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.
   1  <?php
   2  // This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Various fixture course formats for backup unit tests
  19   *
  20   * @package    core_backup
  21   * @category   test
  22   * @copyright  2022 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com}
  23   * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  global $CFG;
  29  require_once($CFG->dirroot . '/course/format/topics/lib.php');
  30  
  31  /**
  32   * Fixture course format with one option.
  33   */
  34  class format_test_cs_options extends format_topics {
  35      /**
  36       * Override method format_topics::get_default_section_name to prevent PHPUnit errors related to the nonexistent
  37       * format_test_cs_options lang file.
  38       *
  39       * @param \stdClass $section The section in question.
  40       * @return string The section's name for display.
  41       */
  42      public function get_default_section_name($section) {
  43          if ($section->section == 0) {
  44              return parent::get_default_section_name($section);
  45          } else {
  46              return get_string('sectionname', 'format_topics') . ' ' . $section->section;
  47          }
  48      }
  49  
  50      public function section_format_options($foreditform = false) {
  51          return array(
  52              'numdaystocomplete' => array(
  53                   'type' => PARAM_INT,
  54                   'label' => 'Test days',
  55                   'element_type' => 'text',
  56                   'default' => 0,
  57               ),
  58           );
  59      }
  60  }
  61  
  62  /**
  63   * Fixture course format with 2 options, 1 inherited.
  64   */
  65  class format_test_cs2_options extends format_test_cs_options {
  66      public function section_format_options($foreditform = false) {
  67          return array(
  68              'numdaystocomplete' => array(
  69                   'type' => PARAM_INT,
  70                   'label' => 'Test days',
  71                   'element_type' => 'text',
  72                   'default' => 0,
  73               ),
  74              'secondparameter' => array(
  75                  'type' => PARAM_INT,
  76                  'label' => 'Test Parmater',
  77                  'element_type' => 'text',
  78                  'default' => 0,
  79              ),
  80          ) + parent::section_format_options($foreditform);
  81      }
  82  }