|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00018 require_once '../../../config.php'; 00019 require_once $CFG->libdir.'/gradelib.php'; 00020 require_once $CFG->dirroot.'/grade/lib.php'; 00021 require_once $CFG->dirroot.'/grade/report/grader/lib.php'; 00022 00023 $courseid = required_param('id', PARAM_INT); // course id 00024 $itemid = required_param('itemid', PARAM_INT); // item id 00025 $page = optional_param('page', 0, PARAM_INT); // active page 00026 $perpageurl = optional_param('perpage', 0, PARAM_INT); 00027 00028 $url = new moodle_url('/grade/report/grader/quickedit_item.php', array('id'=>$courseid, 'itemid'=>$itemid)); 00029 if ($page !== 0) { 00030 $url->param('page', $page); 00031 } 00032 if ($perpage !== 0) { 00033 $url->param('perpage', $perpage); 00034 } 00035 $PAGE->set_url($url); 00036 00037 00039 if (!$course = $DB->get_record('course', array('id' => $courseid))) { 00040 print_error('nocourseid'); 00041 } 00042 00043 if (!$item = $DB->get_record('grade_items', array('id' => $itemid))) { 00044 print_error('noitemid', 'grades'); 00045 } 00046 00047 require_login($course); 00048 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00049 00050 require_capability('gradereport/grader:view', $context); 00051 require_capability('moodle/grade:viewall', $context); 00052 require_capability('moodle/grade:edit', $context); 00053 00055 $gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'grader', 'courseid'=>$courseid, 'page'=>$page)); 00056 00058 if (!isset($USER->grade_last_report)) { 00059 $USER->grade_last_report = array(); 00060 } 00061 $USER->grade_last_report[$course->id] = 'grader'; 00062 00063 // Initialise the grader report object 00064 $report = new grade_report_grader($courseid, $gpr, $context, $page); 00065 00067 if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) { 00068 $warnings = $report->process_data($data); 00069 } else { 00070 $warnings = array(); 00071 } 00072 00073 // Override perpage if set in URL 00074 if ($perpageurl) { 00075 $report->user_prefs['studentsperpage'] = $perpageurl; 00076 } 00077 00078 // final grades MUST be loaded after the processing 00079 $report->load_users(); 00080 $numusers = $report->get_numusers(); 00081 $report->load_final_grades(); 00082 00084 $a->item = $item->itemname; 00085 $reportname = get_string('quickedititem', 'gradereport_grader', $a); 00086 print_grade_page_head($COURSE->id, 'report', 'grader', $reportname); 00087 00088 echo $report->group_selector; 00089 echo '<div class="clearer"></div>'; 00090 // echo $report->get_toggles_html(); 00091 00092 //show warnings if any 00093 foreach($warnings as $warning) { 00094 echo $OUTPUT->notification($warning); 00095 } 00096 00097 $studentsperpage = $report->get_pref('studentsperpage'); 00098 // Don't use paging if studentsperpage is empty or 0 at course AND site levels 00099 if (!empty($studentsperpage)) { 00100 echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl); 00101 } 00102 00106 00107 // print submit button 00108 echo '<div class="submit"><input type="submit" value="'.get_string('update').'" /></div>'; 00109 echo '</div></form>'; 00110 00111 // prints paging bar at bottom for large pages 00112 if (!empty($studentsperpage) && $studentsperpage >= 20) { 00113 echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl); 00114 } 00115 00116 echo $OUTPUT->footer(); 00117