Search moodle.org's
Developer Documentation

See Release Notes

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

Runs an analysis of the site.

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

Defines 1 class


Class: analysis  - X-Ref

Runs an analysis of the site.

__construct(\core_analytics\local\analyser\base $analyser, bool $includetarget,\core_analytics\local\analysis\result $result)   X-Ref
Constructor.

param: \core_analytics\local\analyser\base   $analyser
param: bool                                  $includetarget Whether to calculate the target or not.
param: \core_analytics\local\analysis\result $result

run(array $contexts = [])   X-Ref
Runs the analysis.

param: \context[] $contexts Restrict the analysis to these contexts. No context restrictions if null.
return: null

get_processed_analysables()   X-Ref
Get analysables that have been already processed.

return: \stdClass[]

process_analysable(\core_analytics\analysable $analysable)   X-Ref
Processes an analysable

This method returns the general analysable status, an array of files by time splitting method and
an error message if there is any problem.

param: \core_analytics\analysable $analysable
return: \stdClass[] Results objects by time splitting method

process_time_splitting(\core_analytics\local\time_splitting\base $timesplitting,\core_analytics\analysable $analysable, \core_analytics\local\target\base $target)   X-Ref
Processes the analysable samples using the provided time splitting method.

param: \core_analytics\local\time_splitting\base $timesplitting
param: \core_analytics\analysable $analysable
param: \core_analytics\local\target\base $target
return: \stdClass Results object.

calculate(\core_analytics\local\time_splitting\base $timesplitting, array &$sampleids,array $ranges, \core_analytics\local\target\base $target)   X-Ref
Calculates indicators and targets.

param: \core_analytics\local\time_splitting\base $timesplitting
param: array $sampleids
param: array $ranges
param: \core_analytics\local\target\base $target
return: array|null

calculate_indicators(\core_analytics\local\time_splitting\base $timesplitting, array $sampleids,array $ranges)   X-Ref
Calculates indicators.

param: \core_analytics\local\time_splitting\base $timesplitting
param: array $sampleids
param: array $ranges
return: array

fill_dataset(\core_analytics\local\time_splitting\base $timesplitting,array &$dataset, ?array $calculatedtarget = null)   X-Ref
Adds time range indicators and the target to each sample.

This will identify the sample as belonging to a specific range.

param: \core_analytics\local\time_splitting\base $timesplitting
param: array $dataset
param: array|null $calculatedtarget
return: null

update_analysable_analysed_time(array $processedanalysables, int $analysableid)   X-Ref
Updates the analysable analysis time.

param: array $processedanalysables
param: int $analysableid
return: null

fill_firstanalyses_cache(int $modelid, ?int $analysableid = null)   X-Ref
Fills a cache containing the first time each analysable in the provided model was analysed.

param: int $modelid
param: int|null $analysableid
return: null

add_context_metadata(\core_analytics\local\time_splitting\base $timesplitting, array &$dataset,\core_analytics\local\target\base $target)   X-Ref
Adds dataset context info.

The final dataset document will look like this:
----------------------------------------------------
metadata1,metadata2,metadata3,.....
value1, value2, value3,.....

header1,header2,header3,header4,.....
stud1value1,stud1value2,stud1value3,stud1value4,.....
stud2value1,stud2value2,stud2value3,stud2value4,.....
.....
----------------------------------------------------

param: \core_analytics\local\time_splitting\base $timesplitting
param: array $dataset
param: \core_analytics\local\target\base $target
return: null

get_headers(\core_analytics\local\time_splitting\base $timesplitting,\core_analytics\local\target\base $target)   X-Ref
Returns the headers for the csv file based on the indicators and the target.

param: \core_analytics\local\time_splitting\base $timesplitting
param: \core_analytics\local\target\base $target
return: string[]

filter_out_train_samples(array &$sampleids, \core_analytics\local\time_splitting\base $timesplitting)   X-Ref
Filters out samples that have already been used for training.

param: int[] $sampleids
param: \core_analytics\local\time_splitting\base $timesplitting
return: null

filter_out_prediction_samples_and_ranges(array &$sampleids, array &$ranges,\core_analytics\local\time_splitting\base $timesplitting)   X-Ref
Filters out samples that have already been used for prediction.

param: int[] $sampleids
param: array $ranges
param: \core_analytics\local\time_splitting\base $timesplitting
return: \stdClass|null The analytics_predict_samples record or null

get_predict_samples_record(\core_analytics\local\time_splitting\base $timesplitting, int $rangeindex)   X-Ref
Returns a predict samples record.

param: \core_analytics\local\time_splitting\base $timesplitting
param: int                                       $rangeindex
return: \stdClass|false

save_train_samples(array $sampleids, \core_analytics\local\time_splitting\base $timesplitting)   X-Ref
Saves samples that have just been used for training.

param: int[] $sampleids
param: \core_analytics\local\time_splitting\base $timesplitting
return: null

save_prediction_samples(array $sampleids, array $ranges,\core_analytics\local\time_splitting\base $timesplitting, ?\stdClass $predictsamplesrecord = null)   X-Ref
Saves samples that have just been used for prediction.

param: int[] $sampleids
param: array $ranges
param: \core_analytics\local\time_splitting\base $timesplitting
param: \stdClass|null $predictsamplesrecord The existing record or null if there is no record yet.
return: null

init_analysable_analysis(string $timesplittingid, int $analysableid)   X-Ref
Flags the analysable element as in-analysis and stores a lock for it.

param: string $timesplittingid
param: int    $analysableid
return: bool Success or not

clean_time_splitting_id($timesplittingid)   X-Ref
Remove all possibly problematic chars from the time splitting method id (id = its full class name).

param: string $timesplittingid
return: string

finish_analysable_analysis()   X-Ref
Mark the currently analysed analysable+timesplitting as analysed.

return: null

get_insert_batch_size()   X-Ref
Returns the batch size used for insert_records.

This method tries to find the best batch size without getting
into dml internals. Maximum 1000 records to save memory.

return: int