MDL-19404 Getting default values for grade_item object when creating a new grade_cate...
[moodle.git] / grade / edit / letter / edit_form.php
CommitLineData
284abb09 1<?php //$Id$
2
8ad36f4c 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///////////////////////////////////////////////////////////////////////////
25
284abb09 26require_once $CFG->libdir.'/formslib.php';
27
28class edit_letter_form extends moodleform {
29
d24832f9 30 public function definition() {
284abb09 31 $mform =& $this->_form;
32 $num = $this->_customdata['num'];
33 $admin = $this->_customdata['admin'];
34
35 $mform->addElement('header', 'gradeletters', get_string('gradeletters', 'grades'));
d24832f9 36
395a53ae 37 // Only show "override site defaults" checkbox if editing the course grade letters
38 if (!$admin) {
39 $mform->addElement('checkbox', 'override', get_string('overridesitedefaultgradedisplaytype', 'grades'));
fe6caf18 40 $mform->setHelpButton('override', array('overridesitedefaultgradedisplaytype', get_string('overridesitedefaultgradedisplaytype', 'grades'), 'grade'));
395a53ae 41 }
284abb09 42
43 $gradeletterhelp = get_string('configgradeletter', 'grades');
44 $gradeboundaryhelp = get_string('configgradeboundary', 'grades');
45 $gradeletter = get_string('gradeletter', 'grades');
46 $gradeboundary = get_string('gradeboundary', 'grades');
47
48 $percentages = array(-1 => get_string('unused', 'grades'));
49 for ($i=100; $i > -1; $i--) {
50 $percentages[$i] = "$i %";
51 }
52
53 for($i=1; $i<$num+1; $i++) {
54 $gradelettername = 'gradeletter'.$i;
55 $gradeboundaryname = 'gradeboundary'.$i;
56
57 $mform->addElement('text', $gradelettername, $gradeletter." $i");
395a53ae 58 if ($i == 1) {
fe6caf18 59 $mform->setHelpButton($gradelettername, array('gradeletter', get_string('gradeletter', 'grades'), 'grade'));
395a53ae 60 }
284abb09 61 $mform->setType($gradelettername, PARAM_TEXT);
d24832f9 62
395a53ae 63 if (!$admin) {
64 $mform->disabledIf($gradelettername, 'override', 'notchecked');
65 $mform->disabledIf($gradelettername, $gradeboundaryname, 'eq', -1);
66 }
284abb09 67
68 $mform->addElement('select', $gradeboundaryname, $gradeboundary." $i", $percentages);
395a53ae 69 if ($i == 1) {
fe6caf18 70 $mform->setHelpButton($gradeboundaryname, array('gradeboundary', get_string('gradeboundary', 'grades'), 'grade'));
395a53ae 71 }
284abb09 72 $mform->setDefault($gradeboundaryname, -1);
73 $mform->setType($gradeboundaryname, PARAM_INT);
d24832f9 74
395a53ae 75 if (!$admin) {
76 $mform->disabledIf($gradeboundaryname, 'override', 'notchecked');
77 }
284abb09 78 }
79
80 // hidden params
81 $mform->addElement('hidden', 'id');
82 $mform->setType('id', PARAM_INT);
83
84//-------------------------------------------------------------------------------
85 // buttons
86 $this->add_action_buttons(!$admin);
87 }
88
89}
90
91?>