3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 if (!defined('MOODLE_INTERNAL')) {
19 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
22 require_once $CFG->libdir.'/formslib.php';
24 class edit_letter_form extends moodleform {
26 public function definition() {
27 $mform =& $this->_form;
28 $num = $this->_customdata['num'];
29 $admin = $this->_customdata['admin'];
31 $mform->addElement('header', 'gradeletters', get_string('gradeletters', 'grades'));
33 // Only show "override site defaults" checkbox if editing the course grade letters
35 $mform->addElement('checkbox', 'override', get_string('overridesitedefaultgradedisplaytype', 'grades'));
36 $mform->addHelpButton('override', 'overridesitedefaultgradedisplaytype', 'grades');
39 $gradeletter = get_string('gradeletter', 'grades');
40 $gradeboundary = get_string('gradeboundary', 'grades');
42 $percentages = array(-1 => get_string('unused', 'grades'));
43 for ($i=100; $i > -1; $i--) {
44 $percentages[$i] = "$i %";
47 for($i=1; $i<$num+1; $i++) {
48 $gradelettername = 'gradeletter'.$i;
49 $gradeboundaryname = 'gradeboundary'.$i;
51 $mform->addElement('text', $gradelettername, $gradeletter." $i");
53 $mform->addHelpButton($gradelettername, 'gradeletter', 'grades');
55 $mform->setType($gradelettername, PARAM_TEXT);
58 $mform->disabledIf($gradelettername, 'override', 'notchecked');
59 $mform->disabledIf($gradelettername, $gradeboundaryname, 'eq', -1);
62 $mform->addElement('select', $gradeboundaryname, $gradeboundary." $i", $percentages);
64 $mform->addHelpButton($gradeboundaryname, 'gradeboundary', 'grades');
66 $mform->setDefault($gradeboundaryname, -1);
67 $mform->setType($gradeboundaryname, PARAM_INT);
70 $mform->disabledIf($gradeboundaryname, 'override', 'notchecked');
75 $mform->addElement('hidden', 'id');
76 $mform->setType('id', PARAM_INT);
78 //-------------------------------------------------------------------------------
80 $this->add_action_buttons(!$admin);