Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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   * Test indicator.
  19   *
  20   * @package   core_analytics
  21   * @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Test indicator.
  29   *
  30   * @package   core_analytics
  31   * @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
  32   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33   */
  34  class test_indicator_discrete extends \core_analytics\local\indicator\discrete {
  35  
  36      /**
  37       * Returns the name.
  38       *
  39       * If there is a corresponding '_help' string this will be shown as well.
  40       *
  41       * @return \lang_string
  42       */
  43      public static function get_name() : \lang_string {
  44          // Using a string that exists and contains a corresponding '_help' string.
  45          return new \lang_string('allowstealthmodules');
  46      }
  47  
  48      /**
  49       * The different classes this discrete indicator provides.
  50       * @return [type] [description]
  51       */
  52      protected static function get_classes() {
  53          return [0, 1, 2, 3, 4];
  54      }
  55  
  56      /**
  57       * Just for testing.
  58       *
  59       * @param  float $value
  60       * @param  string $subtype
  61       * @return string
  62       */
  63      public function get_calculation_outcome($value, $subtype = false) {
  64          return self::OUTCOME_OK;
  65      }
  66  
  67      /**
  68       * Custom indicator calculated value display as otherwise we would display meaningless numbers to users.
  69       *
  70       * @param  float  $value
  71       * @param  string $subtype
  72       * @return string
  73       */
  74      public function get_display_value($value, $subtype = false) {
  75          return $value;
  76      }
  77  
  78      /**
  79       * calculate_sample
  80       *
  81       * @param int $sampleid
  82       * @param string $sampleorigin
  83       * @param int $starttime
  84       * @param int $endtime
  85       * @return float
  86       */
  87      protected function calculate_sample($sampleid, $sampleorigin, $starttime = false, $endtime = false) {
  88          return 4;
  89      }
  90  }