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