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.

Abstract base indicator.

Copyright: 2016 David Monllao {@link http://www.davidmonllao.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 197 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: base  - X-Ref

Abstract base indicator.

should_be_displayed($value, $subtype)   X-Ref
Should this value be displayed?

Indicators providing multiple features can be used this method to discard some of them.

param: float $value
param: string $subtype
return: bool

required_sample_data()   X-Ref
Allows indicators to specify data they need.

e.g. A model using courses as samples will not provide users data, but an indicator like
"user is hungry" needs user data.

return: null|string[] Name of the required elements (use the database tablename)

instance()   X-Ref
Returns an instance of the indicator.

Useful to reset cached data.

return: \core_analytics\local\indicator\base

get_max_value()   X-Ref
Returns the maximum value an indicator calculation can return.

return: float

get_min_value()   X-Ref
Returns the minimum value an indicator calculation can return.

return: float

fill_per_analysable_caches(\core_analytics\analysable $analysable)   X-Ref
Hook to allow indicators to pre-fill data that is shared accross time range calculations.

Useful to fill analysable-dependant data that does not depend on the time ranges. Use
instance vars to cache data that can be re-used across samples calculations but changes
between time ranges (indicator instances are reset between time ranges to avoid unexpected
problems).

You are also responsible of emptying previous analysable caches.

param: \core_analytics\analysable $analysable
return: void

calculate($sampleids, $samplesorigin, $starttime = false, $endtime = false, $existingcalculations = array()   X-Ref
Calculates the indicator.

Returns an array of values which size matches $sampleids size.

param: int[] $sampleids
param: string $samplesorigin
param: integer $starttime Limit the calculation to this timestart
param: integer $endtime Limit the calculation to this timeend
param: array $existingcalculations Existing calculations of this indicator, indexed by sampleid.
return: array [0] = [$sampleid => int[]|float[]], [1] = [$sampleid => int|float], [2] = [$sampleid => $sampleid]

validate_calculated_value($calculatedvalue)   X-Ref
Validates the calculated value.

param: float $calculatedvalue
return: true