Merge branch 'MDL-75910-39' of https://github.com/andrewnicols/moodle into MOODLE_39_...
[moodle.git] / question / renderer.php
blob76ef282cda579efcd68f1ac597fbb0f601a6e921
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Renderers for outputting parts of the question bank.
20 * @package moodlecore
21 * @subpackage questionbank
22 * @copyright 2011 The Open University
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') || die();
30 /**
31 * This renderer outputs parts of the question bank.
33 * @copyright 2011 The Open University
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class core_question_bank_renderer extends plugin_renderer_base {
38 /**
39 * Display additional navigation if needed.
41 * @return string
43 public function extra_horizontal_navigation() {
44 // Horizontal navigation for question bank.
45 if ($questionnode = $this->page->settingsnav->find("questionbank", \navigation_node::TYPE_CONTAINER)) {
46 if ($children = $questionnode->children) {
47 $tabs = [];
48 foreach ($children as $key => $node) {
49 $tabs[] = new \tabobject($node->key, $node->action, $node->text);
51 $active = $questionnode->find_active_node()->key;
52 return \html_writer::div(print_tabs([$tabs], $active, null, null, true), 'questionbank-navigation');
55 return '';
58 /**
59 * Output the icon for a question type.
61 * @param string $qtype the question type.
62 * @return string HTML fragment.
64 public function qtype_icon($qtype) {
65 $qtype = question_bank::get_qtype($qtype, false);
66 $namestr = $qtype->local_name();
68 return $this->image_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr));
71 /**
72 * Render a qbank_chooser.
74 * @param renderable $qbankchooser The chooser.
75 * @return string
77 public function render_qbank_chooser(renderable $qbankchooser) {
78 return $this->render_from_template('core_question/qbank_chooser', $qbankchooser->export_for_template($this));
81 /**
82 * Build the HTML for the question chooser javascript popup.
84 * @param array $real A set of real question types
85 * @param array $fake A set of fake question types
86 * @param object $course The course that will be displayed
87 * @param array $hiddenparams Any hidden parameters to add to the form
88 * @return string The composed HTML for the questionbank chooser
90 public function qbank_chooser($real, $fake, $course, $hiddenparams) {
91 debugging('Method core_question_bank_renderer::qbank_chooser() is deprecated, ' .
92 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
93 return '';
96 /**
97 * Build the HTML for a specified set of question types.
99 * @param array $types A set of question types as used by the qbank_chooser_module function
100 * @return string The composed HTML for the module
102 protected function qbank_chooser_types($types) {
103 debugging('Method core_question_bank_renderer::qbank_chooser_types() is deprecated, ' .
104 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
105 return '';
109 * Return the HTML for the specified question type, adding any required classes.
111 * @param object $qtype An object containing the title, and link. An icon, and help text may optionally be specified.
112 * If the module contains subtypes in the types option, then these will also be displayed.
113 * @param array $classes Additional classes to add to the encompassing div element
114 * @return string The composed HTML for the question type
116 protected function qbank_chooser_qtype($qtype, $classes = array()) {
117 debugging('Method core_question_bank_renderer::qbank_chooser_qtype() is deprecated, ' .
118 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
119 return '';
123 * Return the title for the question bank chooser.
125 * @param string $title The language string identifier
126 * @param string $identifier The component identifier
127 * @return string The composed HTML for the title
129 protected function qbank_chooser_title($title, $identifier = null) {
130 debugging('Method core_question_bank_renderer::qbank_chooser_title() is deprecated, ' .
131 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
132 return '';