Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Analytics basic actions manager. More...
Static Public Member Functions | |
static | add_builtin_models () |
Used to be used to add models included with the Moodle core. | |
static | cached_models_with_insights (\context $context, int $newmodelid=null) |
Returns the models that generated insights in the provided context. | |
static | check_can_list_insights (\context $context, bool $return=false) |
Checks that the user can list that context insights. | |
static | check_can_manage_models () |
Checks that the user can manage models. | |
static | cleanup () |
Cleans up analytics db tables that do not directly depend on analysables that may have been deleted. | |
static | create_declared_model (array $definition) |
Create the defined model. | |
static | default_mlbackend () |
Default system backend. | |
static | get_all_indicators () |
Return all system indicators. | |
static | get_all_models ($enabled=false, $trained=false, $predictioncontext=false) |
Returns all system models that match the provided filters. | |
static | get_all_prediction_processors () |
Return all system predictions processors. | |
static | get_all_targets () |
Return all targets in the system. | |
static | get_all_time_splittings () |
Get all available time splitting methods. | |
static | get_analytics_logstore () |
Returns the logstore used for analytics. | |
static | get_declared_target_and_indicators_instances (array $definition) |
Given a model definition, return actual target and indicators instances. | |
static | get_enabled_time_splitting_methods () |
static | get_indicator ($fullclassname) |
Returns an instance of the provided indicator. | |
static | get_indicator_calculations ($analysable, $starttime, $endtime, $samplesorigin) |
Returns this analysable calculations during the provided period. | |
static | get_models_with_insights (\context $context) |
Returns the models with insights at the provided context. | |
static | get_potential_context_restrictions (?array $contextlevels=null, string $query=null) |
Return the context restrictions that can be applied to the provided context levels. | |
static | get_prediction ($predictionid, $requirelogin=false) |
Returns a prediction. | |
static | get_predictions_processor ($predictionclass=false, $checkisready=true) |
Returns the provided predictions processor class. | |
static | get_predictions_processor_name (\core_analytics\predictor $predictionsprocessor) |
Returns the name of the provided predictions processor. | |
static | get_target ($fullclassname) |
Returns the specified target. | |
static | get_time_splitting ($fullclassname) |
Returns a time splitting method by its classname. | |
static | get_time_splitting_methods_for_evaluation (bool $all=false) |
Returns the time-splitting methods for model evaluation. | |
static | is_analytics_enabled () |
Is analytics enabled globally? | |
static | is_mlbackend_used ($plugin) |
Whether the provided plugin is used by any model. | |
static | is_valid ($fullclassname, $baseclass) |
Returns whether a time splitting method is valid or not. | |
static | load_default_models_for_all_components () |
Return the list of all the models declared anywhere in this Moodle installation. | |
static | load_default_models_for_component (string $componentname) |
Return the list of models declared by the given component. | |
static | model_declaration_identifier (array $model) |
Returns a string uniquely representing the given model declaration. | |
static | reset_prediction_processors () |
Resets the cached prediction processors. | |
static | update_default_models_for_component (string $componentname) |
Check that all the models declared by the component are up to date. | |
static | validate_models_declaration (array $models) |
Validate the declaration of prediction models according the syntax expected in the component's db folder. | |
Public Attributes | |
const | ANALYTICS_FILENAME = 'db/analytics.php' |
Name of the file where components declare their models. | |
const | DEFAULT_MLBACKEND = '\mlbackend_php\processor' |
Default mlbackend. | |
Static Protected Attributes | |
static core_analytics local indicator base[] | $allindicators = null |
static core_analytics local target base[] | $alltargets = null |
static core_analytics local time_splitting base[] | $alltimesplittings = null |
static core_analytics predictor[] | $predictionprocessors = [] |
Analytics basic actions manager.
|
static |
|
static |
Returns the models that generated insights in the provided context.
It can also be used to add new models to the context.
Note that if you use this function with $newmodelid is the caller responsibility to ensure that the provided model id generated insights for the provided context.
coding_exception |
context | $context | |
int | null | $newmodelid | A new model to add to the list of models with insights in the provided context. |
int[] |
|
static |
Checks that the user can list that context insights.
required_capability_exception |
context | $context | |
bool | $return | The method returns a bool if true. |
void |
|
static |
|
static |
Create the defined model.
array | $definition | See self::validate_models_declaration() for the syntax. |
core_analytics\model |
|
static |
Default system backend.
string |
|
static |
Return all system indicators.
core_analytics\local\indicator\base[] |
|
static |
Returns all system models that match the provided filters.
bool | $enabled | |
bool | $trained | |
context | false | $predictioncontext |
core_analytics\model[] |
|
static |
Return all system predictions processors.
core_analytics\predictor[] |
|
static |
Return all targets in the system.
core_analytics\local\target\base[] |
|
static |
Get all available time splitting methods.
core_analytics\local\time_splitting\base[] |
|
static |
Returns the logstore used for analytics.
core\log\sql_reader|false | False if no log stores are enabled. |
|
static |
Given a model definition, return actual target and indicators instances.
array | $definition | See self::validate_models_declaration() for the syntax. |
array | [0] => target instance, [1] => array of indicators instances |
|
static |
|
static |
Returns an instance of the provided indicator.
string | $fullclassname |
core_analytics\local\indicator\base|false | False if it is not valid. |
|
static |
Returns this analysable calculations during the provided period.
core_analytics\analysable | $analysable | |
int | $starttime | |
int | $endtime | |
string | $samplesorigin | The samples origin as sampleid is not unique across models. |
array |
|
static |
Returns the models with insights at the provided context.
Note that this method is used for display purposes. It filters out models whose insights are not linked from the reports page.
context | $context |
core_analytics\model[] |
|
static |
Return the context restrictions that can be applied to the provided context levels.
coding_exception |
array | null | $contextlevels | The list of context levels provided by the analyser. Null if all of them. |
string | null | $query |
array | Associative array with contextid as key and the short version of the context name as value. |
|
static |
Returns a prediction.
int | $predictionid | |
bool | $requirelogin |
array | array($model, $prediction, $context) |
|
static |
Returns the provided predictions processor class.
false | string | $predictionclass | Returns the system default processor if false |
bool | $checkisready |
core_analytics\predictor |
|
static |
Returns the name of the provided predictions processor.
core_analytics\predictor | $predictionsprocessor |
string |
|
static |
Returns the specified target.
mixed | $fullclassname |
core_analytics\local\target\base|false | False if it is not valid |
|
static |
Returns a time splitting method by its classname.
string | $fullclassname |
core_analytics\local\time_splitting\base|false | False if it is not valid. |
|
static |
Returns the time-splitting methods for model evaluation.
bool | $all | Return all the time-splitting methods that can potentially be used for evaluation or the default ones. |
core_analytics\local\time_splitting\base[] |
|
static |
Is analytics enabled globally?
return bool
|
static |
Whether the provided plugin is used by any model.
string | $plugin |
bool |
|
static |
Returns whether a time splitting method is valid or not.
string | $fullclassname | |
string | $baseclass |
bool |
|
static |
Return the list of all the models declared anywhere in this Moodle installation.
Models defined by the core and core subsystems come first, followed by those provided by plugins.
array | indexed by the frankenstyle component |
|
static |
Return the list of models declared by the given component.
string | $componentname | The name of the component to load models for. |
coding_exception | Exception thrown in case of invalid syntax. |
array | The $models description array. |
|
static |
Returns a string uniquely representing the given model declaration.
array | $model | Model declaration |
string | complying with PARAM_ALPHANUM rules and starting with an 'id' prefix |
|
static |
Resets the cached prediction processors.
null |
|
static |
Check that all the models declared by the component are up to date.
This is intended to be called during the installation / upgrade to automatically create missing models.
string | $componentname | The name of the component to load models for. |
array | core_analytics\model[] List of actually created models. |
|
static |
Validate the declaration of prediction models according the syntax expected in the component's db folder.
The expected structure looks like this:
[ [ 'target' => 'fully\qualified\name\of\the\target\class', 'indicators' => [ 'fully\qualified\name\of\the\first\indicator', 'fully\qualified\name\of\the\second\indicator', ], 'timesplitting' => 'optional\name\of\the\time_splitting\class', 'enabled' => true, ], ];
array | $models | List of declared models. |
coding_exception | Exception thrown in case of invalid syntax. |