Commit fff03332 authored by Ryan Wyllie's avatar Ryan Wyllie
Browse files

MDL-61135 mod_quiz: add tag condition to question bank form

parent 171d7919
......@@ -1249,7 +1249,8 @@ class edit_renderer extends \plugin_renderer_base {
public function question_bank_contents(\mod_quiz\question\bank\custom_view $questionbank, array $pagevars) {
$qbank = $questionbank->render('editq', $pagevars['qpage'], $pagevars['qperpage'],
$pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], $pagevars['qbshowtext']);
$pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], $pagevars['qbshowtext'],
$pagevars['qtagids']);
return html_writer::div(html_writer::div($qbank, 'bd'), 'questionbankformforpopup');
}
}
......@@ -138,9 +138,10 @@ class custom_view extends \core_question\bank\view {
*
* @return string HTML code for the form
*/
public function render($tabname, $page, $perpage, $cat, $recurse, $showhidden, $showquestiontext) {
public function render($tabname, $page, $perpage, $cat, $recurse, $showhidden,
$showquestiontext, $tagids = []) {
ob_start();
$this->display($tabname, $page, $perpage, $cat, $recurse, $showhidden, $showquestiontext);
$this->display($tabname, $page, $perpage, $cat, $recurse, $showhidden, $showquestiontext, $tagids);
$out = ob_get_contents();
ob_end_clean();
return $out;
......
......@@ -462,15 +462,18 @@ class view {
* displayoptions Sets display options
*/
public function display($tabname, $page, $perpage, $cat,
$recurse, $showhidden, $showquestiontext) {
global $PAGE, $OUTPUT;
$recurse, $showhidden, $showquestiontext, $tagids = []) {
global $PAGE;
if ($this->process_actions_needing_ui()) {
return;
}
$editcontexts = $this->contexts->having_one_edit_tab_cap($tabname);
list($categoryid, $contextid) = explode(',', $cat);
$catcontext = \context::instance_by_id($contextid);
// Category selection form.
$this->display_question_bank_header();
array_unshift($this->searchconditions, new \core_question\bank\search\tag_condition([$catcontext], $tagids));
array_unshift($this->searchconditions, new \core_question\bank\search\hidden_condition(!$showhidden));
array_unshift($this->searchconditions, new \core_question\bank\search\category_condition(
$cat, $recurse, $editcontexts, $this->baseurl, $this->course));
......@@ -593,7 +596,19 @@ class view {
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'));
$excludes = array('recurse', 'showhidden', 'qbshowtext');
// If the URL contains any tags then we need to prevent them
// being added to the form as hidden elements because the tags
// are managed separately.
if ($this->baseurl->param('qtagids[0]')) {
$index = 0;
while ($this->baseurl->param("qtagids[{$index}]")) {
$excludes[] = "qtagids[{$index}]";
$index++;
}
}
echo \html_writer::input_hidden_params($this->baseurl, $excludes);
foreach ($this->searchconditions as $searchcondition) {
echo $searchcondition->display_options($this);
......
......@@ -54,7 +54,7 @@ echo $renderer->extra_horizontal_navigation();
echo '<div class="questionbankwindow boxwidthwide boxaligncenter">';
$questionbank->display('questions', $pagevars['qpage'], $pagevars['qperpage'],
$pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'],
$pagevars['qbshowtext']);
$pagevars['qbshowtext'], $pagevars['qtagids']);
echo "</div>\n";
echo $OUTPUT->footer();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment