27e892ad7f3f6989d864b06f0a82c7341fa6e5a3
[moodle.git] / grade / edit / settings / form.php
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($CFG->libdir.'/formslib.php');
28 /**
29  * First implementation of the preferences in the form of a moodleform.
30  * TODO add "reset to site defaults" button
31  */
32 class course_settings_form extends moodleform {
34     function definition() {
35         global $USER, $CFG;
37         $mform =& $this->_form;
39         $mform->addElement('header', 'general', get_string('settings', 'grades'));
41         $options = array(-1                            => get_string('default', 'grades'),
42                          GRADE_DISPLAY_TYPE_REAL       => get_string('real', 'grades'),
43                          GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
44                          GRADE_DISPLAY_TYPE_LETTER     => get_string('letter', 'grades'));
45         $default_gradedisplaytype = $CFG->grade_displaytype;
46         foreach ($options as $key=>$option) {
47             if ($key == $default_gradedisplaytype) {
48                 $options[-1] = get_string('defaultprev', 'grades', $option);
49                 break;
50             }
51         }
52         $mform->addElement('select', 'displaytype', get_string('gradedisplaytype', 'grades'), $options);
53         $mform->setHelpButton('displaytype', array(false, get_string('gradedisplaytype', 'grades'),
54                               false, true, false, get_string('configgradedisplaytype', 'grades')));
57         $options = array(-1=> get_string('defaultprev', 'grades', $CFG->grade_decimalpoints), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
58         $mform->addElement('select', 'decimalpoints', get_string('decimalpoints', 'grades'), $options);
59         $mform->setHelpButton('decimalpoints', array(false, get_string('decimalpoints', 'grades'),
60                               false, true, false, get_string('configdecimalpoints', 'grades')));
63         $mform->addElement('hidden', 'id');
64         $mform->setType('id', PARAM_INT);
67         $options = array(-1                                      => get_string('default', 'grades'),
68                          GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
69                          GRADE_REPORT_AGGREGATION_POSITION_LAST  => get_string('positionlast', 'grades'));
70         $default_gradedisplaytype = $CFG->grade_aggregationposition;
71         foreach ($options as $key=>$option) {
72             if ($key == $default_gradedisplaytype) {
73                 $options[-1] = get_string('defaultprev', 'grades', $option);
74                 break;
75             }
76         }
77         $mform->addElement('select', 'aggregationposition', get_string('aggregationposition', 'grades'), $options);
78         $mform->setHelpButton('aggregationposition', array(false, get_string('aggregationposition', 'grades'),
79                               false, true, false, get_string('configaggregationposition', 'grades')));
82         $this->add_action_buttons();
83     }
84 }
85 ?>