Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Log Moodle user page load statistics
define('AJAX_SCRIPT', true);
require(__DIR__ . '/config.php');
$contextid = required_param('contextid', PARAM_INT);
$preftiming = optional_param('preftiming', '', PARAM_RAW);
// Security.
list($context, $course, $cm) = get_context_info_array($contextid);
require_login($course->id, false, $cm);
//require_capability('moodle/role:review', $context);
$preftimings = json_decode($preftiming);
//echo json_encode($preftiming['domContentLoadedEventEnd']);
$eventdata = array();
$eventdata['context'] = $context;
$eventdata['other']['preftimings'] = $preftimings;
$eventdata['courseid'] = $course->id;
$eventdata['userid'] = $USER->id;
//$eventdata['action'] = 'preftiming';
$event = \core\event\course_viewed::create($eventdata)->trigger();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment