MDL-63716 course: less user_accesstime_log() calls

We should only call this function when a user actually views a course. It is not called
automatically when a course context is validated from a webservice. It is called directly
from the core_course_view_course webservice.
This commit is contained in:
Damyon Wiese 2018-11-09 13:09:54 +08:00
parent 208950cff0
commit 160e77f9d0
3 changed files with 12 additions and 2 deletions

View File

@ -26,6 +26,7 @@ defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/datalib.php');
require_once($CFG->dirroot.'/course/format/lib.php');
define('COURSE_MAX_LOGS_PER_PAGE', 1000); // Records.
@ -3665,6 +3666,8 @@ function course_view($context, $sectionnumber = 0) {
$event = \core\event\course_viewed::create($eventdata);
$event->trigger();
user_accesstime_log($context->instanceid);
}
/**

View File

@ -2763,7 +2763,10 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
$PAGE->set_course($course);
}
// Set accesstime or the user will appear offline which messes up messaging.
user_accesstime_log($course->id);
// Do not update access time for webservice or ajax requests.
if (!WS_SERVER && !AJAX_SCRIPT) {
user_accesstime_log($course->id);
}
return;
}
@ -2972,7 +2975,10 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
}
// Finally access granted, update lastaccess times.
user_accesstime_log($course->id);
// Do not update access time for webservice or ajax requests.
if (!WS_SERVER && !AJAX_SCRIPT) {
user_accesstime_log($course->id);
}
}

View File

@ -165,6 +165,7 @@ the groupid field.
until all settings have been set. The additional parameters are used recursively and shouldn't be need to be explicitly passed in when calling
the function from other parts of Moodle.
The return value: $settingsoutput is an array of setting names and the values that were set by the function.
* Webservices no longer update the lastaccess time for a user in a course. Call core_course_view_course() manually if needed.
=== 3.5 ===