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 namespace core_question\local\bank; 18 19 /** 20 * Abstract class to define functionality shared by all pluggable components used in the question bank view. 21 * 22 * @package core_question 23 * @copyright 2023 onwards Catalyst IT EU {@link https://catalyst-eu.net} 24 * @author Mark Johnson <mark.johnson@catalyst-eu.net> 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 abstract class view_component { 28 29 /** @var view Question bank view. */ 30 protected $qbank; 31 32 /** 33 * Constructor. 34 * @param view $qbank the question bank view we are helping to render. 35 */ 36 public function __construct(view $qbank) { 37 $this->qbank = $qbank; 38 $this->init(); 39 } 40 41 /** 42 * A chance for subclasses to initialise themselves, for example to load lang strings, 43 * without having to override the constructor. 44 */ 45 protected function init(): void { 46 } 47 48 /** 49 * Return an array 'table_alias' => 'JOIN clause' to bring in any data that 50 * this feature requires. 51 * 52 * The return values for all the features will be checked. It is OK if two 53 * features join in the same table with the same alias and identical JOIN clauses. 54 * If two features try to use the same alias with different joins, you get an error. 55 * Tables included by default are question (alias q) and those defined in {@see view::get_required_joins()} 56 * 57 * It is importnat that your join simply adds additional data (or NULLs) to the 58 * existing rows of the query. It must not cause additional rows. 59 * 60 * @return string[] 'table_alias' => 'JOIN clause' 61 */ 62 public function get_extra_joins(): array { 63 return []; 64 } 65 66 /** 67 * Use table alias 'q' for the question table, or one of the 68 * ones from get_extra_joins. Every field requested must specify a table prefix. 69 * 70 * @return string[] fields required. 71 */ 72 public function get_required_fields(): array { 73 return []; 74 } 75 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body