MDL-81326 mod_book: Deprecate book_get_nav_classes
[moodle.git] / question / renderer.php
blob32aea098f770370acc75e7fcca7b420bfc08ed3a
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 * @deprecated since Moodle 4.0
97 public function render_qbank_chooser() {
98 throw new coding_exception(__FUNCTION__ . '() has been removed.');
102 * Render category condition.
104 * @param array $displaydata
105 * @return bool|string
106 * @deprecated since Moodle 4.3
107 * @todo Final deprecation on Moodle 4.7 MDL-78090
109 public function render_category_condition($displaydata) {
110 debugging(
111 'Function render_category_condition() has been deprecated and moved to qbank_managecategories plugin, ' .
112 'Please use qbank_managecategories\output\renderer::render_category_condition() instead.',
113 DEBUG_DEVELOPER
115 return $this->render_from_template('qbank_managecategories/category_condition', $displaydata);
119 * Render category condition advanced.
121 * @param array $displaydata
122 * @return bool|string
123 * @deprecated since Moodle 4.3
124 * @todo Final deprecation on Moodle 4.7 MDL-78090
126 public function render_category_condition_advanced($displaydata) {
127 debugging(
128 'Function render_category_condition_advanced() has been deprecated',
129 DEBUG_DEVELOPER
131 // The template category_condition_advanced should also be deleted with this function.
132 return $this->render_from_template('qbank_managecategories/category_condition_advanced', $displaydata);
136 * Render hidden condition advanced.
138 * @param array $displaydata
139 * @return bool|string
140 * @see qbank_deletequestion\output\renderer
141 * @deprecated since Moodle 4.3
142 * @todo Final deprecation on Moodle 4.7 MDL-78090
144 public function render_hidden_condition_advanced($displaydata) {
145 debugging(
146 'Function render_hidden_condition_advanced() has been deprecated and moved to qbank_deletequestion plugin, ' .
147 'Please use qbank_deletequestion\output\renderer::render_hidden_condition_advanced() instead.',
148 DEBUG_DEVELOPER
150 return $this->render_from_template('qbank_deletequestion/hidden_condition_advanced', $displaydata);
154 * Render question pagination.
156 * @param array $displaydata
157 * @return bool|string
159 public function render_question_pagination($displaydata) {
160 return $this->render_from_template('core_question/question_pagination', $displaydata);
164 * Render the showtext option.
166 * It's not a checkbox any more! [Name your API after the purpose, not the implementation!]
168 * @param array $displaydata
169 * @return string
171 public function render_showtext_checkbox($displaydata) {
172 return $this->render_from_template('core_question/showtext_option',
173 ['selected' . $displaydata['checked'] => true]);
177 * Render bulk actions ui.
179 * @param array $displaydata
180 * @return bool|string
182 public function render_bulk_actions_ui($displaydata) {
183 return $this->render_from_template('core_question/bulk_actions_ui', $displaydata);
187 * @deprecated since Moodle 4.0
189 public function qbank_chooser() {
190 throw new coding_exception(__FUNCTION__ . '() has been removed.');
194 * @deprecated since Moodle 4.0
196 protected function qbank_chooser_types() {
197 throw new coding_exception(__FUNCTION__ . '() has been removed.');
201 * @deprecated since Moodle 4.0
203 protected function qbank_chooser_qtype() {
204 throw new coding_exception(__FUNCTION__ . '() has been removed.');
208 * @deprecated since Moodle 4.0
210 protected function qbank_chooser_title() {
211 throw new coding_exception(__FUNCTION__ . '() has been removed.');