MDL-62992 question: conditionaly enable question tags feature

This commit is contained in:
Simey Lameze 2019-03-06 10:25:28 +08:00
parent 3271c39c74
commit 2cfd8d1678

View file

@ -462,7 +462,7 @@ class view {
*/ */
public function display($tabname, $page, $perpage, $cat, public function display($tabname, $page, $perpage, $cat,
$recurse, $showhidden, $showquestiontext, $tagids = []) { $recurse, $showhidden, $showquestiontext, $tagids = []) {
global $PAGE; global $PAGE, $CFG;
if ($this->process_actions_needing_ui()) { if ($this->process_actions_needing_ui()) {
return; return;
@ -473,7 +473,14 @@ class view {
$thiscontext = $this->get_most_specific_context(); $thiscontext = $this->get_most_specific_context();
// Category selection form. // Category selection form.
$this->display_question_bank_header(); $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\hidden_condition(!$showhidden));
array_unshift($this->searchconditions, new \core_question\bank\search\category_condition( array_unshift($this->searchconditions, new \core_question\bank\search\category_condition(
$cat, $recurse, $editcontexts, $this->baseurl, $this->course)); $cat, $recurse, $editcontexts, $this->baseurl, $this->course));
@ -485,7 +492,6 @@ class view {
null, $page, $perpage, $showhidden, $showquestiontext, null, $page, $perpage, $showhidden, $showquestiontext,
$this->contexts->having_cap('moodle/question:add')); $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) { protected function print_choose_category_message($categoryandcontext) {