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 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 mod_quiz\question\bank\filter;
  18  
  19  /**
  20   * A custom filter condition for quiz to select question categories.
  21   *
  22   * This is required as quiz will only use ready questions and the count should show according to that.
  23   *
  24   * @package    mod_quiz
  25   * @category   question
  26   * @copyright  2021 Catalyst IT Australia Pty Ltd
  27   * @author     Safat Shahin <safatshahin@catalyst-au.net>
  28   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  29   */
  30  class custom_category_condition extends \core_question\bank\search\category_condition {
  31  
  32      public function display_options() {
  33          global $PAGE;
  34          $displaydata = [];
  35          $catmenu = custom_category_condition_helper::question_category_options($this->contexts, true, 0,
  36              true, -1, false);
  37          $displaydata['categoryselect'] = \html_writer::select($catmenu, 'category', $this->cat, [],
  38              ['class' => 'searchoptions custom-select', 'id' => 'id_selectacategory']);
  39          $displaydata['categorydesc'] = '';
  40          if ($this->category) {
  41              $displaydata['categorydesc'] = $this->print_category_info($this->category);
  42          }
  43          return $PAGE->get_renderer('core_question', 'bank')->render_category_condition($displaydata);
  44      }
  45  }