MDL-20204 more single_selects converted
authorPetr Skoda <skodak@moodle.org>
Wed, 10 Feb 2010 11:51:49 +0000 (11:51 +0000)
committerPetr Skoda <skodak@moodle.org>
Wed, 10 Feb 2010 11:51:49 +0000 (11:51 +0000)
lib/questionlib.php
question/editlib.php

index 21ed4f6..82c14c0 100644 (file)
@@ -2514,9 +2514,12 @@ function question_category_options($contexts, $top = false, $currentcat = 0, $po
     if ($popupform){
         $popupcats = array();
         foreach ($categoriesarray as $contextstring => $optgroup){
-            $popupcats[] = '--'.$contextstring;
-            $popupcats = array_merge($popupcats, $optgroup);
-            $popupcats[] = '--';
+            $group = array();
+            foreach ($optgroup as $key=>$value) {
+                $key = str_replace($CFG->wwwroot, '', $key); 
+                $group[$key] = $value;                
+            }
+            $popupcats[] = array($contextstring=>$group);
         }
         return $popupcats;
     } else {
index c711a9e..dae6616 100644 (file)
@@ -1175,17 +1175,12 @@ class question_bank_view {
         $catmenu = question_category_options($contexts, false, 0, true);
 
         $editurl = new moodle_url('/question/edit.php', $pageurl->params());
-        $select = html_select::make_popup_form($editurl, 'category', $catmenu, 'catmenu', $current);
+        $select = new single_select($editurl, 'category', $catmenu, $current, null, 'catmenu');
         // The js func submit_form_by_id ignores the first element by default when using
         // the html_select component so we need to unset the selectid param to make it
         // work in the way we want for this control
-        $actions = $select->get_actions();
-        unset($actions[0]->jsfunctionargs['selectid']);
-        $select->actions = $actions;
-
-        $select->nothinglabel = false;
         $select->set_label(get_string('selectacategory', 'question'));
-        echo $OUTPUT->select($select);
+        echo $OUTPUT->render($select);
         echo "</div>\n";
     }