} } $url = new moodle_url('/mod/offlinequiz/report.php', array('id' => $cm->id)); if ($mode != '') { $url->param('mode', $mode); } $PAGE->set_url($url); $PAGE->set_pagelayout('report'); require_login($course, false, $cm); $context = context_module::instance($cm->id); require_capability('mod/offlinequiz:viewreports', $context); $node = $PAGE->settingsnav->find('mod_offlinequiz_results', navigation_node::TYPE_SETTING); if ($node) { $node->make_active(); } $reportlist = offlinequiz_report_list($context); if (empty($reportlist)) { print_error('erroraccessingreport', 'offlinequiz'); } // Validate the requested report name. if ($mode == '') { // Default to first accessible report and redirect. $url->param('mode', reset($reportlist)); redirect($url); } else { if (!in_array($mode, $reportlist)) { print_error('erroraccessingreport', 'offlinequiz'); } } if (!is_readable("report/{$mode}/report.php")) { print_error('reportnotfound', 'offlinequiz', '', $mode);
/** * Get the default report for the current user. * @param object $context the offlinequiz context. */ function offlinequiz_report_default_report($context) { $reports = offlinequiz_report_list($context); return reset($reports); }