MDL-45565 core_message: Fixed strangers array
[moodle.git] / mod / quiz / report / default.php
blobd783cf7311ac774d50434baac97052ecded91193
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.
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/>.
17 /**
18 * Base class for quiz report plugins.
20 * @package mod_quiz
21 * @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die();
29 /**
30 * Base class for quiz report plugins.
32 * Doesn't do anything on it's own -- it needs to be extended.
33 * This class displays quiz reports. Because it is called from
34 * within /mod/quiz/report.php you can assume that the page header
35 * and footer are taken care of.
37 * This file can refer to itself as report.php to pass variables
38 * to itself - all these will also be globally available. You must
39 * pass "id=$cm->id" or q=$quiz->id", and "mode=reportname".
41 * @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
42 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
44 abstract class quiz_default_report {
45 const NO_GROUPS_ALLOWED = -2;
47 /**
48 * Override this function to displays the report.
49 * @param $cm the course-module for this quiz.
50 * @param $course the coures we are in.
51 * @param $quiz this quiz.
53 public abstract function display($cm, $course, $quiz);
55 /**
56 * Initialise some parts of $PAGE and start output.
58 * @param object $cm the course_module information.
59 * @param object $coures the course settings.
60 * @param object $quiz the quiz settings.
61 * @param string $reportmode the report name.
63 public function print_header_and_tabs($cm, $course, $quiz, $reportmode = 'overview') {
64 global $PAGE, $OUTPUT;
66 // Print the page header.
67 $PAGE->set_title($quiz->name);
68 $PAGE->set_heading($course->fullname);
69 echo $OUTPUT->header();
70 $context = context_module::instance($cm->id);
71 echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
74 /**
75 * Get the current group for the user user looking at the report.
77 * @param object $cm the course_module information.
78 * @param object $coures the course settings.
79 * @param context $context the quiz context.
80 * @return int the current group id, if applicable. 0 for all users,
81 * NO_GROUPS_ALLOWED if the user cannot see any group.
83 public function get_current_group($cm, $course, $context) {
84 $groupmode = groups_get_activity_groupmode($cm, $course);
85 $currentgroup = groups_get_activity_group($cm, true);
87 if ($groupmode == SEPARATEGROUPS && !$currentgroup && !has_capability('moodle/site:accessallgroups', $context)) {
88 $currentgroup = self::NO_GROUPS_ALLOWED;
91 return $currentgroup;