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/>.
|
2007-10-10 06:34:20 +00:00
|
|
|
|
2007-10-08 23:09:10 +00:00
|
|
|
require_once '../../../config.php';
|
|
|
|
require_once $CFG->dirroot.'/grade/lib.php';
|
|
|
|
require_once $CFG->libdir.'/gradelib.php';
|
|
|
|
require_once 'form.php';
|
|
|
|
|
|
|
|
$courseid = optional_param('id', SITEID, PARAM_INT);
|
|
|
|
|
2008-06-02 16:06:33 +00:00
|
|
|
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
2007-10-08 23:09:10 +00:00
|
|
|
print_error('nocourseid');
|
|
|
|
}
|
|
|
|
require_login($course);
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
|
|
|
|
|
|
|
require_capability('moodle/grade:manage', $context);
|
|
|
|
|
|
|
|
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'settings', 'courseid'=>$courseid));
|
|
|
|
|
|
|
|
$strgrades = get_string('grades');
|
|
|
|
$pagename = get_string('coursesettings', 'grades');
|
|
|
|
|
|
|
|
$navigation = grade_build_nav(__FILE__, $pagename, $courseid);
|
|
|
|
|
|
|
|
$returnurl = $CFG->wwwroot.'/grade/index.php?id='.$course->id;
|
|
|
|
|
|
|
|
$mform = new course_settings_form();
|
|
|
|
|
2007-10-27 15:33:43 +00:00
|
|
|
$settings = grade_get_settings($course->id);
|
2007-10-08 23:09:10 +00:00
|
|
|
|
2007-10-27 15:33:43 +00:00
|
|
|
$mform->set_data($settings);
|
2007-10-08 23:09:10 +00:00
|
|
|
|
|
|
|
if ($mform->is_cancelled()) {
|
|
|
|
redirect($returnurl);
|
|
|
|
|
2008-06-09 16:53:30 +00:00
|
|
|
} else if ($data = $mform->get_data()) {
|
2007-10-27 15:33:43 +00:00
|
|
|
$data = (array)$data;
|
|
|
|
$general = array('displaytype', 'decimalpoints', 'aggregationposition');
|
|
|
|
foreach ($data as $key=>$value) {
|
|
|
|
if (!in_array($key, $general) and strpos($key, 'report_') !== 0
|
|
|
|
and strpos($key, 'import_') !== 0
|
|
|
|
and strpos($key, 'export_') !== 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($value == -1) {
|
|
|
|
$value = null;
|
|
|
|
}
|
|
|
|
grade_set_setting($course->id, $key, $value);
|
2007-10-08 23:09:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
redirect($returnurl);
|
|
|
|
}
|
|
|
|
|
2009-02-11 14:27:22 +00:00
|
|
|
print_grade_page_head($courseid, 'settings', 'coursesettings', get_string('coursesettings', 'grades'));
|
2007-10-08 23:09:10 +00:00
|
|
|
|
2009-08-10 04:54:32 +00:00
|
|
|
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal centerpara');
|
2009-02-17 11:17:29 +00:00
|
|
|
echo get_string('coursesettingsexplanation', 'grades');
|
2009-08-10 04:54:32 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2009-02-17 11:17:29 +00:00
|
|
|
|
2007-10-08 23:09:10 +00:00
|
|
|
$mform->display();
|
|
|
|
|
2009-08-06 14:12:17 +00:00
|
|
|
echo $OUTPUT->footer();
|
2007-10-08 23:09:10 +00:00
|
|
|
|
|
|
|
?>
|