From a4bfd8e1de822fd8d191e503981ca2ebd301deb9 Mon Sep 17 00:00:00 2001 From: sam_marshall Date: Mon, 8 Jun 2009 12:42:24 +0000 Subject: [PATCH] MDL-19428: mform - Fixed the 'includenograde' option in modgrade type --- lib/form/modgrade.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/form/modgrade.php b/lib/form/modgrade.php index 70d2c4bcf6..fbf1789215 100644 --- a/lib/form/modgrade.php +++ b/lib/form/modgrade.php @@ -11,8 +11,8 @@ require_once "$CFG->libdir/form/select.php"; */ class MoodleQuickForm_modgrade extends MoodleQuickForm_select{ - - var $_includenograde=true; + var $_hidenograde = false; + /** * Class constructor * @@ -23,11 +23,11 @@ class MoodleQuickForm_modgrade extends MoodleQuickForm_select{ * @access public * @return void */ - function MoodleQuickForm_modgrade($elementName=null, $elementLabel=null, $attributes=null, $includenograde=true) + function MoodleQuickForm_modgrade($elementName=null, $elementLabel=null, $attributes=null, $hidenograde=false) { HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null); $this->_type = 'modgrade'; - $this->_includenograde=$includenograde; + $this->_hidenograde = $hidenograde; } //end constructor @@ -46,13 +46,16 @@ class MoodleQuickForm_modgrade extends MoodleQuickForm_select{ global $COURSE, $CFG; switch ($event) { case 'createElement': + // Need to call superclass first because we want the constructor + // to run. + $result = parent::onQuickFormEvent($event, $arg, $caller); $strscale = get_string('scale'); $strscales = get_string('scales'); $scales = get_scales_menu($COURSE->id); foreach ($scales as $i => $scalename) { $grades[-$i] = $strscale .': '. $scalename; } - if ($this->_includenograde) { + if (!$this->_hidenograde) { $grades[0] = get_string('nograde'); } for ($i=100; $i>=1; $i--) { @@ -62,7 +65,7 @@ class MoodleQuickForm_modgrade extends MoodleQuickForm_select{ $linkobject = ''.$strscales.''; $this->setHelpButton(array('/course/scales.php?id='. $COURSE->id .'&list=true', 'ratingscales', $linkobject, 400, 500, $strscales, 'none', true), 'link_to_popup_window'); - break; + return $result; } return parent::onQuickFormEvent($event, $arg, $caller); } -- 2.39.5