diff --git a/question/bank/exportquestions/export.php b/question/bank/exportquestions/export.php index c5a3a1e20b4..a36a7b0914d 100644 --- a/question/bank/exportquestions/export.php +++ b/question/bank/exportquestions/export.php @@ -48,13 +48,11 @@ $PAGE->set_title($strexportquestions); $PAGE->set_heading($COURSE->fullname); $PAGE->activityheader->disable(); -// Print horizontal nav if needed. -$renderer = $PAGE->get_renderer('core_question', 'bank'); - echo $OUTPUT->header(); -$qbankaction = new \core_question\output\qbank_actionbar($thispageurl); -echo $renderer->qbank_action_menu($qbankaction); +// Print horizontal nav if needed. +$renderer = $PAGE->get_renderer('core_question', 'bank'); +echo $renderer->extra_horizontal_navigation(); $exportform = new export_form($thispageurl, ['contexts' => $contexts->having_one_edit_tab_cap('export'), 'defaultcategory' => $pagevars['cat']]); diff --git a/question/bank/importquestions/import.php b/question/bank/importquestions/import.php index ccf1a674be8..959acf90eae 100644 --- a/question/bank/importquestions/import.php +++ b/question/bank/importquestions/import.php @@ -75,13 +75,12 @@ $PAGE->set_title($txt->importquestions); $PAGE->set_heading($COURSE->fullname); $PAGE->activityheader->disable(); -// Print horizontal nav if needed. -$renderer = $PAGE->get_renderer('core_question', 'bank'); - echo $OUTPUT->header(); -$qbankaction = new \core_question\output\qbank_actionbar($thispageurl); -echo $renderer->qbank_action_menu($qbankaction); +// Print horizontal nav if needed. +$renderer = $PAGE->get_renderer('core_question', 'bank'); +echo $renderer->extra_horizontal_navigation(); + // File upload form submitted. if ($form = $importform->get_data()) { diff --git a/question/bank/managecategories/category.php b/question/bank/managecategories/category.php index bba32c2f07d..e501edb3014 100644 --- a/question/bank/managecategories/category.php +++ b/question/bank/managecategories/category.php @@ -152,13 +152,11 @@ $PAGE->set_title(get_string('editcategories', 'question')); $PAGE->set_heading($COURSE->fullname); $PAGE->activityheader->disable(); -// Print horizontal nav if needed. -$renderer = $PAGE->get_renderer('core_question', 'bank'); - echo $OUTPUT->header(); -$qbankaction = new \core_question\output\qbank_actionbar($url); -echo $renderer->qbank_action_menu($qbankaction); +// Print horizontal nav if needed. +$renderer = $PAGE->get_renderer('core_question', 'bank'); +echo $renderer->extra_horizontal_navigation(); // Display the UI. if (!empty($param->edit)) { diff --git a/question/classes/output/qbank_actionbar.php b/question/classes/output/qbank_actionbar.php deleted file mode 100644 index 85d987ad183..00000000000 --- a/question/classes/output/qbank_actionbar.php +++ /dev/null @@ -1,103 +0,0 @@ -. - -namespace core_question\output; - -use moodle_url; -use renderer_base; -use templatable; -use renderable; -use url_select; - -/** - * Rendered HTML elements for tertiary nav for Question bank. - * - * @package core_question - * @copyright 2021 Sujith Haridasan - * @package core_question - */ -class qbank_actionbar implements templatable, renderable { - /** @var moodle_url */ - private $currenturl; - - /** - * qbank_actionbar constructor. - * - * @param moodle_url $currenturl The current URL. - */ - public function __construct(moodle_url $currenturl) { - $this->currenturl = $currenturl; - } - - /** - * Provides the data for the template. - * - * @param renderer_base $output renderer_base object. - * @return array data for the template - */ - public function export_for_template(renderer_base $output): array { - $questionslink = new moodle_url('/question/edit.php', $this->currenturl->params()); - if (\core\plugininfo\qbank::is_plugin_enabled("qbank_managecategories")) { - $categorylink = new moodle_url('/question/bank/managecategories/category.php', $this->currenturl->params()); - } - $importlink = new moodle_url('/question/bank/importquestions/import.php', $this->currenturl->params()); - $exportlink = new moodle_url('/question/bank/exportquestions/export.php', $this->currenturl->params()); - - $menu = [ - $questionslink->out(false) => get_string('questions', 'question'), - ]; - - if (\core\plugininfo\qbank::is_plugin_enabled("qbank_managecategories")) { - $menu[$categorylink->out(false)] = get_string('categories', 'question'); - } - $menu[$importlink->out(false)] = get_string('import', 'question'); - $menu[$exportlink->out(false)] = get_string('export', 'question'); - $additional = $this->get_additional_menu_elements(); - $menu += $additional ?: []; - - $urlselect = new url_select($menu, $this->currenturl->out(false), null, 'questionbankaction'); - $urlselect->set_label('questionbankactionselect', ['class' => 'accesshide']); - - return ['questionbankselect' => $urlselect->export_for_template($output)]; - } - - /** - * Gets the additional third party navigation nodes. - * - * @return array|null The additional menu elements. - */ - protected function get_additional_menu_elements(): ?array { - global $PAGE; - $qbnode = $PAGE->settingsnav->find('questionbank', \navigation_node::TYPE_CONTAINER); - $othernodes = []; - foreach ($qbnode->children as $key => $value) { - if (array_search($value->key, $this->expected_nodes()) === false) { - $othernodes[] = $value; - } - } - $result = \core\navigation\views\secondary::create_menu_element($othernodes, true); - return $result; - } - - /** - * Returns a list of expected child navigation nodes for 'questionbank'. - * - * @return array The expected nodes - */ - protected function expected_nodes(): array { - return ['questions', 'categories', 'import', 'export']; - } -} diff --git a/question/edit.php b/question/edit.php index b70fbf6f450..2c386c29342 100644 --- a/question/edit.php +++ b/question/edit.php @@ -48,13 +48,11 @@ $PAGE->set_title($streditingquestions); $PAGE->set_heading($COURSE->fullname); $PAGE->activityheader->disable(); +echo $OUTPUT->header(); + // Print horizontal nav if needed. $renderer = $PAGE->get_renderer('core_question', 'bank'); - -echo $OUTPUT->header(); -// Render the selection action. -$qbankaction = new \core_question\output\qbank_actionbar($url); -echo $renderer->qbank_action_menu($qbankaction); +echo $renderer->extra_horizontal_navigation(); // Print the question area. $questionbank->display($pagevars, 'questions'); diff --git a/question/renderer.php b/question/renderer.php index c4687e2b44b..83cfc413e52 100644 --- a/question/renderer.php +++ b/question/renderer.php @@ -182,17 +182,6 @@ class core_question_bank_renderer extends plugin_renderer_base { return ''; } - /** - * Get the rendered HTML for the action area in Question bank. - * - * @param \core_question\output\qbank_actionbar $qbankactionbar qbankactionbar object. - * @return string rendered HTML string from template. - */ - public function qbank_action_menu(\core_question\output\qbank_actionbar $qbankactionbar): string { - return $this->render_from_template('core_question/qbank_action_menu', - $qbankactionbar->export_for_template($this)); - } - /** * Build the HTML for a specified set of question types. * diff --git a/question/templates/qbank_action_menu.mustache b/question/templates/qbank_action_menu.mustache deleted file mode 100644 index 87d9ed33d97..00000000000 --- a/question/templates/qbank_action_menu.mustache +++ /dev/null @@ -1,63 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Moodle. If not, see . -}} -{{! - @template core_question/qbank_action_menu - Add selector in the question bank tab. - Classes required for JS: - * none - Data attributes required for JS: - * data-region - Context variables required for this template: - * see question/classes/output/qbank_actionbar.php - Example context (json): - { - "action" : "http://localhost/moodle/course/jumpto.php", - "classes" : "urlselect", - "formid" : "questionbankaction", - "id" : "url_select61a85bc543dca7", - "label" : "questionbankactionselect", - "options" : [ - { - "name" : "Questions", - "selected" : true, - "value" : "/question/edit.php?courseid=7" - }, - { - "name" : "Categories", - "selected" : false, - "value" : "/question/bank/managecategories/category.php?courseid=7" - }, - { - "name" : "Import", - "selected" : false, - "value" : "/question/bank/importquestions/import.php?courseid=7" - }, - { - "name" : "Export", - "selected" : false, - "value" : "/question/bank/exportquestions/export.php?courseid=7" - } - ] - } -}} -
-
- {{#questionbankselect}} - {{>core/url_select}} - {{/questionbankselect}} -
-