Skip to content

Commit

Permalink
MDL-62992 question: conditionaly enable question tags feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Mar 27, 2019
1 parent d70651f commit 89b9e4f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions question/classes/bank/view.php
Expand Up @@ -462,7 +462,7 @@ public function preview_question_url($questiondata) {
*/
public function display($tabname, $page, $perpage, $cat,
$recurse, $showhidden, $showquestiontext, $tagids = []) {
global $PAGE;
global $PAGE, $CFG;

if ($this->process_actions_needing_ui()) {
return;
Expand All @@ -473,7 +473,14 @@ public function display($tabname, $page, $perpage, $cat,
$thiscontext = $this->get_most_specific_context();
// Category selection form.
$this->display_question_bank_header();
array_unshift($this->searchconditions, new \core_question\bank\search\tag_condition([$catcontext, $thiscontext], $tagids));

// Display tag filter if usetags setting is enabled.
if ($CFG->usetags) {
array_unshift($this->searchconditions,
new \core_question\bank\search\tag_condition([$catcontext, $thiscontext], $tagids));
$PAGE->requires->js_call_amd('core_question/edit_tags', 'init', ['#questionscontainer']);
}

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));
Expand All @@ -485,7 +492,6 @@ public function display($tabname, $page, $perpage, $cat,
null, $page, $perpage, $showhidden, $showquestiontext,
$this->contexts->having_cap('moodle/question:add'));

$PAGE->requires->js_call_amd('core_question/edit_tags', 'init', ['#questionscontainer']);
}

protected function print_choose_category_message($categoryandcontext) {
Expand Down

0 comments on commit 89b9e4f

Please sign in to comment.