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.

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

return: void
param: array $data

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.

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

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

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

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.

return: null
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.

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

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

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.

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

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

return: float|null
param: float $calculatedvalue

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'

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

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

return: array