Commit e87c74e9 authored by Tim Lock's avatar Tim Lock
Browse files

MDL-46710 mod_lti: fix logging and completion tracking in new windows

parent 3377cbc3
......@@ -61,6 +61,20 @@ $context = context_module::instance($cm->id);
require_login($course, true, $cm);
require_capability('mod/lti:view', $context);
// Mark viewed by user (if required).
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$params = array(
'context' => $context,
'objectid' => $lti->id
);
$event = \mod_lti\event\course_module_viewed::create($params);
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('lti', $lti);
$event->trigger();
$lti->cmid = $cm->id;
lti_view($lti);
......@@ -102,11 +102,15 @@ $params = array(
'context' => $context,
'objectid' => $lti->id
);
$event = \mod_lti\event\course_module_viewed::create($params);
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('lti', $lti);
$event->trigger();
// Prevent double logging when launching in a new window is configured.
if ($launchcontainer != LTI_LAUNCH_CONTAINER_WINDOW) {
$event = \mod_lti\event\course_module_viewed::create($params);
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('lti', $lti);
$event->trigger();
}
$pagetitle = strip_tags($course->shortname.': '.format_string($lti->name));
$PAGE->set_title($pagetitle);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment