|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 global $CFG; 00003 require_once "$CFG->libdir/form/select.php"; 00004 00012 class MoodleQuickForm_modgrade extends MoodleQuickForm_select{ 00013 00014 var $_hidenograde = false; 00015 00026 function MoodleQuickForm_modgrade($elementName=null, $elementLabel=null, $attributes=null, $hidenograde=false) 00027 { 00028 HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null); 00029 $this->_type = 'modgrade'; 00030 $this->_hidenograde = $hidenograde; 00031 00032 } //end constructor 00033 00044 function onQuickFormEvent($event, $arg, &$caller) 00045 { 00046 global $COURSE, $CFG, $OUTPUT; 00047 switch ($event) { 00048 case 'createElement': 00049 // Need to call superclass first because we want the constructor 00050 // to run. 00051 $result = parent::onQuickFormEvent($event, $arg, $caller); 00052 $strscale = get_string('scale'); 00053 $strscales = get_string('scales'); 00054 $scales = get_scales_menu($COURSE->id); 00055 foreach ($scales as $i => $scalename) { 00056 $grades[-$i] = $strscale .': '. $scalename; 00057 } 00058 if (!$this->_hidenograde) { 00059 $grades[0] = get_string('nograde'); 00060 } 00061 for ($i=100; $i>=1; $i--) { 00062 $grades[$i] = $i; 00063 } 00064 $this->load($grades); 00065 //TODO: rewrite mod grading support in modforms 00066 return $result; 00067 } 00068 return parent::onQuickFormEvent($event, $arg, $caller); 00069 } 00070 00071 }