|
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 set_time_limit(0); 00019 require_once '../../../config.php'; 00020 require_once $CFG->libdir . '/gradelib.php'; 00021 require_once '../../lib.php'; 00022 00023 $courseid = required_param('id', PARAM_INT); 00024 00025 $PAGE->set_url(new moodle_url('/grade/report/grader/preferences.php', array('id'=>$courseid))); 00026 $PAGE->set_pagelayout('admin'); 00027 00029 00030 if (!$course = $DB->get_record('course', array('id' => $courseid))) { 00031 print_error('nocourseid'); 00032 } 00033 00034 require_login($course->id); 00035 00036 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00037 $systemcontext = get_context_instance(CONTEXT_SYSTEM); 00038 require_capability('gradereport/grader:view', $context); 00039 00040 require('preferences_form.php'); 00041 $mform = new grader_report_preferences_form('preferences.php', compact('course')); 00042 00043 // If data submitted, then process and store. 00044 if (!$mform->is_cancelled() && $data = $mform->get_data()) { 00045 foreach ($data as $preference => $value) { 00046 if (substr($preference, 0, 6) !== 'grade_') { 00047 continue; 00048 } 00049 00050 if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) { 00051 unset_user_preference($preference); 00052 } else { 00053 set_user_preference($preference, $value); 00054 } 00055 } 00056 00057 redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid); // message here breaks accessability and is sloooowww 00058 exit; 00059 } 00060 00061 if ($mform->is_cancelled()){ 00062 redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid); 00063 } 00064 00065 print_grade_page_head($courseid, 'preferences', 'grader', get_string('preferences', 'gradereport_grader')); 00066 00067 // If USER has admin capability, print a link to the site config page for this report 00068 if (has_capability('moodle/site:config', $systemcontext)) { 00069 echo '<div id="siteconfiglink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereportgrader">'; 00070 echo get_string('changereportdefaults', 'grades'); 00071 echo "</a></div>\n"; 00072 } 00073 00074 echo $OUTPUT->box_start(); 00075 00076 $mform->display(); 00077 echo $OUTPUT->box_end(); 00078 00079 echo $OUTPUT->footer(); 00080