Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Extra information generated during the analysis by calculable elements.

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

Defines 1 class

calculation_info:: (5 methods):
  add_shared()
  save()
  pull_info()
  get_data_key()
  get_sample_key()


Class: calculation_info  - X-Ref

Extra information generated during the analysis by calculable elements.

The main purpose of this request cache is to allow calculable elements to
store data during their calculations for further use at a later stage efficiently.

add_shared(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.

We store two different arrays so objects that appear multiple times for different samples
appear just once in 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(\core_analytics\calculable $calculable, \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.

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

pull_info(array $predictionrecords)   X-Ref
Pulls the info related to the provided records out from the cache.

Note that this function purges 'calculablesinfo' cache.

param: \stdClass[] $predictionrecords
return: array|false

get_data_key(string $calculableclass, $key)   X-Ref
Gets the key used to store data.

param: string       $calculableclass
param: string|int   $key
return: string

get_sample_key(string $uniquesampleid)   X-Ref
Gets the key used to store samples.

param: string $uniquesampleid
return: string