3 require_once "$CFG->libdir/form/select.php";
6 * HTML class for a drop down element to select the grade for an activity,
7 * used in mod update form
12 class MoodleQuickForm_modgrade
extends MoodleQuickForm_select
{
14 var $_hidenograde = false;
19 * @param string Select name attribute
20 * @param mixed Label(s) for the select
21 * @param mixed Either a typical HTML attribute string or an associative array
22 * @param mixed $options ignored
26 function MoodleQuickForm_modgrade($elementName=null, $elementLabel=null, $attributes=null, $hidenograde=false)
28 HTML_QuickForm_element
::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
29 $this->_type
= 'modgrade';
30 $this->_hidenograde
= $hidenograde;
35 * Called by HTML_QuickForm whenever form event is made on this element
37 * @param string $event Name of event
38 * @param mixed $arg event arguments
39 * @param object $caller calling object
44 function onQuickFormEvent($event, $arg, &$caller)
46 global $COURSE, $CFG, $OUTPUT;
49 // Need to call superclass first because we want the constructor
51 $result = parent
::onQuickFormEvent($event, $arg, $caller);
52 $strscale = get_string('scale');
53 $strscales = get_string('scales');
54 $scales = get_scales_menu($COURSE->id
);
55 foreach ($scales as $i => $scalename) {
56 $grades[-$i] = $strscale .': '. $scalename;
58 if (!$this->_hidenograde
) {
59 $grades[0] = get_string('nograde');
61 for ($i=100; $i>=1; $i--) {
65 //TODO: rewrite mod grading support in modforms
68 return parent
::onQuickFormEvent($event, $arg, $caller);