Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Analysers base class. More...
Public Member Functions | |
__construct ($modelid, core_analytics\local\target\base $target, $indicators, $timesplittings, $options) | |
Constructor method. | |
add_log ($string) | |
Adds a register to the analysis log. | |
check_indicator_requirements (\core_analytics\local\indicator\base $indicator) | |
Checks that this analyser satisfies the provided indicator requirements. | |
get_all_samples (\core_analytics\analysable $analysable) | |
This function returns this analysable list of samples. | |
get_analysables () | |
get_analysables_iterator (?string $action=null, array $contexts=[]) | |
Returns the list of analysable elements available on the site. | |
get_indicators () | |
Getter for indicators. | |
get_labelled_data (array $contexts=[]) | |
Returns labelled data (training and evaluation). | |
get_logs () | |
Returns the analysis logs. | |
get_modelid () | |
Model id getter. | |
get_options () | |
Options getter. | |
get_sample_analysable ($sampleid) | |
Returns the analysable of a sample. | |
get_samples ($sampleids) | |
This function returns the samples data from a list of sample ids. | |
get_samples_origin () | |
Returns the sample's origin in moodle database. | |
get_static_data (array $contexts=[]) | |
Returns indicator calculations as an array. | |
get_target () | |
Returns the analysed target. | |
get_timesplittings () | |
Getter for time splittings. | |
get_unlabelled_data (array $contexts=[]) | |
Returns unlabelled data (prediction). | |
instantiate_indicators () | |
Instantiate the indicators. | |
join_sample_user ($sampletablealias) | |
SQL JOIN from a sample to users table. | |
processes_user_data () | |
Whether the plugin needs user data clearing or not. | |
sample_access_context ($sampleid) | |
Returns the context of a sample. | |
sample_description ($sampleid, $contextid, $sampledata) | |
Describes a sample with a description summary and a renderable (an image for example) | |
Static Public Member Functions | |
static | context_restriction_support () |
Returns an array of context levels that can be used to restrict the contexts used during analysis. | |
static | one_sample_per_analysable () |
Do this analyser's analysables have 1 single sample each? | |
static | potential_context_restrictions (string $query=null) |
Returns the possible contexts used by the analyser. | |
Protected Member Functions | |
check_indicators_requirements () | |
Checks if the analyser satisfies all the model indicators requirements. | |
get_iterator_sql (string $tablename, int $contextlevel, ?string $action=null, ?string $tablealias=null, array $contexts=[]) | |
Get the sql of a default implementation of the iterator. | |
order_sql (?string $fieldname=null, string $order='ASC', ?string $tablealias=null) | |
Returns the order by clause. | |
provided_sample_data () | |
Samples data this analyser provides. | |
Protected Attributes | |
core_analytics local indicator base[] | $indicators |
The model indicators. | |
string[] | $log |
Simple log array. | |
int | $modelid |
array | $options |
Execution options. | |
core_analytics local target base | $target |
The model target. | |
core_analytics local time_splitting base[] | $timesplittings |
Time splitting methods to use. | |
Analysers base class.
core_analytics\local\analyser\base::__construct | ( | $modelid, | |
core_analytics\local\target\base | $target, | ||
$indicators, | |||
$timesplittings, | |||
$options ) |
Constructor method.
int | $modelid | |
core_analytics\local\target\base | $target | |
core_analytics\local\indicator\base[] | $indicators | |
core_analytics\local\time_splitting\base[] | $timesplittings | |
array | $options |
void |
core_analytics\local\analyser\base::add_log | ( | $string | ) |
Adds a register to the analysis log.
string | $string |
void |
core_analytics\local\analyser\base::check_indicator_requirements | ( | \core_analytics\local\indicator\base | $indicator | ) |
Checks that this analyser satisfies the provided indicator requirements.
core_analytics\local\indicator\base | $indicator |
true|string[] | True if all good, missing requirements list otherwise |
|
protected |
Checks if the analyser satisfies all the model indicators requirements.
core_analytics\requirements_exception |
void |
|
static |
Returns an array of context levels that can be used to restrict the contexts used during analysis.
The contexts provided to self\get_analysables_iterator will match these contextlevels.
array | Array of context levels or an empty array if context restriction is not supported. |
Reimplemented in core_analytics\local\analyser\by_course.
|
abstract |
This function returns this analysable list of samples.
core_analytics\analysable | $analysable |
array | array[0] = int[] (sampleids) and array[1] = array (samplesdata) |
core_analytics\local\analyser\base::get_analysables | ( | ) |
|
abstract |
Returns the list of analysable elements available on the site.
A relatively complex SQL query should be set so that we take into account which analysable elements have already been processed and the order in which they have been processed. Helper methods are available to ease to implementation of get_analysables_iterator: get_iterator_sql and order_sql.
string | null | $action | 'prediction', 'training' or null if no specific action needed. |
context[] | $contexts | Only analysables that depend on the provided contexts. All analysables in the system if empty. |
Iterator |
Reimplemented in core\analytics\analyser\users, core_analytics\local\analyser\by_course, and core_analytics\local\analyser\sitewide.
core_analytics\local\analyser\base::get_indicators | ( | ) |
Getter for indicators.
core_analytics\local\indicator\base |
|
protected |
Get the sql of a default implementation of the iterator.
This method only works for analysers that return analysable elements which ids map to a context instance ids.
string | $tablename | The name of the table |
int | $contextlevel | The context level of the analysable |
string | null | $action | |
string | null | $tablealias | The table alias |
context[] | $contexts | Only analysables that depend on the provided contexts. All analysables if empty. |
array | [0] => sql and [1] => params array |
core_analytics\local\analyser\base::get_labelled_data | ( | array | $contexts = [] | ) |
Returns labelled data (training and evaluation).
context[] | $contexts | Restrict the analysis to these contexts. No context restrictions if null. |
stored_file[] |
core_analytics\local\analyser\base::get_logs | ( | ) |
Returns the analysis logs.
string[] |
core_analytics\local\analyser\base::get_modelid | ( | ) |
Model id getter.
int |
core_analytics\local\analyser\base::get_options | ( | ) |
Options getter.
array |
|
abstract |
Returns the analysable of a sample.
int | $sampleid |
core_analytics\analysable |
Reimplemented in core\analytics\analyser\courses, core\analytics\analyser\site_courses, core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
|
abstract |
This function returns the samples data from a list of sample ids.
int[] | $sampleids |
array | array[0] = int[] (sampleids) and array[1] = array (samplesdata) |
Reimplemented in core\analytics\analyser\courses, core\analytics\analyser\site_courses, core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
|
abstract |
Returns the sample's origin in moodle database.
string |
Reimplemented in core\analytics\analyser\courses, core\analytics\analyser\site_courses, core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
core_analytics\local\analyser\base::get_static_data | ( | array | $contexts = [] | ) |
Returns indicator calculations as an array.
context[] | $contexts | Restrict the analysis to these contexts. No context restrictions if null. |
array |
core_analytics\local\analyser\base::get_target | ( | ) |
Returns the analysed target.
core_analytics\local\target\base |
core_analytics\local\analyser\base::get_timesplittings | ( | ) |
Getter for time splittings.
core_analytics\local\time_splitting\base |
core_analytics\local\analyser\base::get_unlabelled_data | ( | array | $contexts = [] | ) |
Returns unlabelled data (prediction).
context[] | $contexts | Restrict the analysis to these contexts. No context restrictions if null. |
stored_file[] |
core_analytics\local\analyser\base::instantiate_indicators | ( | ) |
Instantiate the indicators.
core_analytics\local\indicator\base[] |
core_analytics\local\analyser\base::join_sample_user | ( | $sampletablealias | ) |
SQL JOIN from a sample to users table.
This function should be defined if static\processes_user_data returns true and it is related to analytics API privacy API implementation. It allows the analytics API to identify data associated to users that needs to be deleted or exported.
This function receives the alias of a table with a 'sampleid' field and it should return a SQL join with static\get_samples_origin and with 'user' table. Note that:
Some examples:
static\get_samples_origin() === 'user': JOIN {user} u ON {$sampletablealias}.sampleid = u.id
static\get_samples_origin() === 'role_assignments': JOIN {role_assignments} ra ON {$sampletablealias}.sampleid = ra.userid JOIN {user} u ON u.id = ra.userid
static\get_samples_origin() === 'user_enrolments': JOIN {user_enrolments} ue ON {$sampletablealias}.sampleid = ue.userid JOIN {user} u ON u.id = ue.userid
coding_exception |
string | $sampletablealias | The alias of the table with a sampleid field that will join with this SQL string |
string |
Reimplemented in core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
|
static |
Do this analyser's analysables have 1 single sample each?
Overwrite and return true if your analysables only have one sample. The insights generated by models using this analyser will then include the suggested actions in the notification.
bool |
Reimplemented in core\analytics\analyser\courses, and core\analytics\analyser\users.
|
protected |
Returns the order by clause.
string | null | $fieldname | The field name |
string | $order | 'ASC' or 'DESC' |
string | null | $tablealias | The table alias of the field |
string |
|
static |
Returns the possible contexts used by the analyser.
This method uses separate logic for each context level because to iterate through the list of contexts calling get_context_name for each of them would be expensive in performance terms.
This generic implementation returns all the contexts in the site for the provided context level. Overwrite it for specific restrictions in your analyser.
string | null | $query | Context name filter. |
int[] |
core_analytics\local\analyser\base::processes_user_data | ( | ) |
Whether the plugin needs user data clearing or not.
This is related to privacy. Override this method if your analyser samples have any relation to the 'user' database entity. We need to clean the site from all user-related data if a user request their data to be deleted from the system. A static\provided_sample_data returning 'user' is an indicator that you should be returning true.
bool |
Reimplemented in core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
|
protected |
Samples data this analyser provides.
string[] |
Reimplemented in core\analytics\analyser\courses, core\analytics\analyser\site_courses, core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
|
abstract |
Returns the context of a sample.
moodle/analytics:listinsights will be required at this level to access the sample predictions.
int | $sampleid |
context |
Reimplemented in core\analytics\analyser\courses, core\analytics\analyser\site_courses, core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
|
abstract |
Describes a sample with a description summary and a renderable (an image for example)
int | $sampleid | |
int | $contextid | |
array | $sampledata |
array | array(string, renderable) |
Reimplemented in core\analytics\analyser\courses, core\analytics\analyser\site_courses, core\analytics\analyser\student_enrolments, and core\analytics\analyser\users.
|
protected |
Time splitting methods to use.
Multiple time splitting methods during evaluation and 1 single time splitting method once the model is enabled.