Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_analytics\analysis Class Reference

Runs an analysis of the site. More...

Public Member Functions

 __construct (\core_analytics\local\analyser\base $analyser, bool $includetarget, core_analytics\local\analysis\result $result)
 Constructor.
 
 calculate (\core_analytics\local\time_splitting\base $timesplitting, array &$sampleids, array $ranges, core_analytics\local\target\base $target)
 Calculates indicators and targets.
 
 get_headers (\core_analytics\local\time_splitting\base $timesplitting, core_analytics\local\target\base $target)
 Returns the headers for the csv file based on the indicators and the target.
 
 process_analysable (\core_analytics\analysable $analysable)
 Processes an analysable.
 
 run (array $contexts=[])
 Runs the analysis.
 

Static Public Member Functions

static clean_time_splitting_id ($timesplittingid)
 Remove all possibly problematic chars from the time splitting method id (id = its full class name).
 
static fill_firstanalyses_cache (int $modelid, ?int $analysableid=null)
 Fills a cache containing the first time each analysable in the provided model was analysed.
 

Protected Member Functions

 add_context_metadata (\core_analytics\local\time_splitting\base $timesplitting, array &$dataset, core_analytics\local\target\base $target)
 Adds dataset context info.
 
 calculate_indicators (\core_analytics\local\time_splitting\base $timesplitting, array $sampleids, array $ranges)
 Calculates indicators.
 
 fill_dataset (\core_analytics\local\time_splitting\base $timesplitting, array &$dataset, ?array $calculatedtarget=null)
 Adds time range indicators and the target to each sample.
 
 filter_out_prediction_samples_and_ranges (array &$sampleids, array &$ranges, core_analytics\local\time_splitting\base $timesplitting)
 Filters out samples that have already been used for prediction.
 
 filter_out_train_samples (array &$sampleids, core_analytics\local\time_splitting\base $timesplitting)
 Filters out samples that have already been used for training.
 
 get_processed_analysables ()
 Get analysables that have been already processed.
 
 process_time_splitting (\core_analytics\local\time_splitting\base $timesplitting, core_analytics\analysable $analysable, core_analytics\local\target\base $target)
 Processes the analysable samples using the provided time splitting method.
 
 save_prediction_samples (array $sampleids, array $ranges, core_analytics\local\time_splitting\base $timesplitting, ?\stdClass $predictsamplesrecord=null)
 Saves samples that have just been used for prediction.
 
 save_train_samples (array $sampleids, core_analytics\local\time_splitting\base $timesplitting)
 Saves samples that have just been used for training.
 
 update_analysable_analysed_time (array $processedanalysables, int $analysableid)
 Updates the analysable analysis time.
 

Detailed Description

Runs an analysis of the site.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_analytics\analysis::__construct ( \core_analytics\local\analyser\base $analyser,
bool $includetarget,
core_analytics\local\analysis\result $result )

Constructor.

Parameters
core_analytics\local\analyser\base$analyser
bool$includetargetWhether to calculate the target or not.
core_analytics\local\analysis\result$result

Member Function Documentation

◆ add_context_metadata()

core_analytics\analysis::add_context_metadata ( \core_analytics\local\time_splitting\base $timesplitting,
array & $dataset,
core_analytics\local\target\base $target )
protected

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,.....

.....

Parameters
core_analytics\local\time_splitting\base$timesplitting
array$dataset
core_analytics\local\target\base$target
Return values
null

◆ calculate()

core_analytics\analysis::calculate ( \core_analytics\local\time_splitting\base $timesplitting,
array & $sampleids,
array $ranges,
core_analytics\local\target\base $target )

Calculates indicators and targets.

Parameters
core_analytics\local\time_splitting\base$timesplitting
array$sampleids
array$ranges
core_analytics\local\target\base$target
Return values
array|null

◆ calculate_indicators()

core_analytics\analysis::calculate_indicators ( \core_analytics\local\time_splitting\base $timesplitting,
array $sampleids,
array $ranges )
protected

Calculates indicators.

Parameters
core_analytics\local\time_splitting\base$timesplitting
array$sampleids
array$ranges
Return values
array

◆ clean_time_splitting_id()

static core_analytics\analysis::clean_time_splitting_id ( $timesplittingid)
static

Remove all possibly problematic chars from the time splitting method id (id = its full class name).

Parameters
string$timesplittingid
Return values
string

◆ fill_dataset()

core_analytics\analysis::fill_dataset ( \core_analytics\local\time_splitting\base $timesplitting,
array & $dataset,
?array $calculatedtarget = null )
protected

Adds time range indicators and the target to each sample.

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

Parameters
core_analytics\local\time_splitting\base$timesplitting
array$dataset
array | null$calculatedtarget
Return values
null

◆ fill_firstanalyses_cache()

static core_analytics\analysis::fill_firstanalyses_cache ( int $modelid,
?int $analysableid = null )
static

Fills a cache containing the first time each analysable in the provided model was analysed.

Parameters
int$modelid
int | null$analysableid
Return values
null

◆ filter_out_prediction_samples_and_ranges()

core_analytics\analysis::filter_out_prediction_samples_and_ranges ( array & $sampleids,
array & $ranges,
core_analytics\local\time_splitting\base $timesplitting )
protected

Filters out samples that have already been used for prediction.

Parameters
int[]$sampleids
array$ranges
core_analytics\local\time_splitting\base$timesplitting
Return values
stdClass|nullThe analytics_predict_samples record or null

◆ filter_out_train_samples()

core_analytics\analysis::filter_out_train_samples ( array & $sampleids,
core_analytics\local\time_splitting\base $timesplitting )
protected

Filters out samples that have already been used for training.

Parameters
int[]$sampleids
core_analytics\local\time_splitting\base$timesplitting
Return values
null

◆ get_headers()

core_analytics\analysis::get_headers ( \core_analytics\local\time_splitting\base $timesplitting,
core_analytics\local\target\base $target )

Returns the headers for the csv file based on the indicators and the target.

Parameters
core_analytics\local\time_splitting\base$timesplitting
core_analytics\local\target\base$target
Return values
string[]

◆ get_processed_analysables()

core_analytics\analysis::get_processed_analysables ( )
protected

Get analysables that have been already processed.

Return values
stdClass[]

◆ process_analysable()

core_analytics\analysis::process_analysable ( \core_analytics\analysable $analysable)

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.

Parameters
core_analytics\analysable$analysable
Return values
stdClass[]Results objects by time splitting method

◆ process_time_splitting()

core_analytics\analysis::process_time_splitting ( \core_analytics\local\time_splitting\base $timesplitting,
core_analytics\analysable $analysable,
core_analytics\local\target\base $target )
protected

Processes the analysable samples using the provided time splitting method.

Parameters
core_analytics\local\time_splitting\base$timesplitting
core_analytics\analysable$analysable
core_analytics\local\target\base$target
Return values
stdClassResults object.

◆ run()

core_analytics\analysis::run ( array $contexts = [])

Runs the analysis.

Parameters
context[]$contextsRestrict the analysis to these contexts. No context restrictions if null.
Return values
null

◆ save_prediction_samples()

core_analytics\analysis::save_prediction_samples ( array $sampleids,
array $ranges,
core_analytics\local\time_splitting\base $timesplitting,
?\stdClass $predictsamplesrecord = null )
protected

Saves samples that have just been used for prediction.

Parameters
int[]$sampleids
array$ranges
core_analytics\local\time_splitting\base$timesplitting
stdClass | null$predictsamplesrecordThe existing record or null if there is no record yet.
Return values
null

◆ save_train_samples()

core_analytics\analysis::save_train_samples ( array $sampleids,
core_analytics\local\time_splitting\base $timesplitting )
protected

Saves samples that have just been used for training.

Parameters
int[]$sampleids
core_analytics\local\time_splitting\base$timesplitting
Return values
null

◆ update_analysable_analysed_time()

core_analytics\analysis::update_analysable_analysed_time ( array $processedanalysables,
int $analysableid )
protected

Updates the analysable analysis time.

Parameters
array$processedanalysables
int$analysableid
Return values
null

The documentation for this class was generated from the following file: