|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00018 if (!defined('MOODLE_INTERNAL')) { 00019 die('Direct access to this script is forbidden.'); 00020 } 00021 00022 require_once $CFG->libdir.'/formslib.php'; 00023 00024 class edit_letter_form extends moodleform { 00025 00026 public function definition() { 00027 $mform =& $this->_form; 00028 $num = $this->_customdata['num']; 00029 $admin = $this->_customdata['admin']; 00030 00031 $mform->addElement('header', 'gradeletters', get_string('gradeletters', 'grades')); 00032 00033 // Only show "override site defaults" checkbox if editing the course grade letters 00034 if (!$admin) { 00035 $mform->addElement('checkbox', 'override', get_string('overridesitedefaultgradedisplaytype', 'grades')); 00036 $mform->addHelpButton('override', 'overridesitedefaultgradedisplaytype', 'grades'); 00037 } 00038 00039 $gradeletter = get_string('gradeletter', 'grades'); 00040 $gradeboundary = get_string('gradeboundary', 'grades'); 00041 00042 $percentages = array(-1 => get_string('unused', 'grades')); 00043 for ($i=100; $i > -1; $i--) { 00044 $percentages[$i] = "$i %"; 00045 } 00046 00047 for($i=1; $i<$num+1; $i++) { 00048 $gradelettername = 'gradeletter'.$i; 00049 $gradeboundaryname = 'gradeboundary'.$i; 00050 00051 $mform->addElement('text', $gradelettername, $gradeletter." $i"); 00052 if ($i == 1) { 00053 $mform->addHelpButton($gradelettername, 'gradeletter', 'grades'); 00054 } 00055 $mform->setType($gradelettername, PARAM_TEXT); 00056 00057 if (!$admin) { 00058 $mform->disabledIf($gradelettername, 'override', 'notchecked'); 00059 $mform->disabledIf($gradelettername, $gradeboundaryname, 'eq', -1); 00060 } 00061 00062 $mform->addElement('select', $gradeboundaryname, $gradeboundary." $i", $percentages); 00063 if ($i == 1) { 00064 $mform->addHelpButton($gradeboundaryname, 'gradeboundary', 'grades'); 00065 } 00066 $mform->setDefault($gradeboundaryname, -1); 00067 $mform->setType($gradeboundaryname, PARAM_INT); 00068 00069 if (!$admin) { 00070 $mform->disabledIf($gradeboundaryname, 'override', 'notchecked'); 00071 } 00072 } 00073 00074 // hidden params 00075 $mform->addElement('hidden', 'id'); 00076 $mform->setType('id', PARAM_INT); 00077 00078 //------------------------------------------------------------------------------- 00079 // buttons 00080 $this->add_action_buttons(!$admin); 00081 } 00082 00083 } 00084 00085