Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
   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  /**
  18   * Base class for 'columns' that are actually displayed as a row following the main question row.
  19   *
  20   * @package   core_question
  21   * @copyright 2009 Tim Hunt
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace core_question\local\bank;
  26  
  27  /**
  28   * Base class for 'columns' that are actually displayed as a row following the main question row.
  29   *
  30   * @copyright 2009 Tim Hunt
  31   * @author    2021 Safat Shahin <safatshahin@catalyst-au.net>
  32   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33   */
  34  abstract class row_base extends column_base {
  35  
  36      /**
  37       * Check if the column is an extra row of not.
  38       */
  39      public function is_extra_row(): bool {
  40          return true;
  41      }
  42  
  43      /**
  44       * Output the opening column tag.  If it is set as heading, it will use <th> tag instead of <td>
  45       *
  46       * @param \stdClass $question
  47       * @param string $rowclasses
  48       */
  49      protected function display_start($question, $rowclasses): void {
  50          if ($rowclasses) {
  51              echo \html_writer::start_tag('tr', ['class' => $rowclasses]);
  52          } else {
  53              echo \html_writer::start_tag('tr');
  54          }
  55          echo \html_writer::start_tag('td',
  56                  ['colspan' => $this->qbank->get_column_count(), 'class' => $this->get_name()]);
  57      }
  58  
  59      /**
  60       * Output the closing column tag
  61       *
  62       * @param object $question
  63       * @param string $rowclasses
  64       */
  65      protected function display_end($question, $rowclasses): void {
  66          echo \html_writer::end_tag('td');
  67          echo \html_writer::end_tag('tr');
  68      }
  69  
  70  }