Updated the HEAD build version to 20100513
[moodle.git] / grade / edit / letter / edit_form.php
CommitLineData
e060e33d 1<?php
284abb09 2
e060e33d 3// This file is part of Moodle - http://moodle.org/
4//
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.
9//
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.
14//
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/>.
8ad36f4c 17
284abb09 18require_once $CFG->libdir.'/formslib.php';
19
20class edit_letter_form extends moodleform {
21
d24832f9 22 public function definition() {
284abb09 23 $mform =& $this->_form;
24 $num = $this->_customdata['num'];
25 $admin = $this->_customdata['admin'];
26
27 $mform->addElement('header', 'gradeletters', get_string('gradeletters', 'grades'));
d24832f9 28
395a53ae 29 // Only show "override site defaults" checkbox if editing the course grade letters
30 if (!$admin) {
31 $mform->addElement('checkbox', 'override', get_string('overridesitedefaultgradedisplaytype', 'grades'));
fe6caf18 32 $mform->setHelpButton('override', array('overridesitedefaultgradedisplaytype', get_string('overridesitedefaultgradedisplaytype', 'grades'), 'grade'));
395a53ae 33 }
284abb09 34
35 $gradeletterhelp = get_string('configgradeletter', 'grades');
36 $gradeboundaryhelp = get_string('configgradeboundary', 'grades');
37 $gradeletter = get_string('gradeletter', 'grades');
38 $gradeboundary = get_string('gradeboundary', 'grades');
39
40 $percentages = array(-1 => get_string('unused', 'grades'));
41 for ($i=100; $i > -1; $i--) {
42 $percentages[$i] = "$i %";
43 }
44
45 for($i=1; $i<$num+1; $i++) {
46 $gradelettername = 'gradeletter'.$i;
47 $gradeboundaryname = 'gradeboundary'.$i;
48
49 $mform->addElement('text', $gradelettername, $gradeletter." $i");
395a53ae 50 if ($i == 1) {
fe6caf18 51 $mform->setHelpButton($gradelettername, array('gradeletter', get_string('gradeletter', 'grades'), 'grade'));
395a53ae 52 }
284abb09 53 $mform->setType($gradelettername, PARAM_TEXT);
d24832f9 54
395a53ae 55 if (!$admin) {
56 $mform->disabledIf($gradelettername, 'override', 'notchecked');
57 $mform->disabledIf($gradelettername, $gradeboundaryname, 'eq', -1);
58 }
284abb09 59
60 $mform->addElement('select', $gradeboundaryname, $gradeboundary." $i", $percentages);
395a53ae 61 if ($i == 1) {
fe6caf18 62 $mform->setHelpButton($gradeboundaryname, array('gradeboundary', get_string('gradeboundary', 'grades'), 'grade'));
395a53ae 63 }
284abb09 64 $mform->setDefault($gradeboundaryname, -1);
65 $mform->setType($gradeboundaryname, PARAM_INT);
d24832f9 66
395a53ae 67 if (!$admin) {
68 $mform->disabledIf($gradeboundaryname, 'override', 'notchecked');
69 }
284abb09 70 }
71
72 // hidden params
73 $mform->addElement('hidden', 'id');
74 $mform->setType('id', PARAM_INT);
75
76//-------------------------------------------------------------------------------
77 // buttons
78 $this->add_action_buttons(!$admin);
79 }
80
81}
82
6c3ef410 83