From: nicolasconnault Date: Tue, 28 Jul 2009 09:33:34 +0000 (+0000) Subject: MDL-19805 Migrated choose_from_menu to the new $OUTPUT->select_menu() function X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=db8935ef42629dae74a2d7202ae9a38fd0e1d17a;p=moodle.git MDL-19805 Migrated choose_from_menu to the new $OUTPUT->select_menu() function --- diff --git a/mod/choice/choice.js b/mod/choice/choice.js new file mode 100644 index 0000000000..19897bd5d2 --- /dev/null +++ b/mod/choice/choice.js @@ -0,0 +1,5 @@ +function submit_attempts_form(e, args) { + if (e.target.selectedIndex > 0) { + submit_form_by_id(null, {id: 'attemptsform'}); + } +} diff --git a/mod/choice/lib.php b/mod/choice/lib.php index e1de214bb9..b832cffd2a 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -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 ''.get_string('selectall', 'quiz').' / '; echo ''.get_string('selectnone', 'quiz').' '; echo '  '; - $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 '';