diff --git a/lang/en/question.php b/lang/en/question.php index 27b569dd025..3a9caaead44 100644 --- a/lang/en/question.php +++ b/lang/en/question.php @@ -25,6 +25,7 @@ $string['addmorechoiceblanks'] = 'Blanks for {no} more choices'; $string['addcategory'] = 'Add category'; $string['adminreport'] = 'Report on possible problems in your question database.'; +$string['advancedsearchoptions'] = 'Search options'; $string['answers'] = 'Answers'; $string['availableq'] = 'Available?'; $string['badbase'] = 'Bad base before **: {$a}**'; diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index 6cebed780e2..e3d9f8a6447 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -1111,6 +1111,7 @@ class quiz_question_bank_view extends question_bank_view { protected $quizhasattempts = false; /** @var object the quiz settings. */ protected $quiz = false; + const MAX_TEXT_LENGTH = 200; /** * Constructor @@ -1184,16 +1185,15 @@ class quiz_question_bank_view extends question_bank_view { return; } - // Display the current category. - if (!$category = $this->get_current_category($cat)) { - return; - } - $this->print_category_info($category); + $editcontexts = $this->contexts->having_one_edit_tab_cap($tabname); + array_unshift($this->searchconditions, + new question_bank_search_condition_hide(!$showhidden)); + array_unshift($this->searchconditions, + new question_bank_search_condition_category($cat, $recurse, + $editcontexts, $this->baseurl, $this->course, self::MAX_TEXT_LENGTH)); echo $OUTPUT->box_start('generalbox questionbank'); - - $this->display_category_form($this->contexts->having_one_edit_tab_cap($tabname), - $this->baseurl, $cat); + $this->display_options_form($showquestiontext); // Continues with list of questions. $this->display_question_list($this->contexts->having_one_edit_tab_cap($tabname), @@ -1201,12 +1201,18 @@ class quiz_question_bank_view extends question_bank_view { $perpage, $showhidden, $showquestiontext, $this->contexts->having_cap('moodle/question:add')); - $this->display_options($recurse, $showhidden, $showquestiontext); echo $OUTPUT->box_end(); } + /** + * prints a form to choose categories + * @deprecated since Moodle 2.6 MDL-40313. + * @see question_bank_search_condition_category + * @todo MDL-41978 This will be deleted in Moodle 2.8 + */ protected function print_choose_category_message($categoryandcontext) { global $OUTPUT; + debugging('print_choose_category_message() is deprecated, please use question_bank_search_condition_category instead.', DEBUG_DEVELOPER); echo $OUTPUT->box_start('generalbox questionbank'); $this->display_category_form($this->contexts->having_one_edit_tab_cap('edit'), $this->baseurl, $categoryandcontext); @@ -1216,6 +1222,27 @@ class quiz_question_bank_view extends 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 print_category_info($category) { $formatoptions = new stdClass(); $formatoptions->noclean = true; @@ -1232,6 +1259,7 @@ class quiz_question_bank_view extends question_bank_view { } protected function display_options($recurse, $showhidden, $showquestiontext) { + debugging('display_options() is deprecated, see display_options_form() instead.', DEBUG_DEVELOPER); echo '