Merge branch 'MDL-77223-400' of https://github.com/roland04/moodle into MOODLE_400_STABLE
[moodle.git] / question / renderer.php
blob83cfc413e5203ac9db836641ab7cd7b4c6e90aa2
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 core_question
21 * @copyright 2011 The Open University
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die();
29 /**
30 * This renderer outputs parts of the question bank.
32 * @copyright 2011 The Open University
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class core_question_bank_renderer extends plugin_renderer_base {
37 /**
38 * Display additional navigation if needed.
40 * @param string $active
41 * @return string
43 public function extra_horizontal_navigation($active = null) {
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 if (empty($active) && $questionnode->find_active_node()) {
52 $active = $questionnode->find_active_node()->key;
54 return \html_writer::div(print_tabs([$tabs], $active, null, null, true),
55 'questionbank-navigation');
58 return '';
61 /**
62 * Output the icon for a question type.
64 * @param string $qtype the question type.
65 * @return string HTML fragment.
67 public function qtype_icon($qtype) {
68 $qtype = question_bank::get_qtype($qtype, false);
69 $namestr = $qtype->local_name();
71 return $this->image_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr));
74 /**
75 * Render the column headers.
77 * @param array $qbankheaderdata
78 * @return bool|string
80 public function render_column_header($qbankheaderdata) {
81 return $this->render_from_template('core_question/column_header', $qbankheaderdata);
84 /**
85 * Render the column sort elements.
87 * @param array $sortdata
88 * @return bool|string
90 public function render_column_sort($sortdata) {
91 return $this->render_from_template('core_question/column_sort', $sortdata);
94 /**
95 * Render a qbank_chooser.
97 * @param renderable $qbankchooser The chooser.
98 * @return string
99 * @deprecated since Moodle 4.0
100 * @see \qbank_editquestion\output\renderer
101 * @todo Final deprecation on Moodle 4.4 MDL-72438
103 public function render_qbank_chooser(renderable $qbankchooser) {
104 debugging('Function render_qbank_chooser is deprecated,
105 please use qbank_editquestion renderer instead.', DEBUG_DEVELOPER);
106 return $this->render_from_template('core_question/qbank_chooser', $qbankchooser->export_for_template($this));
110 * Render category condition.
112 * @param array $displaydata
113 * @return bool|string
115 public function render_category_condition($displaydata) {
116 return $this->render_from_template('core_question/category_condition', $displaydata);
120 * Render category condition advanced.
122 * @param array $displaydata
123 * @return bool|string
125 public function render_category_condition_advanced($displaydata) {
126 return $this->render_from_template('core_question/category_condition_advanced', $displaydata);
130 * Render hidden condition advanced.
132 * @param array $displaydata
133 * @return bool|string
135 public function render_hidden_condition_advanced($displaydata) {
136 return $this->render_from_template('core_question/hidden_condition_advanced', $displaydata);
140 * Render question pagination.
142 * @param array $displaydata
143 * @return bool|string
145 public function render_question_pagination($displaydata) {
146 return $this->render_from_template('core_question/question_pagination', $displaydata);
150 * Render question showtext checkbox.
152 * @param array $displaydata
153 * @return bool|string
155 public function render_showtext_checkbox($displaydata) {
156 return $this->render_from_template('core_question/showtext_checkbox', $displaydata);
160 * Render bulk actions ui.
162 * @param array $displaydata
163 * @return bool|string
165 public function render_bulk_actions_ui($displaydata) {
166 return $this->render_from_template('core_question/bulk_actions_ui', $displaydata);
170 * Build the HTML for the question chooser javascript popup.
172 * @param array $real A set of real question types
173 * @param array $fake A set of fake question types
174 * @param object $course The course that will be displayed
175 * @param array $hiddenparams Any hidden parameters to add to the form
176 * @return string The composed HTML for the questionbank chooser
177 * @todo Final deprecation on Moodle 4.4 MDL-72438
179 public function qbank_chooser($real, $fake, $course, $hiddenparams) {
180 debugging('Method core_question_bank_renderer::qbank_chooser() is deprecated, ' .
181 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
182 return '';
186 * Build the HTML for a specified set of question types.
188 * @param array $types A set of question types as used by the qbank_chooser_module function
189 * @return string The composed HTML for the module
190 * @todo Final deprecation on Moodle 4.4 MDL-72438
192 protected function qbank_chooser_types($types) {
193 debugging('Method core_question_bank_renderer::qbank_chooser_types() is deprecated, ' .
194 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
195 return '';
199 * Return the HTML for the specified question type, adding any required classes.
201 * @param object $qtype An object containing the title, and link. An icon, and help text may optionally be specified.
202 * If the module contains subtypes in the types option, then these will also be displayed.
203 * @param array $classes Additional classes to add to the encompassing div element
204 * @return string The composed HTML for the question type
205 * @todo Final deprecation on Moodle 4.4 MDL-72438
207 protected function qbank_chooser_qtype($qtype, $classes = array()) {
208 debugging('Method core_question_bank_renderer::qbank_chooser_qtype() is deprecated, ' .
209 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
210 return '';
214 * Return the title for the question bank chooser.
216 * @param string $title The language string identifier
217 * @param string $identifier The component identifier
218 * @return string The composed HTML for the title
219 * @todo Final deprecation on Moodle 4.4 MDL-72438
221 protected function qbank_chooser_title($title, $identifier = null) {
222 debugging('Method core_question_bank_renderer::qbank_chooser_title() is deprecated, ' .
223 'see core_question_bank_renderer::render_qbank_chooser().', DEBUG_DEVELOPER);
224 return '';