See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 403]
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 qbank_customfields; 18 19 use core_question\local\bank\column_base; 20 21 /** 22 * A column type for the name of the question creator. 23 * 24 * @package qbank_customfields 25 * @copyright 2021 Catalyst IT Australia Pty Ltd 26 * @author Matt Porritt <mattp@catalyst-au.net> 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 */ 29 class custom_field_column extends column_base { 30 31 /** @var \core_customfield\field_controller The custom field this column is displaying. */ 32 protected $field; 33 34 /** 35 * Constructor. 36 * 37 * @param view $qbank the question bank view we are helping to render. 38 * @param \core_customfield\field_controller $field The custom field this column is displaying. 39 */ 40 public function __construct(\core_question\local\bank\view $qbank, \core_customfield\field_controller $field) { 41 parent::__construct($qbank); 42 $this->field = $field; 43 } 44 45 /** 46 * Get the internal name for this column. Used as a CSS class name, 47 * and to store information about the current sort. Must match PARAM_ALPHA. 48 * 49 * @return string column name. 50 */ 51 public function get_name(): string { 52 return 'customfield'; 53 } 54 55 /** 56 * Get the name of this column. This must be unique. 57 * When using the inherited class to make many columns from one parent, 58 * ensure each instance returns a unique value. 59 * 60 * @return string The unique name; 61 */ 62 public function get_column_name(): string { 63 return 'custom_field_column\\' . $this->field->get('shortname'); 64 } 65 66 /** 67 * Title for this column. Not used if is_sortable returns an array. 68 * 69 * @return string 70 */ 71 public function get_title(): string { 72 return $this->field->get_formatted_name(); 73 } 74 75 /** 76 * Output the contents of this column. 77 * 78 * @param object $question the row from the $question table, augmented with extra information. 79 * @param string $rowclasses CSS class names that should be applied to this row of output. 80 */ 81 protected function display_content($question, $rowclasses): void { 82 $fieldhandler = $this->field->get_handler(); 83 if ($fieldhandler->can_view($this->field, $question->id)) { 84 $fielddata = $fieldhandler->get_field_data($this->field, $question->id); 85 echo $fieldhandler->display_custom_field_table($fielddata); 86 } else { 87 echo ''; 88 } 89 } 90 91 public function get_extra_classes(): array { 92 return ['pr-3']; 93 } 94 95 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body