2009-07-07 02:26:36 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-01-06 11:52:46 +07:00
|
|
|
/**
|
|
|
|
* Grader report preferences configuration page
|
|
|
|
*
|
|
|
|
* @package gradereport_grader
|
|
|
|
* @copyright 2007 Nicolas Connault
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
2007-06-26 06:19:45 +00:00
|
|
|
require_once '../../../config.php';
|
|
|
|
require_once $CFG->libdir . '/gradelib.php';
|
2007-07-23 08:13:59 +00:00
|
|
|
require_once '../../lib.php';
|
2013-12-04 16:59:03 +00:00
|
|
|
core_php_time_limit::raise();
|
2007-06-26 06:19:45 +00:00
|
|
|
|
2007-07-04 15:23:36 +00:00
|
|
|
$courseid = required_param('id', PARAM_INT);
|
2007-06-26 06:19:45 +00:00
|
|
|
|
2010-05-05 03:27:22 +00:00
|
|
|
$PAGE->set_url(new moodle_url('/grade/report/grader/preferences.php', array('id'=>$courseid)));
|
|
|
|
$PAGE->set_pagelayout('admin');
|
2009-10-15 06:58:21 +00:00
|
|
|
|
2007-06-26 06:19:45 +00:00
|
|
|
/// Make sure they can even access this course
|
|
|
|
|
2008-06-03 16:10:57 +00:00
|
|
|
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('invalidcourseid');
|
2007-06-26 06:19:45 +00:00
|
|
|
}
|
|
|
|
|
2012-04-22 17:41:47 +02:00
|
|
|
require_login($course);
|
2007-06-26 06:19:45 +00:00
|
|
|
|
2012-07-24 14:04:40 +08:00
|
|
|
$context = context_course::instance($course->id);
|
|
|
|
$systemcontext = context_system::instance();
|
2007-09-17 17:31:48 +00:00
|
|
|
require_capability('gradereport/grader:view', $context);
|
2007-07-04 15:23:36 +00:00
|
|
|
|
2007-12-05 02:59:44 +00:00
|
|
|
require('preferences_form.php');
|
|
|
|
$mform = new grader_report_preferences_form('preferences.php', compact('course'));
|
|
|
|
|
2007-07-05 21:42:34 +00:00
|
|
|
// If data submitted, then process and store.
|
2021-10-30 00:48:55 +08:00
|
|
|
if ($data = $mform->get_data()) {
|
2007-08-16 17:53:08 +00:00
|
|
|
foreach ($data as $preference => $value) {
|
2007-10-08 07:11:22 +00:00
|
|
|
if (substr($preference, 0, 6) !== 'grade_') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) {
|
|
|
|
unset_user_preference($preference);
|
|
|
|
} else {
|
|
|
|
set_user_preference($preference, $value);
|
2007-07-04 15:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-17 09:12:25 +00:00
|
|
|
}
|
|
|
|
|
2023-05-09 10:36:00 +10:00
|
|
|
print_grade_page_head($courseid, 'settings', 'grader');
|
2007-09-14 06:51:57 +00:00
|
|
|
|
2007-07-30 09:46:01 +00:00
|
|
|
// If USER has admin capability, print a link to the site config page for this report
|
2007-10-03 14:16:04 +00:00
|
|
|
if (has_capability('moodle/site:config', $systemcontext)) {
|
2007-12-19 17:35:20 +00:00
|
|
|
echo '<div id="siteconfiglink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereportgrader">';
|
2007-10-08 23:09:10 +00:00
|
|
|
echo get_string('changereportdefaults', 'grades');
|
2007-08-16 17:53:08 +00:00
|
|
|
echo "</a></div>\n";
|
2007-07-30 09:46:01 +00:00
|
|
|
}
|
|
|
|
|
2009-08-18 04:59:57 +00:00
|
|
|
echo $OUTPUT->box_start();
|
2007-07-04 15:23:36 +00:00
|
|
|
|
2007-12-05 02:59:44 +00:00
|
|
|
$mform->display();
|
2009-08-18 04:59:57 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2007-07-04 15:23:36 +00:00
|
|
|
|
2009-08-06 14:12:17 +00:00
|
|
|
echo $OUTPUT->footer();
|
2009-11-01 12:11:29 +00:00
|
|
|
|