Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / form / modgrade.php
blob70d2c4bcf6fcd13d8080537d2f60c0a2f0c4217c
1 <?php
2 global $CFG;
3 require_once "$CFG->libdir/form/select.php";
5 /**
6 * HTML class for a drop down element to select the grade for an activity,
7 * used in mod update form
9 * @author Jamie Pratt
10 * @access public
12 class MoodleQuickForm_modgrade extends MoodleQuickForm_select{
15 var $_includenograde=true;
16 /**
17 * Class constructor
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
23 * @access public
24 * @return void
26 function MoodleQuickForm_modgrade($elementName=null, $elementLabel=null, $attributes=null, $includenograde=true)
28 HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
29 $this->_type = 'modgrade';
30 $this->_includenograde=$includenograde;
32 } //end constructor
34 /**
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
40 * @since 1.0
41 * @access public
42 * @return mixed
44 function onQuickFormEvent($event, $arg, &$caller)
46 global $COURSE, $CFG;
47 switch ($event) {
48 case 'createElement':
49 $strscale = get_string('scale');
50 $strscales = get_string('scales');
51 $scales = get_scales_menu($COURSE->id);
52 foreach ($scales as $i => $scalename) {
53 $grades[-$i] = $strscale .': '. $scalename;
55 if ($this->_includenograde) {
56 $grades[0] = get_string('nograde');
58 for ($i=100; $i>=1; $i--) {
59 $grades[$i] = $i;
61 $this->load($grades);
62 $linkobject = '<span class="helplink"><img height="17" width="17" alt="'.$strscales.'" src="'.$CFG->pixpath .'/help.gif" /></span>';
63 $this->setHelpButton(array('/course/scales.php?id='. $COURSE->id .'&amp;list=true', 'ratingscales',
64 $linkobject, 400, 500, $strscales, 'none', true), 'link_to_popup_window');
65 break;
67 return parent::onQuickFormEvent($event, $arg, $caller);