MDL-46163 quiz/questions: fix missing hidden fields.
authorTim Hunt <T.J.Hunt@open.ac.uk>
Wed, 2 Jul 2014 13:26:59 +0000 (14:26 +0100)
committerDan Poltawski <dan@moodle.com>
Wed, 2 Jul 2014 13:32:53 +0000 (14:32 +0100)
I have done this by eliminating the duplication between the base class
and the subclass.

This was a regression introdcued by MDL-40313.

mod/quiz/editlib.php
question/classes/bank/view.php

index e98e594..0ee5f56 100644 (file)
@@ -1230,25 +1230,10 @@ class quiz_question_bank_view extends core_question\bank\view {
         echo $OUTPUT->box_end();
     }
 
-    /**
-     * Display the form with options for which questions are displayed and how they are displayed.
-     * This differs from parent display_options_form only in that it does not have the checkbox to show the question text.
-     * @param bool $showquestiontext Display the text of the question within the list. (Currently ignored)
-     */
-    protected function display_options_form($showquestiontext) {
-        global $PAGE;
-        echo html_writer::start_tag('form', array('method' => 'get',
-                'action' => new moodle_url('/mod/quiz/edit.php'), 'id' => 'displayoptions'));
-        echo html_writer::start_div();
-        foreach ($this->searchconditions as $searchcondition) {
-            echo $searchcondition->display_options($this);
-        }
-        $this->display_advanced_search_form();
-        $go = html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('go')));
-        echo html_writer::tag('noscript', html_writer::tag('div', $go), array('class' => 'inline'));
-        echo html_writer::end_div();
-        echo html_writer::end_tag('form');
-        $PAGE->requires->yui_module('moodle-question-searchform', 'M.question.searchform.init');
+    protected function display_options_form($showquestiontext, $scriptpath = '/mod/quiz/edit.php',
+            $showtextoption = false) {
+        // Overridden just to change the default values of the arguments.
+        parent::display_options_form($showquestiontext, $scriptpath, $showtextoption);
     }
 
     protected function print_category_info($category) {
index 022be82..d4018ac 100644 (file)
@@ -582,22 +582,30 @@ class view {
     /**
      * Display the form with options for which questions are displayed and how they are displayed.
      * @param bool $showquestiontext Display the text of the question within the list.
+     * @param string $path path to the script displaying this page.
+     * @param bool $showtextoption whether to include the 'Show question text' checkbox.
      */
-    protected function display_options_form($showquestiontext) {
+    protected function display_options_form($showquestiontext, $scriptpath = '/question/edit.php',
+            $showtextoption = true) {
         global $PAGE;
 
-        echo '<form method="get" action="edit.php" id="displayoptions">';
-        echo "<fieldset class='invisiblefieldset'>";
+        echo \html_writer::start_tag('form', array('method' => 'get',
+                'action' => new \moodle_url($scriptpath), 'id' => 'displayoptions'));
+        echo \html_writer::start_div();
         echo \html_writer::input_hidden_params($this->baseurl, array('recurse', 'showhidden', 'qbshowtext'));
 
         foreach ($this->searchconditions as $searchcondition) {
             echo $searchcondition->display_options($this);
         }
-        $this->display_showtext_checkbox($showquestiontext);
+        if ($showtextoption) {
+            $this->display_showtext_checkbox($showquestiontext);
+        }
         $this->display_advanced_search_form();
+        $go = \html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('go')));
+        echo \html_writer::tag('noscript', \html_writer::div($go), array('class' => 'inline'));
+        echo \html_writer::end_div();
+        echo \html_writer::end_tag('form');
         $PAGE->requires->yui_module('moodle-question-searchform', 'M.question.searchform.init');
-        echo '<noscript><div class="centerpara"><input type="submit" value="'. get_string('go') .'" />';
-        echo '</div></noscript></fieldset></form>';
     }
 
     /**