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 - 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   * Class to store data for "hide if" rules for the settings form.
  19   *
  20   * @package    quizaccess_seb
  21   * @author     Dmitrii Metelkin <dmitriim@catalyst-au.net>
  22   * @copyright  2019 Catalyst IT
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace quizaccess_seb;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  /**
  31   * Class to store data for "hide if" rules for the settings form.
  32   *
  33   * @copyright  2020 Catalyst IT
  34   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class hideif_rule {
  37  
  38      /**
  39       * Name of the element to hide.
  40       * @var string
  41       */
  42      protected $element;
  43  
  44      /**
  45       * Name of the element that $element is dependant on.
  46       * @var string
  47       */
  48      protected $dependantname;
  49  
  50      /**
  51       * Condition. E.g. 'eq', 'noteq' and etc.
  52       * @var string
  53       */
  54      protected $condition;
  55  
  56      /**
  57       * Value to check the $condition against.
  58       * @var string
  59       */
  60      protected $dependantvalue;
  61  
  62      /**
  63       * Constructor.
  64       *
  65       * @param string $element Name of the element to hide.
  66       * @param string $dependantname Name of the element that $element is dependant on.
  67       * @param string $condition Condition. E.g. 'eq', 'noteq' and etc.
  68       * @param string $dependantvalue Value to check the $condition against.
  69       */
  70      public function __construct(string $element, string $dependantname, string $condition, string $dependantvalue) {
  71          $this->element = $element;
  72          $this->dependantname = $dependantname;
  73          $this->condition = $condition;
  74          $this->dependantvalue = $dependantvalue;
  75      }
  76  
  77      /**
  78       * Return name of the element to hide.
  79       * @return string
  80       */
  81      public function get_element(): string {
  82          return $this->element;
  83      }
  84  
  85      /**
  86       * Returns name of the element that $element is dependant on.
  87       * @return string
  88       */
  89      public function get_dependantname(): string {
  90          return $this->dependantname;
  91      }
  92  
  93      /**
  94       * Returns condition. E.g. 'eq', 'noteq' and etc
  95       * @return string
  96       */
  97      public function get_condition(): string {
  98          return $this->condition;
  99      }
 100  
 101      /**
 102       * Returns value to check the $condition against.
 103       * @return string
 104       */
 105      public function get_dependantvalue(): string {
 106          return $this->dependantvalue;
 107      }
 108  
 109  }