MDL-11515:
[moodle-linuxchix.git] / grade / report / grader / preferences.php
blob494d94cc879996572d3d62f70826cf31b78f5945
1 <?php // $Id$
3 ///////////////////////////////////////////////////////////////////////////
4 // //
5 // NOTICE OF COPYRIGHT //
6 // //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
9 // //
10 // Copyright (C) 2001-2007 Martin Dougiamas http://dougiamas.com //
11 // //
12 // This program is free software; you can redistribute it and/or modify //
13 // it under the terms of the GNU General Public License as published by //
14 // the Free Software Foundation; either version 2 of the License, or //
15 // (at your option) any later version. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details: //
21 // //
22 // http://www.gnu.org/copyleft/gpl.html //
23 // //
24 ///////////////////////////////////////////////////////////////////////////
25 set_time_limit(0);
26 require_once '../../../config.php';
27 require_once $CFG->libdir . '/gradelib.php';
28 require_once '../../lib.php';
30 $courseid = required_param('id', PARAM_INT);
32 /// Make sure they can even access this course
34 if (!$course = get_record('course', 'id', $courseid)) {
35 print_error('nocourseid');
38 require_login($course->id);
40 $context = get_context_instance(CONTEXT_COURSE, $course->id);
41 $systemcontext = get_context_instance(CONTEXT_SYSTEM);
42 require_capability('gradereport/grader:view', $context);
44 // If data submitted, then process and store.
45 if ($data = data_submitted()) {
46 foreach ($data as $preference => $value) {
47 if (substr($preference, 0, 6) !== 'grade_') {
48 continue;
51 if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) {
52 unset_user_preference($preference);
53 } else {
54 set_user_preference($preference, $value);
58 redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid); // message here breaks accessability and is sloooowww
59 exit;
62 $strgrades = get_string('grades');
63 $strgraderreport = get_string('modulename', 'gradereport_grader');
64 $strgradepreferences = get_string('gradepreferences', 'grades');
66 $navigation = grade_build_nav(__FILE__, $strgradepreferences, $courseid);
68 print_header_simple($strgrades.': '.$strgraderreport . ': ' . $strgradepreferences,': '.$strgradepreferences, $navigation,
69 '', '', true, '', navmenu($course));
71 /// Print the plugin selector at the top
72 print_grade_plugin_selector($course->id, 'report', 'grader');
74 // Add tabs
75 $currenttab = 'preferences';
76 include('tabs.php');
78 // If USER has admin capability, print a link to the site config page for this report
79 if (has_capability('moodle/site:config', $systemcontext)) {
80 echo '<div id="siteconfiglink"><a href="' . $CFG->wwwroot . '/admin/settings.php?section=gradereportgrader">';
81 echo get_string('changereportdefaults', 'grades');
82 echo "</a></div>\n";
85 print_simple_box_start("center");
87 require('preferences_form.php');
88 $mform = new grader_report_preferences_form('preferences.php', compact('course'));
89 echo $mform->display();
90 print_simple_box_end();
92 print_footer($course);