Slight change to recent activity calculations in RA block.
authormoodler <moodler>
Sat, 15 May 2004 14:58:12 +0000 (14:58 +0000)
committermoodler <moodler>
Sat, 15 May 2004 14:58:12 +0000 (14:58 +0000)
Upon login, the last access to each course is stored in the USER session
variable.

The earliest date of recent activity now shown is now the earliest of:

   - this last access time
   - the last login time

If this value is older than two days, then just use two days instead.

course/lib.php
lib/datalib.php

index 8f57443a0212070481ec131fd1ab9d70ef6f2a25..9c7e380b965317997cb1d2c36d4a35a282a4eb52 100644 (file)
@@ -12,7 +12,7 @@ define('COURSE_MAX_LOGS_PER_PAGE', 1000);    // records
 
 define('COURSE_LIVELOG_REFRESH', 60);        // Seconds
 
-define('COURSE_MAX_RECENT_PERIOD', 86400);  // A day, in seconds
+define('COURSE_MAX_RECENT_PERIOD', 172800);  // Two days, in seconds
 
 define('COURSE_MAX_SUMMARIES_PER_PAGE', 10); // courses
 
@@ -482,15 +482,14 @@ function print_recent_activity($course) {
 
     $isteacher = isteacher($course->id);
 
+    $timestart = $USER->lastlogin;
 
-    if (empty($USER->lastlogin)) {
-        echo '<p align="center"><font size="1">';
-        print_string("welcometocourse", "", $course->shortname);
-        echo '</font></p>';
-        return;
+    if (!empty($USER->timeaccess[$course->id])) {
+        if ($USER->timeaccess[$course->id] < $timestart) {
+            $timestart = $USER->timeaccess[$course->id];
+        }
     }
 
-    $timestart = $USER->lastlogin;
     $timemaxrecent = time() - COURSE_MAX_RECENT_PERIOD;
     if ($timestart < $timemaxrecent) {
         $timestart = $timemaxrecent;
index 89262dc03968ca0c8db9cca4ea61b586f068a1b5..22887a61637531bd61d8c41074fd9c5e5247e337 100644 (file)
@@ -912,6 +912,7 @@ function get_user_info_from_db($field, $value) {
             if (get_field("course", "visible", "id", $student->course)) {
                 $user->student[$student->course] = true;
             }
+            $user->timeaccess[$student->course] = $student->timeaccess;
         }
     }
 
@@ -921,6 +922,7 @@ function get_user_info_from_db($field, $value) {
             if ($teacher->editall) {
                 $user->teacheredit[$teacher->course] = true;
             }
+            $user->timeaccess[$teacher->course] = $teacher->timeaccess;
         }
     }