Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]

   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 mod_quiz\question\bank;
  18  
  19  /**
  20   * A column type for the name followed by the start of the question text.
  21   *
  22   * @package    mod_quiz
  23   * @category   question
  24   * @copyright  2009 Tim Hunt
  25   * @author     2021 Safat Shahin <safatshahin@catalyst-au.net>
  26   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27   */
  28  class question_name_text_column extends question_name_column {
  29  
  30      public function get_name(): string {
  31          return 'questionnametext';
  32      }
  33  
  34      protected function display_content($question, $rowclasses): void {
  35          echo \html_writer::start_tag('div');
  36          $labelfor = $this->label_for($question);
  37          if ($labelfor) {
  38              echo \html_writer::start_tag('label', ['for' => $labelfor]);
  39          }
  40          echo quiz_question_tostring($question, false, true, true, $question->tags);
  41          if ($labelfor) {
  42              echo \html_writer::end_tag('label');
  43          }
  44          echo \html_writer::end_tag('div');
  45      }
  46  
  47      public function get_required_fields(): array {
  48          $fields = parent::get_required_fields();
  49          $fields[] = 'q.questiontext';
  50          $fields[] = 'q.questiontextformat';
  51          $fields[] = 'qbe.idnumber';
  52          return $fields;
  53      }
  54  
  55      public function load_additional_data(array $questions) {
  56          parent::load_additional_data($questions);
  57          parent::load_question_tags($questions);
  58      }
  59  }