/** Tests for report viewed. * * There is no api involved so the best we can do is test legacy data and validations by triggering event manually. */ public function test_report_viewed_event() { $this->resetAfterTest(); $event = \mod_scorm\event\report_viewed::create(array('context' => context_module::instance($this->eventcm->id), 'courseid' => $this->eventcourse->id, 'other' => array('scormid' => $this->eventscorm->id, 'mode' => 'basic'))); // Trigger and capture the event. $sink = $this->redirectEvents(); $event->trigger(); $events = $sink->get_events(); $event = reset($events); // Check that the legacy log data is valid. $expected = array($this->eventcourse->id, 'scorm', 'report', 'report.php?id=' . $this->eventcm->id . '&mode=basic', $this->eventscorm->id, $this->eventcm->id); $this->assertEventLegacyLogData($expected, $event); $this->assertEventContextNotUsed($event); }
if (empty($mode)) { $mode = reset($reportlist); } else { if (!in_array($mode, $reportlist)) { print_error('erroraccessingreport', 'scorm'); } } $url->param('mode', $mode); $PAGE->set_url($url); require_login($course, false, $cm); require_capability('mod/scorm:viewreport', $contextmodule); if (count($reportlist) < 1) { print_error('erroraccessingreport', 'scorm'); } // Trigger a report viewed event. $event = \mod_scorm\event\report_viewed::create(array('context' => $contextmodule, 'other' => array('scormid' => $scorm->id, 'mode' => $mode))); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('scorm', $scorm); $event->trigger(); $userdata = null; if (!empty($download)) { $noheader = true; } /// Print the page header if (empty($noheader)) { $strreport = get_string('report', 'scorm'); $strattempt = get_string('attempt', '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))); echo $OUTPUT->header();