]> git.mjollnir.org Git - moodle.git/commitdiff
reverting back to version 1.2. Accidentally committed version 1.3 in HEAD.
authorjamiesensei <jamiesensei>
Wed, 23 May 2007 00:59:36 +0000 (00:59 +0000)
committerjamiesensei <jamiesensei>
Wed, 23 May 2007 00:59:36 +0000 (00:59 +0000)
lib/form/questioncategory.php

index 42b58f5f2dceaf9906ff4008c0070ebe73e04937..04a90596dd14d9f55baeaf88fe2caee335904f64 100644 (file)
@@ -9,15 +9,13 @@
  *//** */
 
 global $CFG;
-require_once("$CFG->libdir/form/selectgroups.php");
-require_once("$CFG->libdir/questionlib.php");
+require_once("$CFG->libdir/form/select.php");
 
 /**
  * HTML class for a drop down element to select a question category.
  * @access public
  */
-class MoodleQuickForm_questioncategory extends MoodleQuickForm_selectgroups {
-    var $_options = array('top'=>false, 'currentcat'=>0);
+class MoodleQuickForm_questioncategory extends MoodleQuickForm_select {
 
     /**
      * Constructor
@@ -30,15 +28,45 @@ class MoodleQuickForm_questioncategory extends MoodleQuickForm_selectgroups {
      * @access public
      * @return void
      */
-    function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $options = null, $attributes = null) {
-        MoodleQuickForm_selectgroups::MoodleQuickForm_selectgroups($elementName, $elementLabel, array(), $attributes);
+    function MoodleQuickForm_questioncategory($elementName = null,
+            $elementLabel = null, $attributes = null, $options = null) {
+        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null);
+
+        global $COURSE;
         $this->_type = 'questioncategory';
-        if (is_array($options)) {
-            $this->_options = $options + $this->_options;
-            $this->loadArrayOptGroups(
-                        question_category_options($this->_options['contexts'], $this->_options['top'], $this->_options['currentcat']));
+        if (!empty($options['courseid'])) {
+            $this->_courseid = $options['courseid'];
+        } else {
+            $this->_courseid = $COURSE->id;
+        }
+        if (!empty($options['published'])) {
+            $this->_published = $options['published'];
+        } else {
+            $this->_published = false;
+        }
+        if (!empty($options['only_editable'])) {
+            $this->_only_editable = $options['only_editable'];
+        } else {
+            $this->_only_editable = false;
         }
     }
 
+    /**
+     * Called by HTML_QuickForm whenever form event is made on this element
+     *
+     * @param string $event Name of event
+     * @param mixed $arg event arguments
+     * @param object $caller calling object
+     * @access public
+     * @return mixed
+     */
+    function onQuickFormEvent($event, $arg, &$caller) {
+        switch ($event) {
+            case 'createElement':
+                $this->load(question_category_options($this->_courseid, $this->_published, $this->_only_editable));
+            break;
+        }
+        return parent::onQuickFormEvent($event, $arg, $caller);
+    }
 }
 ?>
\ No newline at end of file