Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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 // First make sure we have proper final grades. 93 grade_regrade_final_grades_if_required($course); 94 95 $report = new gradereport_singleview($courseid, $gpr, $context, $itemtype, $itemid); 96 97 $reportname = $report->screen->heading(); 98 99 $pluginname = get_string('pluginname', 'gradereport_singleview'); 100 101 $pageparams = array( 102 'id' => $courseid, 103 'itemid' => $itemid, 104 'item' => $itemtype, 105 'userid' => $userid, 106 'group' => $groupid, 107 'page' => $page, 108 'perpage' => $perpage 109 ); 110 111 $currentpage = new moodle_url('/grade/report/singleview/index.php', $pageparams); 112 113 if ($data = data_submitted()) { 114 $PAGE->set_pagelayout('redirect'); 115 $PAGE->set_title(get_string('savegrades', 'gradereport_singleview')); 116 echo $OUTPUT->header(); 117 118 require_sesskey(); // Must have a sesskey for all actions. 119 $result = $report->process_data($data); 120 121 if (!empty($result->warnings)) { 122 foreach ($result->warnings as $warning) { 123 echo $OUTPUT->notification($warning); 124 } 125 } 126 echo $OUTPUT->notification(get_string('savegradessuccess', 'gradereport_singleview', count ((array)$result->changecount))); 127 echo $OUTPUT->continue_button($currentpage); 128 echo $OUTPUT->footer(); 129 die(); 130 } 131 132 $PAGE->set_pagelayout('report'); 133 if ($itemtype == 'user') { 134 print_grade_page_head($course->id, 'report', 'singleview', $reportname, false, false, true, null, null, $report->screen->item); 135 } else { 136 print_grade_page_head($course->id, 'report', 'singleview', $reportname); 137 } 138 139 $graderrightnav = $graderleftnav = null; 140 141 $options = $report->screen->options(); 142 143 if (!empty($options)) { 144 145 $optionkeys = array_keys($options); 146 $optionitemid = array_shift($optionkeys); 147 148 $relreport = new gradereport_singleview( 149 $courseid, $gpr, $context, 150 $report->screen->item_type(), $optionitemid 151 ); 152 $reloptions = $relreport->screen->options(); 153 $reloptionssorting = array_keys($relreport->screen->options()); 154 155 $i = array_search($itemid, $reloptionssorting); 156 $navparams = array('item' => $itemtype, 'id' => $courseid, 'group' => $groupid); 157 if ($i > 0) { 158 $navparams['itemid'] = $reloptionssorting[$i - 1]; 159 $link = new moodle_url('/grade/report/singleview/index.php', $navparams); 160 $navprev = html_writer::link($link, $OUTPUT->larrow() . ' ' . $reloptions[$reloptionssorting[$i - 1]]); 161 $graderleftnav = html_writer::tag('div', $navprev, array('class' => 'itemnav previtem')); 162 } 163 if ($i < count($reloptionssorting) - 1) { 164 $navparams['itemid'] = $reloptionssorting[$i + 1]; 165 $link = new moodle_url('/grade/report/singleview/index.php', $navparams); 166 $navnext = html_writer::link($link, $reloptions[$reloptionssorting[$i + 1]] . ' ' . $OUTPUT->rarrow()); 167 $graderrightnav = html_writer::tag('div', $navnext, array('class' => 'itemnav nextitem')); 168 } 169 } 170 171 if (!is_null($graderleftnav)) { 172 echo $graderleftnav; 173 } 174 if (!is_null($graderrightnav)) { 175 echo $graderrightnav; 176 } 177 178 if ($report->screen->supports_paging()) { 179 echo $report->screen->pager(); 180 } 181 182 if ($report->screen->display_group_selector()) { 183 echo $report->group_selector; 184 } 185 186 echo $report->output(); 187 188 if ($report->screen->supports_paging()) { 189 echo $report->screen->perpage_select(); 190 echo $report->screen->pager(); 191 } 192 193 if (!is_null($graderleftnav)) { 194 echo $graderleftnav; 195 } 196 if (!is_null($graderrightnav)) { 197 echo $graderrightnav; 198 } 199 200 $event = \gradereport_singleview\event\grade_report_viewed::create( 201 array( 202 'context' => $context, 203 'courseid' => $courseid, 204 'relateduserid' => $USER->id, 205 ) 206 ); 207 $event->trigger(); 208 209 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body