]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19805 Migrated choose_from_menu to the new $OUTPUT->select_menu() function
authornicolasconnault <nicolasconnault>
Tue, 28 Jul 2009 09:33:34 +0000 (09:33 +0000)
committernicolasconnault <nicolasconnault>
Tue, 28 Jul 2009 09:33:34 +0000 (09:33 +0000)
mod/choice/choice.js [new file with mode: 0644]
mod/choice/lib.php

diff --git a/mod/choice/choice.js b/mod/choice/choice.js
new file mode 100644 (file)
index 0000000..19897bd
--- /dev/null
@@ -0,0 +1,5 @@
+function submit_attempts_form(e, args) {
+    if (e.target.selectedIndex > 0) {
+        submit_form_by_id(null, {id: 'attemptsform'});
+    }
+}
index e1de214bb9b6b89ae3e840f172022cc24d2f2cce..b832cffd2ac28bcc1aabe97179de05ecfa8e9eff 100644 (file)
@@ -411,7 +411,7 @@ function choice_show_reportlink($user, $cm) {
  * @return void Output is echo'd
  */
 function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish='') {
-    global $CFG, $CHOICE_COLUMN_HEIGHT, $FULLSCRIPT, $PAGE;
+    global $CFG, $CHOICE_COLUMN_HEIGHT, $FULLSCRIPT, $PAGE, $OUTPUT, $DB;
 
     print_heading(get_string("responses", "choice"));
     if (empty($forcepublish)) { //alow the publish setting to be overridden
@@ -544,8 +544,14 @@ function choice_show_results($choice, $course, $cm, $allresponses, $forcepublish
                 echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectall', 'quiz').'</a> / ';
                 echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('selectnone', 'quiz').'</a> ';
                 echo '&nbsp;&nbsp;';
-                $options = array('delete' => get_string('delete'));
-                echo choose_from_menu($options, 'action', '', get_string('withselected', 'quiz'), 'if(this.selectedIndex > 0) submitFormById(\'attemptsform\');', '', true);
+                $PAGE->requires->js('mod/choice/choice.js');
+                $selectmenu = new moodle_select_menu();
+                $selectmenu->options = array('delete' => get_string('delete'));
+                $selectmenu->name = 'action';
+                $selectmenu->button->label = get_string('withselected', 'quiz');
+                $selectmenu->id = 'menuaction';
+                $selectmenu->add_action('change', 'submit_attempts_form');
+                echo $OUTPUT->select_menu($selectmenu);
                 echo '<noscript id="noscriptmenuaction" style="display: inline;">';
                 echo '<div>';
                 echo '<input type="submit" value="'.get_string('go').'" /></div></noscript>';