2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Defines the custom question bank view used in the question bank modal.
22 * @copyright 2018 Ryan Wyllie <ryan@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 namespace mod_quiz\question\bank
;
27 defined('MOODLE_INTERNAL') ||
die();
31 * Subclass to customise the view of the question bank for a fragment.
33 * This view is to be used when returning the question bank as part of
36 * @copyright 2018 Ryan Wyllie <ryan@moodle.com>
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 class fragment_view
extends custom_view
{
41 * Override the base implementation in \core_question\bank\view
42 * because we don't want to print the headers in the fragment
45 protected function display_question_bank_header() {
49 * Override the base implementation in \core_question\bank\view
50 * because we don't want it to read from the $_POST global variables
51 * for the sort parameters since they are not present in a fragment.
53 * Unfortunately the best we can do is to look at the URL for
54 * those parameters (only marginally better really).
56 protected function init_sort_from_params() {
58 for ($i = 1; $i <= self
::MAX_SORTS
; $i++
) {
59 if (!$sort = $this->baseurl
->param('qbs' . $i)) {
62 // Work out the appropriate order.
64 if ($sort[0] == '-') {
66 $sort = substr($sort, 1);
71 // Deal with subsorts.
72 list($colname, $subsort) = $this->parse_subsort($sort);
73 $this->requiredcolumns
[$colname] = $this->get_column_type($colname);
74 $this->sort
[$sort] = $order;