Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

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