See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401] [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_viewquestionname; 18 19 /** 20 * A question bank column showing the question name with idnumber and tags. 21 * 22 * @package qbank_viewquestionname 23 * @copyright 2019 The Open University 24 * @author 2021 Safat Shahin <safatshahin@catalyst-au.net> 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 class question_name_idnumber_tags_column extends viewquestionname_column_helper { 28 29 public function get_name(): string { 30 return 'qnameidnumbertags'; 31 } 32 33 protected function display_content($question, $rowclasses): void { 34 global $OUTPUT; 35 36 echo \html_writer::start_tag('div', ['class' => 'd-inline-flex flex-nowrap overflow-hidden w-100']); 37 $questiondisplay = $OUTPUT->render(new \qbank_viewquestionname\output\questionname($question)); 38 $labelfor = $this->label_for($question); 39 if ($labelfor) { 40 echo \html_writer::tag('label', $questiondisplay, [ 41 'for' => $labelfor, 42 ]); 43 } else { 44 echo \html_writer::start_span('questionname flex-grow-1 flex-shrink-1 text-truncate'); 45 echo $questiondisplay; 46 echo \html_writer::end_span(); 47 } 48 49 // Question idnumber. 50 // The non-breaking space ' ' is used in html to fix MDL-75051 (browser issues caused by chrome and Edge). 51 if ($question->idnumber !== null && $question->idnumber !== '') { 52 echo ' ' . \html_writer::span( 53 \html_writer::span(get_string('idnumber', 'question'), 'accesshide') 54 . ' ' . \html_writer::span(s($question->idnumber), 'badge badge-primary'), 'ml-1'); 55 } 56 57 // Question tags. 58 if (!empty($question->tags)) { 59 $tags = \core_tag_tag::get_item_tags('core_question', 'question', $question->id); 60 echo $OUTPUT->tag_list($tags, null, 'd-inline flex-shrink-1 text-truncate ml-1', 0, null, true); 61 } 62 63 echo \html_writer::end_tag('div'); 64 } 65 66 public function get_required_fields(): array { 67 $fields = parent::get_required_fields(); 68 $fields[] = 'qbe.idnumber'; 69 return $fields; 70 } 71 72 public function is_sortable(): array { 73 return [ 74 'name' => ['field' => 'q.name', 'title' => get_string('questionname', 'question')], 75 'idnumber' => ['field' => 'qbe.idnumber', 'title' => get_string('idnumber', 'question')], 76 ]; 77 } 78 79 public function load_additional_data(array $questions): void { 80 parent::load_additional_data($questions); 81 parent::load_question_tags($questions); 82 } 83 84 public function get_extra_classes(): array { 85 return ['pr-3']; 86 } 87 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body