2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Base lib class for singleview functionality.
20 * @package gradereport_singleview
21 * @copyright 2014 Moodle Pty Ltd (http://moodle.com)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die;
27 require_once($CFG->dirroot . '/grade/report/lib.php');
30 * This class is the main class that must be implemented by a grade report plugin.
32 * @package gradereport_singleview
33 * @copyright 2014 Moodle Pty Ltd (http://moodle.com)
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class gradereport_singleview extends grade_report {
39 * Return the list of valid screens, used to validate the input.
41 * @return array List of screens.
43 public static function valid_screens() {
44 // This is a list of all the known classes representing a screen in this plugin.
45 return array('user', 'select', 'grade');
49 * Process data from a form submission. Delegated to the current screen.
51 * @param array $data The data from the form
52 * @return array List of warnings
54 public function process_data($data) {
55 if (has_capability('moodle/grade:manage', $this->context)) {
56 return $this->screen->process($data);
61 * Unused - abstract function declared in the parent class.
63 * @param string $target
64 * @param string $action
66 public function process_action($target, $action) {
70 * Constructor for this report. Creates the appropriate screen class based on itemtype.
72 * @param int $courseid The course id.
73 * @param object $gpr grade plugin return tracking object
74 * @param context_course $context
75 * @param string $itemtype Should be user, select or grade
76 * @param int $itemid The id of the user or grade item
77 * @param string $unused Used to be group id but that was removed and this is now unused.
79 public function __construct($courseid, $gpr, $context, $itemtype, $itemid, $unused = null) {
80 parent::__construct($courseid, $gpr, $context);
82 $base = '/grade/report/singleview/index.php';
84 $idparams = array('id' => $courseid);
86 $this->baseurl = new moodle_url($base, $idparams);
88 $this->pbarurl = new moodle_url($base, $idparams + array(
93 // The setup_group method is used to validate group mode and permissions and define the currentgroup value.
94 $this->setup_groups();
96 $screenclass = "\\gradereport_singleview\\local\\screen\\${itemtype}";
98 $this->screen = new $screenclass($courseid, $itemid, $this->currentgroup);
100 // Load custom or predifined js.
105 * Build the html for the screen.
106 * @return string HTML to display
108 public function output() {
110 return $OUTPUT->box($this->screen->html());