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 * The gradebook grade history report 19 * 20 * @package gradereport_history 21 * @copyright 2013 NetSpot Pty Ltd (https://www.netspot.com.au) 22 * @author Adam Olley <adam.olley@netspot.com.au> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require_once(__DIR__ . '/../../../config.php'); 27 require_once($CFG->libdir.'/gradelib.php'); 28 require_once($CFG->dirroot.'/grade/lib.php'); 29 30 $download = optional_param('download', '', PARAM_ALPHA); 31 $courseid = required_param('id', PARAM_INT); // Course id. 32 $page = optional_param('page', 0, PARAM_INT); // Active page. 33 $showreport = optional_param('showreport', 0, PARAM_INT); 34 35 $PAGE->set_pagelayout('report'); 36 $url = new moodle_url('/grade/report/history/index.php', array('id' => $courseid, 'showreport' => 1)); 37 $PAGE->set_url($url); 38 39 $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); 40 require_login($course); 41 $context = context_course::instance($course->id); 42 43 require_capability('gradereport/history:view', $context); 44 require_capability('moodle/grade:viewall', $context); 45 46 // Last selected report session tracking. 47 if (!isset($USER->grade_last_report)) { 48 $USER->grade_last_report = array(); 49 } 50 $USER->grade_last_report[$course->id] = 'history'; 51 52 $select = "itemtype <> 'course' AND courseid = :courseid AND " . $DB->sql_isnotempty('grade_items', 'itemname', true, true); 53 $itemids = $DB->get_records_select_menu('grade_items', $select, array('courseid' => $course->id), 'itemname ASC', 'id, itemname'); 54 foreach ($itemids as $itemid => $itemname) { 55 $itemids[$itemid] = format_string($itemname, false, array("context" => $context)); 56 } 57 $itemids = array(0 => get_string('allgradeitems', 'gradereport_history')) + $itemids; 58 59 $output = $PAGE->get_renderer('gradereport_history'); 60 $graders = \gradereport_history\helper::get_graders($course->id); 61 $params = array('course' => $course, 'itemids' => $itemids, 'graders' => $graders, 'userbutton' => null); 62 $mform = new \gradereport_history\filter_form(null, $params); 63 $filters = array(); 64 if ($data = $mform->get_data()) { 65 $filters = (array)$data; 66 67 if (!empty($filters['datetill'])) { 68 $filters['datetill'] += DAYSECS - 1; // Set to end of the chosen day. 69 } 70 } else { 71 $filters = array( 72 'id' => $courseid, 73 'userids' => optional_param('userids', '', PARAM_SEQUENCE), 74 'itemid' => optional_param('itemid', 0, PARAM_INT), 75 'grader' => optional_param('grader', 0, PARAM_INT), 76 'datefrom' => optional_param('datefrom', 0, PARAM_INT), 77 'datetill' => optional_param('datetill', 0, PARAM_INT), 78 'revisedonly' => optional_param('revisedonly', 0, PARAM_INT), 79 ); 80 } 81 82 $table = new \gradereport_history\output\tablelog('gradereport_history', $context, $url, $filters, $download, $page); 83 84 $names = array(); 85 foreach ($table->get_selected_users() as $key => $user) { 86 $names[$key] = fullname($user); 87 } 88 $filters['userfullnames'] = implode(',', $names); 89 90 // Set up js. 91 \gradereport_history\helper::init_js($course->id, $names); 92 93 // Now that we have the names, reinitialise the button so its able to control them. 94 $button = new \gradereport_history\output\user_button($PAGE->url, get_string('selectusers', 'gradereport_history'), 'get'); 95 96 $userbutton = $output->render($button); 97 $params = array('course' => $course, 'itemids' => $itemids, 'graders' => $graders, 'userbutton' => $userbutton); 98 $mform = new \gradereport_history\filter_form(null, $params); 99 $mform->set_data($filters); 100 101 if ($table->is_downloading()) { 102 // Download file and exit. 103 \core\session\manager::write_close(); 104 echo $output->render($table); 105 die(); 106 } 107 108 // Print header. 109 print_grade_page_head($COURSE->id, 'report', 'history', get_string('pluginname', 'gradereport_history'), false, ''); 110 $mform->display(); 111 112 if ($showreport) { 113 // Only display report after form has been submitted. 114 echo $output->render($table); 115 116 $event = \gradereport_history\event\grade_report_viewed::create( 117 array( 118 'context' => $context, 119 'courseid' => $courseid 120 ) 121 ); 122 $event->trigger(); 123 } 124 125 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body