3 ///////////////////////////////////////////////////////////////////////////
5 // NOTICE OF COPYRIGHT //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
10 // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
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. //
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: //
22 // http://www.gnu.org/copyleft/gpl.html //
24 ///////////////////////////////////////////////////////////////////////////
26 require_once $CFG->libdir
.'/formslib.php';
28 class edit_letter_form
extends moodleform
{
30 function definition() {
31 $mform =& $this->_form
;
32 $num = $this->_customdata
['num'];
33 $admin = $this->_customdata
['admin'];
35 $mform->addElement('header', 'gradeletters', get_string('gradeletters', 'grades'));
37 // Only show "override site defaults" checkbox if editing the course grade letters
39 $mform->addElement('checkbox', 'override', get_string('overridesitedefaultgradedisplaytype', 'grades'));
40 $mform->setHelpButton('override', array('overridesitedefaultgradedisplaytype', get_string('overridesitedefaultgradedisplaytype', 'grades'), 'grade'));
43 $gradeletterhelp = get_string('configgradeletter', 'grades');
44 $gradeboundaryhelp = get_string('configgradeboundary', 'grades');
45 $gradeletter = get_string('gradeletter', 'grades');
46 $gradeboundary = get_string('gradeboundary', 'grades');
48 $percentages = array(-1 => get_string('unused', 'grades'));
49 for ($i=100; $i > -1; $i--) {
50 $percentages[$i] = "$i %";
53 for($i=1; $i<$num+
1; $i++
) {
54 $gradelettername = 'gradeletter'.$i;
55 $gradeboundaryname = 'gradeboundary'.$i;
57 $mform->addElement('text', $gradelettername, $gradeletter." $i");
59 $mform->setHelpButton($gradelettername, array('gradeletter', get_string('gradeletter', 'grades'), 'grade'));
61 $mform->setType($gradelettername, PARAM_TEXT
);
64 $mform->disabledIf($gradelettername, 'override', 'notchecked');
65 $mform->disabledIf($gradelettername, $gradeboundaryname, 'eq', -1);
68 $mform->addElement('select', $gradeboundaryname, $gradeboundary." $i", $percentages);
70 $mform->setHelpButton($gradeboundaryname, array('gradeboundary', get_string('gradeboundary', 'grades'), 'grade'));
72 $mform->setDefault($gradeboundaryname, -1);
73 $mform->setType($gradeboundaryname, PARAM_INT
);
76 $mform->disabledIf($gradeboundaryname, 'override', 'notchecked');
81 $mform->addElement('hidden', 'id');
82 $mform->setType('id', PARAM_INT
);
84 //-------------------------------------------------------------------------------
86 $this->add_action_buttons(!$admin);