MDL-11495 grade letter setting improvements:
[moodle.git] / grade / edit / letter / edit_form.php
CommitLineData
284abb09 1<?php //$Id$
2
3require_once $CFG->libdir.'/formslib.php';
4
5class edit_letter_form extends moodleform {
6
7 function definition() {
8 $mform =& $this->_form;
9 $num = $this->_customdata['num'];
10 $admin = $this->_customdata['admin'];
11
12 $mform->addElement('header', 'gradeletters', get_string('gradeletters', 'grades'));
13
14 $mform->addElement('checkbox', 'override', get_string('overridesitedefaultgradedisplaytype', 'grades'));
15 $mform->setHelpButton('override', array(false, get_string('overridesitedefaultgradedisplaytype', 'grades'),
16 false, true, false, get_string('overridesitedefaultgradedisplaytypehelp', 'grades')));
17
18 $gradeletterhelp = get_string('configgradeletter', 'grades');
19 $gradeboundaryhelp = get_string('configgradeboundary', 'grades');
20 $gradeletter = get_string('gradeletter', 'grades');
21 $gradeboundary = get_string('gradeboundary', 'grades');
22
23 $percentages = array(-1 => get_string('unused', 'grades'));
24 for ($i=100; $i > -1; $i--) {
25 $percentages[$i] = "$i %";
26 }
27
28 for($i=1; $i<$num+1; $i++) {
29 $gradelettername = 'gradeletter'.$i;
30 $gradeboundaryname = 'gradeboundary'.$i;
31
32 $mform->addElement('text', $gradelettername, $gradeletter." $i");
33 $mform->setHelpButton($gradelettername, array(false, $gradeletter." $i", false, true, false, $gradeletterhelp));
34 $mform->setType($gradelettername, PARAM_TEXT);
35 $mform->disabledIf($gradelettername, 'override', 'notchecked');
36 $mform->disabledIf($gradelettername, $gradeboundaryname, 'eq', -1);
37
38 $mform->addElement('select', $gradeboundaryname, $gradeboundary." $i", $percentages);
39 $mform->setHelpButton($gradeboundaryname, array(false, $gradeboundary." $i", false, true, false, $gradeboundaryhelp));
40 $mform->setDefault($gradeboundaryname, -1);
41 $mform->setType($gradeboundaryname, PARAM_INT);
42 $mform->disabledIf($gradeboundaryname, 'override', 'notchecked');
43 }
44
45 // hidden params
46 $mform->addElement('hidden', 'id');
47 $mform->setType('id', PARAM_INT);
48
49//-------------------------------------------------------------------------------
50 // buttons
51 $this->add_action_buttons(!$admin);
52 }
53
54}
55
56?>