Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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 * Displays the Single view 19 * 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 23 */ 24 25 define('NO_OUTPUT_BUFFERING', true); 26 27 require_once('../../../config.php'); 28 require_once($CFG->dirroot.'/lib/gradelib.php'); 29 require_once($CFG->dirroot.'/grade/lib.php'); 30 require_once($CFG->dirroot.'/grade/report/singleview/lib.php'); 31 32 $courseid = required_param('id', PARAM_INT); 33 $groupid = optional_param('group', null, PARAM_INT); 34 35 // Making this work with profile reports. 36 $userid = optional_param('userid', null, PARAM_INT); 37 38 $defaulttype = $userid ? 'user' : 'select'; 39 40 $itemid = optional_param('itemid', null, PARAM_INT); 41 $itemtype = optional_param('item', $defaulttype, PARAM_TEXT); 42 $page = optional_param('page', 0, PARAM_INT); 43 $perpage = optional_param('perpage', 100, PARAM_INT); 44 45 if (empty($itemid)) { 46 $itemid = $userid; 47 $itemtype = $defaulttype; 48 } 49 50 $courseparams = array('id' => $courseid); 51 $pageparams = array( 52 'id' => $courseid, 53 'group' => $groupid, 54 'userid' => $userid, 55 'itemid' => $itemid, 56 'item' => $itemtype, 57 'page' => $page, 58 'perpage' => $perpage, 59 ); 60 $PAGE->set_url(new moodle_url('/grade/report/singleview/index.php', $pageparams)); 61 $PAGE->set_pagelayout('incourse'); 62 63 if (!$course = $DB->get_record('course', $courseparams)) { 64 print_error('invalidcourseid'); 65 } 66 67 require_login($course); 68 69 if (!in_array($itemtype, gradereport_singleview::valid_screens())) { 70 print_error('notvalid', 'gradereport_singleview', '', $itemtype); 71 } 72 73 $context = context_course::instance($course->id); 74 75 // This is the normal requirements. 76 require_capability('gradereport/singleview:view', $context); 77 require_capability('moodle/grade:viewall', $context); 78 require_capability('moodle/grade:edit', $context); 79 80 $gpr = new grade_plugin_return(array( 81 'type' => 'report', 82 'plugin' => 'singleview', 83 'courseid' => $courseid 84 )); 85 86 // Last selected report session tracking. 87 if (!isset($USER->grade_last_report)) { 88 $USER->grade_last_report = array(); 89 } 90 $USER->grade_last_report[$course->id] = 'singleview'; 91 92 $report = new gradereport_singleview($courseid, $gpr, $context, $itemtype, $itemid); 93 94 $reportname = $report->screen->heading(); 95 96 $pluginname = get_string('pluginname', 'gradereport_singleview'); 97 98 $pageparams = array( 99 'id' => $courseid, 100 'itemid' => $itemid, 101 'item' => $itemtype, 102 'userid' => $userid, 103 'group' => $groupid, 104 'page' => $page, 105 'perpage' => $perpage 106 ); 107 108 $PAGE->set_pagelayout('report'); 109 110 $actionbar = new \core_grades\output\general_action_bar($context, 111 new moodle_url('/grade/report/singleview/index.php', ['id' => $courseid]), 'report', 'singleview'); 112 113 if ($itemtype == 'user') { 114 print_grade_page_head($course->id, 'report', 'singleview', $reportname, false, false, 115 true, null, null, $report->screen->item, $actionbar); 116 } else { 117 print_grade_page_head($course->id, 'report', 'singleview', $reportname, false, false, 118 true, null, null, null, $actionbar); 119 } 120 121 if ($data = data_submitted()) { 122 // Must have a sesskey for all actions. 123 require_sesskey(); 124 $result = $report->process_data($data); 125 126 // If result is not null (because somedata was processed), warnings and success message should be displayed. 127 if (!is_null($result)) { 128 if (!empty($result->warnings)) { 129 foreach ($result->warnings as $warning) { 130 \core\notification::add($warning); 131 } 132 } 133 134 // And notify the user of the success result. 135 \core\notification::add( 136 get_string('savegradessuccess', 'gradereport_singleview', count ((array)$result->changecount)), 137 \core\notification::SUCCESS 138 ); 139 } 140 } 141 142 // Make sure we have proper final grades. 143 grade_regrade_final_grades_if_required($course); 144 145 $graderrightnav = $graderleftnav = null; 146 147 $options = $report->screen->options(); 148 149 if (!empty($options)) { 150 151 $optionkeys = array_keys($options); 152 $optionitemid = array_shift($optionkeys); 153 154 $relreport = new gradereport_singleview( 155 $courseid, $gpr, $context, 156 $report->screen->item_type(), $optionitemid 157 ); 158 $reloptions = $relreport->screen->options(); 159 $reloptionssorting = array_keys($relreport->screen->options()); 160 161 $i = array_search($itemid, $reloptionssorting); 162 $navparams = array('item' => $itemtype, 'id' => $courseid, 'group' => $groupid); 163 if ($i > 0) { 164 $navparams['itemid'] = $reloptionssorting[$i - 1]; 165 $link = new moodle_url('/grade/report/singleview/index.php', $navparams); 166 $navprev = html_writer::link($link, $OUTPUT->larrow() . ' ' . $reloptions[$reloptionssorting[$i - 1]]); 167 $graderleftnav = html_writer::tag('div', $navprev, array('class' => 'itemnav previtem')); 168 } 169 if ($i < count($reloptionssorting) - 1) { 170 $navparams['itemid'] = $reloptionssorting[$i + 1]; 171 $link = new moodle_url('/grade/report/singleview/index.php', $navparams); 172 $navnext = html_writer::link($link, $reloptions[$reloptionssorting[$i + 1]] . ' ' . $OUTPUT->rarrow()); 173 $graderrightnav = html_writer::tag('div', $navnext, array('class' => 'itemnav nextitem')); 174 } 175 } 176 177 if (!is_null($graderleftnav)) { 178 echo $graderleftnav; 179 } 180 if (!is_null($graderrightnav)) { 181 echo $graderrightnav; 182 } 183 184 if ($report->screen->supports_paging()) { 185 echo $report->screen->pager(); 186 } 187 188 if ($report->screen->display_group_selector()) { 189 echo $report->group_selector; 190 } 191 192 echo $report->output(); 193 194 if ($report->screen->supports_paging()) { 195 echo $report->screen->perpage_select(); 196 echo $report->screen->pager(); 197 } 198 199 if (!is_null($graderleftnav)) { 200 echo $graderleftnav; 201 } 202 if (!is_null($graderrightnav)) { 203 echo $graderrightnav; 204 } 205 206 $event = \gradereport_singleview\event\grade_report_viewed::create( 207 array( 208 'context' => $context, 209 'courseid' => $courseid, 210 'relateduserid' => $USER->id, 211 ) 212 ); 213 $event->trigger(); 214 215 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body