Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This script controls the display of the quiz reports. 19 * 20 * @package mod_quiz 21 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 use mod_quiz\quiz_settings; 26 27 define('NO_OUTPUT_BUFFERING', true); 28 29 require_once(__DIR__ . '/../../config.php'); 30 require_once($CFG->dirroot . '/mod/quiz/locallib.php'); 31 require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); 32 33 $id = optional_param('id', 0, PARAM_INT); 34 $q = optional_param('q', 0, PARAM_INT); 35 $mode = optional_param('mode', '', PARAM_ALPHA); 36 37 if ($id) { 38 $quizobj = quiz_settings::create_for_cmid($id); 39 } else { 40 $quizobj = quiz_settings::create($q); 41 } 42 $quiz = $quizobj->get_quiz(); 43 $cm = $quizobj->get_cm(); 44 $course = $quizobj->get_course(); 45 46 $url = new moodle_url('/mod/quiz/report.php', ['id' => $cm->id]); 47 if ($mode !== '') { 48 $url->param('mode', $mode); 49 } 50 $PAGE->set_url($url); 51 52 require_login($course, false, $cm); 53 $PAGE->set_pagelayout('report'); 54 $PAGE->activityheader->disable(); 55 $reportlist = quiz_report_list($quizobj->get_context()); 56 if (empty($reportlist)) { 57 throw new \moodle_exception('erroraccessingreport', 'quiz'); 58 } 59 60 // Validate the requested report name. 61 if ($mode == '') { 62 // Default to first accessible report and redirect. 63 $url->param('mode', reset($reportlist)); 64 redirect($url); 65 } else if (!in_array($mode, $reportlist)) { 66 throw new \moodle_exception('erroraccessingreport', 'quiz'); 67 } 68 if (!is_readable("report/$mode/report.php")) { 69 throw new \moodle_exception('reportnotfound', 'quiz', '', $mode); 70 } 71 72 // Open the selected quiz report and display it. 73 $file = $CFG->dirroot . '/mod/quiz/report/' . $mode . '/report.php'; 74 if (is_readable($file)) { 75 include_once($file); 76 } 77 $reportclassname = 'quiz_' . $mode . '_report'; 78 if (!class_exists($reportclassname)) { 79 throw new \moodle_exception('preprocesserror', 'quiz'); 80 } 81 82 $report = new $reportclassname(); 83 $report->display($quiz, $cm, $course); 84 85 // Print footer. 86 echo $OUTPUT->footer(); 87 88 // Log that this report was viewed. 89 $params = [ 90 'context' => $quizobj->get_context(), 91 'other' => [ 92 'quizid' => $quiz->id, 93 'reportname' => $mode 94 ] 95 ]; 96 $event = \mod_quiz\event\report_viewed::create($params); 97 $event->add_record_snapshot('course', $course); 98 $event->add_record_snapshot('quiz', $quiz); 99 $event->trigger();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body