MDL-71915 question: Update the tertiary nav
Update the tertiary navigation activity for question.
This commit is contained in:
@@ -46,11 +46,14 @@ $category = $DB->get_record('question_categories', ["id" => $catid, 'contextid'
|
||||
$PAGE->set_url($thispageurl);
|
||||
$PAGE->set_title($strexportquestions);
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print horizontal nav if needed.
|
||||
$renderer = $PAGE->get_renderer('core_question', 'bank');
|
||||
echo $renderer->extra_horizontal_navigation();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$qbankaction = new \core_question\output\qbank_actionbar($thispageurl);
|
||||
echo $renderer->qbank_action_menu($qbankaction);
|
||||
|
||||
$exportform = new export_form($thispageurl,
|
||||
['contexts' => $contexts->having_one_edit_tab_cap('export'), 'defaultcategory' => $pagevars['cat']]);
|
||||
|
||||
@@ -73,11 +73,14 @@ if ($importform->is_cancelled()) {
|
||||
// Page header.
|
||||
$PAGE->set_title($txt->importquestions);
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print horizontal nav if needed.
|
||||
$renderer = $PAGE->get_renderer('core_question', 'bank');
|
||||
echo $renderer->extra_horizontal_navigation();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$qbankaction = new \core_question\output\qbank_actionbar($thispageurl);
|
||||
echo $renderer->qbank_action_menu($qbankaction);
|
||||
|
||||
// File upload form submitted.
|
||||
if ($form = $importform->get_data()) {
|
||||
|
||||
@@ -147,11 +147,14 @@ if ($param->edit) {
|
||||
|
||||
$PAGE->set_title(get_string('editcategories', 'question'));
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print horizontal nav if needed.
|
||||
$renderer = $PAGE->get_renderer('core_question', 'bank');
|
||||
echo $renderer->extra_horizontal_navigation();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$qbankaction = new \core_question\output\qbank_actionbar($url);
|
||||
echo $renderer->qbank_action_menu($qbankaction);
|
||||
|
||||
// Display the UI.
|
||||
if (!empty($param->edit)) {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 <[email protected]>
|
||||
* @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');
|
||||
|
||||
$urlselect = new url_select($menu, $this->currenturl, null, 'questionbankaction');
|
||||
$urlselect->set_label('questionbankactionselect', ['class' => 'accesshide']);
|
||||
|
||||
return ['questionbankselect' => $urlselect->export_for_template($output)];
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -42,11 +42,14 @@ $context = $contexts->lowest();
|
||||
$streditingquestions = get_string('editquestions', 'question');
|
||||
$PAGE->set_title($streditingquestions);
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print horizontal nav if needed.
|
||||
$renderer = $PAGE->get_renderer('core_question', 'bank');
|
||||
echo $renderer->extra_horizontal_navigation();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
// Render the selection action.
|
||||
$qbankaction = new \core_question\output\qbank_actionbar($url);
|
||||
echo $renderer->qbank_action_menu($qbankaction);
|
||||
|
||||
// Print the question area.
|
||||
$questionbank->display($pagevars, 'questions');
|
||||
|
||||
@@ -182,6 +182,17 @@ 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.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
{{!
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}}
|
||||
<div class="container-fluid mb-2">
|
||||
<div class="row">
|
||||
{{#questionbankselect}}
|
||||
{{>core/url_select}}
|
||||
{{/questionbankselect}}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user