Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Grader report preferences configuration page
19
 *
20
 * @package   gradereport_grader
21
 * @copyright 2007 Nicolas Connault
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->libdir . '/gradelib.php';
27
require_once '../../lib.php';
28
core_php_time_limit::raise();
29
 
30
$courseid      = required_param('id', PARAM_INT);
31
 
32
$PAGE->set_url(new moodle_url('/grade/report/grader/preferences.php', array('id'=>$courseid)));
33
$PAGE->set_pagelayout('admin');
34
 
35
/// Make sure they can even access this course
36
 
37
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
38
    throw new \moodle_exception('invalidcourseid');
39
}
40
 
41
require_login($course);
42
 
43
$context = context_course::instance($course->id);
44
$systemcontext = context_system::instance();
45
require_capability('gradereport/grader:view', $context);
46
 
47
require('preferences_form.php');
48
$mform = new grader_report_preferences_form('preferences.php', compact('course'));
49
 
50
// If data submitted, then process and store.
51
if ($data = $mform->get_data()) {
52
    foreach ($data as $preference => $value) {
53
        if (substr($preference, 0, 6) !== 'grade_') {
54
            continue;
55
        }
56
 
57
        if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) {
58
            unset_user_preference($preference);
59
        } else {
60
            set_user_preference($preference, $value);
61
        }
62
    }
63
}
64
 
65
print_grade_page_head($courseid, 'settings', 'grader');
66
 
67
// If USER has admin capability, print a link to the site config page for this report
68
if (has_capability('moodle/site:config', $systemcontext)) {
69
    echo '<div id="siteconfiglink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereportgrader">';
70
    echo get_string('changereportdefaults', 'grades');
71
    echo "</a></div>\n";
72
}
73
 
74
echo $OUTPUT->box_start();
75
 
76
$mform->display();
77
echo $OUTPUT->box_end();
78
 
79
echo $OUTPUT->footer();
80