function scorm_get_tracks($scoid, $userid, $attempt = '') { // Gets all tracks of specified sco and user. global $DB; if (empty($attempt)) { if ($scormid = $DB->get_field('scorm_scoes', 'scorm', array('id' => $scoid))) { $attempt = scorm_get_last_attempt($scormid, $userid); } else { $attempt = 1; } } if ($tracks = $DB->get_records('scorm_scoes_track', array('userid' => $userid, 'scoid' => $scoid, 'attempt' => $attempt), 'element ASC')) { $usertrack = scorm_format_interactions($tracks); $usertrack->userid = $userid; $usertrack->scoid = $scoid; return $usertrack; } else { return false; } }
// END of url setting + data buildup. // Checking login +logging +getting context. require_login($course, false, $cm); $contextmodule = context_module::instance($cm->id); require_capability('mod/scorm:viewreport', $contextmodule); // Check user has group access. if (!groups_user_groups_visible($course, $userid, $cm)) { throw new moodle_exception('nopermissiontoshow'); } // Trigger a user interactions viewed event. $event = \mod_scorm\event\interactions_viewed::create(array('context' => $contextmodule, 'relateduserid' => $userid, 'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id))); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('scorm', $scorm); $event->trigger(); $trackdata = $DB->get_records('scorm_scoes_track', array('userid' => $user->id, 'scormid' => $scorm->id, 'attempt' => $attempt)); $usertrack = scorm_format_interactions($trackdata); $questioncount = get_scorm_question_count($scorm->id); $courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id))); $exportfilename = $courseshortname . '-' . format_string($scorm->name, true) . '-' . get_string('interactions', 'scorm'); // Set up the table. $table = new flexible_table('mod-scorm-userreport-interactions'); if (!$table->is_downloading($download, $exportfilename)) { // Print the page header. $strattempt = get_string('attempt', 'scorm'); $strreport = get_string('report', 'scorm'); $PAGE->set_title("{$course->shortname}: " . format_string($scorm->name)); $PAGE->set_heading($course->fullname); $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id))); $PAGE->navbar->add(fullname($user) . " - {$strattempt} {$attempt}"); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($scorm->name));