"MDL-12304, fix double text"
[moodle-linuxchix.git] / grade / edit / settings / index.php
blobfd6feefce7f93879055c63468bb14ba76ab1facf
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) 1999 onwards Martin Dougiamas http://moodle.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 ///////////////////////////////////////////////////////////////////////////
26 require_once '../../../config.php';
27 require_once $CFG->dirroot.'/grade/lib.php';
28 require_once $CFG->libdir.'/gradelib.php';
29 require_once 'form.php';
31 $courseid = optional_param('id', SITEID, PARAM_INT);
33 if (!$course = get_record('course', 'id', $courseid)) {
34 print_error('nocourseid');
36 require_login($course);
37 $context = get_context_instance(CONTEXT_COURSE, $course->id);
39 require_capability('moodle/grade:manage', $context);
41 $gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'settings', 'courseid'=>$courseid));
43 $strgrades = get_string('grades');
44 $pagename = get_string('coursesettings', 'grades');
46 $navigation = grade_build_nav(__FILE__, $pagename, $courseid);
48 $returnurl = $CFG->wwwroot.'/grade/index.php?id='.$course->id;
50 $mform = new course_settings_form();
52 $settings = grade_get_settings($course->id);
54 $mform->set_data($settings);
56 if ($mform->is_cancelled()) {
57 redirect($returnurl);
59 } else if ($data = $mform->get_data()) {
60 $data = (array)$data;
61 $general = array('displaytype', 'decimalpoints', 'aggregationposition');
62 foreach ($data as $key=>$value) {
63 if (!in_array($key, $general) and strpos($key, 'report_') !== 0
64 and strpos($key, 'import_') !== 0
65 and strpos($key, 'export_') !== 0) {
66 continue;
68 if ($value == -1) {
69 $value = null;
71 grade_set_setting($course->id, $key, $value);
74 redirect($returnurl);
77 /// Print header
78 print_header_simple($strgrades.': '.$pagename, ': '.$strgrades, $navigation, '', '', true, '', navmenu($course));
79 /// Print the plugin selector at the top
80 print_grade_plugin_selector($courseid, 'edit', 'settings');
82 $mform->display();
84 print_footer($course);