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.

Calculable dataset items abstract class.

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

Defines 1 class


Class: calculable  - X-Ref

Calculable dataset items abstract class.

get_id()   X-Ref
The class id is the calculable class full qualified class name.

return: string

add_sample_data($data)   X-Ref
add_sample_data

param: array $data
return: void

clear_sample_data()   X-Ref
clear_sample_data

return: void

get_display_value($value, $subtype = false)   X-Ref
Returns the visible value of the calculated value.

param: float $value
param: string|false $subtype
return: string

retrieve($elementname, $sampleid)   X-Ref
Retrieve the specified element associated to $sampleid.

param: string $elementname
param: int $sampleid
return: \stdClass|false An \stdClass object or false if it can not be found.

add_shared_calculation_info(int $sampleid, array $info)   X-Ref
Adds info related to the current calculation for later use when generating insights.

Note that the data in $info array is reused across multiple samples, if you want to add data just for this
sample you can use the sample id as key.

Please, note that you should be careful with how much data you add here as it can kill the server memory.

param: int      $sampleid       The sample id this data is associated with
param: array    $info           The data. Indexed by an id unique across the site. E.g. an activity id.
return: null

save_calculation_info(\core_analytics\local\time_splitting\base $timesplitting, int $rangeindex)   X-Ref
Stores in MUC the previously added data and it associates it to the provided $calculable.

Flagged as final as we don't want people to extend this, it is likely to be moved to \core_analytics\calculable

param: \core_analytics\local\time_splitting\base $timesplitting
param: int                                       $rangeindex
return: null

get_time_range_weeks_number($starttime, $endtime)   X-Ref
Returns the number of weeks a time range contains.

Useful for calculations that depend on the time range duration. Note that it returns
a float, rounding the float may lead to inaccurate results.

param: int $starttime
param: int $endtime
return: float

limit_value($calculatedvalue)   X-Ref
Limits the calculated value to the minimum and maximum values.

param: float $calculatedvalue
return: float|null

classify_value($value, $ranges)   X-Ref
Classifies the provided value into the provided range according to the ranges predicates.

Use:
- eq as 'equal'
- ne as 'not equal'
- lt as 'lower than'
- le as 'lower or equal than'
- gt as 'greater than'
- ge as 'greater or equal than'

param: int|float $value
param: array $ranges e.g. [ ['lt', 20], ['ge', 20] ]
return: float

array_merge_recursive_keep_keys()   X-Ref
Merges arrays recursively keeping the same keys the original arrays have.

return: array