Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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  
  18  /**
  19   * Drop down for question categories.
  20   *
  21   * Contains HTML class for a drop down element to select a question category.
  22   *
  23   * @package   core_form
  24   * @copyright 2007 Tim Hunt
  25   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  
  28  global $CFG;
  29  require_once("$CFG->libdir/form/selectgroups.php");
  30  require_once("$CFG->libdir/questionlib.php");
  31  
  32  /**
  33   * Drop down for question categories.
  34   *
  35   * HTML class for a drop down element to select a question category.
  36   *
  37   * @package   core_form
  38   * @category  form
  39   * @copyright 2007 Tim Hunt
  40   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  41   */
  42  class MoodleQuickForm_questioncategory extends MoodleQuickForm_selectgroups {
  43      /** @var array default options for question categories */
  44      var $_options = array('top'=>false, 'currentcat'=>0, 'nochildrenof' => -1);
  45  
  46      /**
  47       * Constructor
  48       *
  49       * @param string $elementName Select name attribute
  50       * @param mixed $elementLabel Label(s) for the select
  51       * @param array $options additional options. Recognised options are courseid, published and
  52       *              only_editable, corresponding to the arguments of question_category_options
  53       *              from moodlelib.php.
  54       * @param mixed $attributes Either a typical HTML attribute string or an associative array
  55       */
  56      public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null) {
  57          parent::__construct($elementName, $elementLabel, array(), $attributes);
  58          $this->_type = 'questioncategory';
  59          if (is_array($options)) {
  60              $this->_options = $options + $this->_options;
  61              $this->loadArrayOptGroups(
  62                          question_category_options($this->_options['contexts'], $this->_options['top'], $this->_options['currentcat'],
  63                                                  false, $this->_options['nochildrenof'], false));
  64          }
  65      }
  66  
  67      /**
  68       * Old syntax of class constructor. Deprecated in PHP7.
  69       *
  70       * @deprecated since Moodle 3.1
  71       */
  72      public function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $options = null, $attributes = null) {
  73          debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
  74          self::__construct($elementName, $elementLabel, $options, $attributes);
  75      }
  76  }