Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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.
13
//
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/>.
16
 
17
/**
18
 * Renderers for outputting parts of the question bank.
19
 *
20
 * @package    core_question
21
 * @copyright  2011 The Open University
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
 
29
/**
30
 * This renderer outputs parts of the question bank.
31
 *
32
 * @copyright  2011 The Open University
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
35
class core_question_bank_renderer extends plugin_renderer_base {
36
 
37
    /**
38
     * Display additional navigation if needed.
39
     *
40
     * @param string $active
41
     * @return string
42
     */
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);
50
                }
51
                if (empty($active) && $questionnode->find_active_node()) {
52
                    $active = $questionnode->find_active_node()->key;
53
                }
54
                return \html_writer::div(print_tabs([$tabs], $active, null, null, true),
55
                        'questionbank-navigation');
56
            }
57
        }
58
        return '';
59
    }
60
 
61
    /**
62
     * Output the icon for a question type.
63
     *
64
     * @param string $qtype the question type.
65
     * @return string HTML fragment.
66
     */
67
    public function qtype_icon($qtype) {
68
        $qtype = question_bank::get_qtype($qtype, false);
69
        $namestr = $qtype->local_name();
70
 
71
        return $this->image_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr));
72
    }
73
 
74
    /**
75
     * Render the column headers.
76
     *
77
     * @param array $qbankheaderdata
78
     * @return bool|string
79
     */
80
    public function render_column_header($qbankheaderdata) {
81
        return $this->render_from_template('core_question/column_header', $qbankheaderdata);
82
    }
83
 
84
    /**
85
     * Render the column sort elements.
86
     *
87
     * @param array $sortdata
88
     * @return bool|string
89
     */
90
    public function render_column_sort($sortdata) {
91
        return $this->render_from_template('core_question/column_sort', $sortdata);
92
    }
93
 
94
    /**
95
     * @deprecated since Moodle 4.0
96
     */
97
    public function render_qbank_chooser() {
98
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
99
    }
100
 
101
    /**
102
     * Render category condition.
103
     *
104
     * @param array $displaydata
105
     * @return bool|string
106
     * @deprecated since Moodle 4.3
107
     * @todo Final deprecation on Moodle 4.7 MDL-78090
108
     */
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
114
        );
115
        return $this->render_from_template('qbank_managecategories/category_condition', $displaydata);
116
    }
117
 
118
    /**
119
     * Render category condition advanced.
120
     *
121
     * @param array $displaydata
122
     * @return bool|string
123
     * @deprecated since Moodle 4.3
124
     * @todo Final deprecation on Moodle 4.7 MDL-78090
125
     */
126
    public function render_category_condition_advanced($displaydata) {
127
        debugging(
128
            'Function render_category_condition_advanced() has been deprecated',
129
            DEBUG_DEVELOPER
130
        );
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);
133
    }
134
 
135
    /**
136
     * Render hidden condition advanced.
137
     *
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
143
     */
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
149
        );
150
        return $this->render_from_template('qbank_deletequestion/hidden_condition_advanced', $displaydata);
151
    }
152
 
153
    /**
154
     * Render question pagination.
155
     *
156
     * @param array $displaydata
157
     * @return bool|string
158
     */
159
    public function render_question_pagination($displaydata) {
160
        return $this->render_from_template('core_question/question_pagination', $displaydata);
161
    }
162
 
163
    /**
164
     * Render the showtext option.
165
     *
166
     * It's not a checkbox any more! [Name your API after the purpose, not the implementation!]
167
     *
168
     * @param array $displaydata
169
     * @return string
170
     */
171
    public function render_showtext_checkbox($displaydata) {
172
        return $this->render_from_template('core_question/showtext_option',
173
                ['selected' . $displaydata['checked'] => true]);
174
    }
175
 
176
    /**
177
     * Render bulk actions ui.
178
     *
179
     * @param array $displaydata
180
     * @return bool|string
181
     */
182
    public function render_bulk_actions_ui($displaydata) {
183
        return $this->render_from_template('core_question/bulk_actions_ui', $displaydata);
184
    }
185
 
186
    /**
187
     * @deprecated since Moodle 4.0
188
     */
189
    public function qbank_chooser() {
190
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
191
    }
192
 
193
    /**
194
     * @deprecated since Moodle 4.0
195
     */
196
    protected function qbank_chooser_types() {
197
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
198
    }
199
 
200
    /**
201
     * @deprecated since Moodle 4.0
202
     */
203
    protected function qbank_chooser_qtype() {
204
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
205
    }
206
 
207
    /**
208
     * @deprecated since Moodle 4.0
209
     */
210
    protected function qbank_chooser_title() {
211
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
212
    }
213
 
214
}