Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | Public Attributes | Static Protected Attributes | List of all members
core_analytics\manager Class Reference

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. More...
 
static cached_models_with_insights (\context $context, int $newmodelid=null)
 Returns the models that generated insights in the provided context. More...
 
static check_can_list_insights (\context $context, bool $return=false)
 Checks that the user can list that context insights. More...
 
static check_can_manage_models ()
 Checks that the user can manage models. More...
 
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. More...
 
static default_mlbackend ()
 Default system backend. More...
 
static get_all_indicators ()
 Return all system indicators. More...
 
static get_all_models ($enabled=false, $trained=false, $predictioncontext=false)
 Returns all system models that match the provided filters. More...
 
static get_all_prediction_processors ()
 Return all system predictions processors. More...
 
static get_all_targets ()
 Return all targets in the system. More...
 
static get_all_time_splittings ()
 Get all available time splitting methods. More...
 
static get_analytics_logstore ()
 Returns the logstore used for analytics. More...
 
static get_declared_target_and_indicators_instances (array $definition)
 Given a model definition, return actual target and indicators instances. More...
 
static get_enabled_time_splitting_methods ()
 Returns the enabled time splitting methods. More...
 
static get_indicator ($fullclassname)
 Returns an instance of the provided indicator. More...
 
static get_indicator_calculations ($analysable, $starttime, $endtime, $samplesorigin)
 Returns this analysable calculations during the provided period. More...
 
static get_models_with_insights (\context $context)
 Returns the models with insights at the provided context. More...
 
static get_potential_context_restrictions (?array $contextlevels=null, string $query=null)
 Return the context restrictions that can be applied to the provided context levels. More...
 
static get_prediction ($predictionid, $requirelogin=false)
 Returns a prediction. More...
 
static get_predictions_processor ($predictionclass=false, $checkisready=true)
 Returns the provided predictions processor class. More...
 
static get_predictions_processor_name (\core_analytics\predictor $predictionsprocessor)
 Returns the name of the provided predictions processor. More...
 
static get_target ($fullclassname)
 Returns the specified target. More...
 
static get_time_splitting ($fullclassname)
 Returns a time splitting method by its classname. More...
 
static get_time_splitting_methods_for_evaluation (bool $all=false)
 Returns the time-splitting methods for model evaluation. More...
 
static is_analytics_enabled ()
 Is analytics enabled globally? More...
 
static is_mlbackend_used ($plugin)
 Whether the provided plugin is used by any model. More...
 
static is_valid ($fullclassname, $baseclass)
 Returns whether a time splitting method is valid or not. More...
 
static load_default_models_for_all_components ()
 Return the list of all the models declared anywhere in this Moodle installation. More...
 
static load_default_models_for_component (string $componentname)
 Return the list of models declared by the given component. More...
 
static model_declaration_identifier (array $model)
 Returns a string uniquely representing the given model declaration. More...
 
static reset_prediction_processors ()
 Resets the cached prediction processors. More...
 
static update_default_models_for_component (string $componentname)
 Check that all the models declared by the component are up to date. More...
 
static validate_models_declaration (array $models)
 Validate the declaration of prediction models according the syntax expected in the component's db folder. More...
 

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 = []
 

Detailed Description

Analytics basic actions manager.

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

Member Function Documentation

◆ add_builtin_models()

static core_analytics\manager::add_builtin_models ( )
static

Used to be used to add models included with the Moodle core.

Deprecated:
Deprecated since Moodle 3.7 (MDL-61667) - Use lib/db/analytics.php instead.
Todo:
Remove this method in Moodle 4.1 (MDL-65186).
Return values
void

◆ cached_models_with_insights()

static core_analytics\manager::cached_models_with_insights ( \context  $context,
int  $newmodelid = null 
)
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.

Exceptions
coding_exception
Parameters
context$context
int | null$newmodelidA new model to add to the list of models with insights in the provided context.
Return values
int[]

◆ check_can_list_insights()

static core_analytics\manager::check_can_list_insights ( \context  $context,
bool  $return = false 
)
static

Checks that the user can list that context insights.

Exceptions
required_capability_exception
Parameters
context$context
bool$returnThe method returns a bool if true.
Return values
void

◆ check_can_manage_models()

static core_analytics\manager::check_can_manage_models ( )
static

Checks that the user can manage models.

Exceptions
required_capability_exception
Return values
void

◆ create_declared_model()

static core_analytics\manager::create_declared_model ( array  $definition)
static

Create the defined model.

Parameters
array$definitionSee self::validate_models_declaration() for the syntax.
Return values
core_analytics

◆ default_mlbackend()

static core_analytics\manager::default_mlbackend ( )
static

Default system backend.

Return values
string

◆ get_all_indicators()

static core_analytics\manager::get_all_indicators ( )
static

Return all system indicators.

Return values
core_analytics

◆ get_all_models()

static core_analytics\manager::get_all_models (   $enabled = false,
  $trained = false,
  $predictioncontext = false 
)
static

Returns all system models that match the provided filters.

Parameters
bool$enabled
bool$trained
context | false$predictioncontext
Return values
core_analytics

◆ get_all_prediction_processors()

static core_analytics\manager::get_all_prediction_processors ( )
static

Return all system predictions processors.

Return values
core_analytics

◆ get_all_targets()

static core_analytics\manager::get_all_targets ( )
static

Return all targets in the system.

Return values
core_analytics

◆ get_all_time_splittings()

static core_analytics\manager::get_all_time_splittings ( )
static

Get all available time splitting methods.

Return values
core_analytics

◆ get_analytics_logstore()

static core_analytics\manager::get_analytics_logstore ( )
static

Returns the logstore used for analytics.

Return values
core

◆ get_declared_target_and_indicators_instances()

static core_analytics\manager::get_declared_target_and_indicators_instances ( array  $definition)
static

Given a model definition, return actual target and indicators instances.

Parameters
array$definitionSee self::validate_models_declaration() for the syntax.
Return values
array[0] => target instance, [1] => array of indicators instances

◆ get_enabled_time_splitting_methods()

static core_analytics\manager::get_enabled_time_splitting_methods ( )
static

Returns the enabled time splitting methods.

Deprecated:
since Moodle 3.7
Todo:
MDL-65086 This will be deleted in Moodle 4.1
See also
core_analytics\manager::get_time_splitting_methods_for_evaluation
Return values
core_analytics

◆ get_indicator()

static core_analytics\manager::get_indicator (   $fullclassname)
static

Returns an instance of the provided indicator.

Parameters
string$fullclassname
Return values
core_analytics

◆ get_indicator_calculations()

static core_analytics\manager::get_indicator_calculations (   $analysable,
  $starttime,
  $endtime,
  $samplesorigin 
)
static

Returns this analysable calculations during the provided period.

Parameters
core_analytics\analysable$analysable
int$starttime
int$endtime
string$samplesoriginThe samples origin as sampleid is not unique across models.
Return values
array

◆ get_models_with_insights()

static core_analytics\manager::get_models_with_insights ( \context  $context)
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.

Parameters
context$context
Return values
core_analytics

◆ get_potential_context_restrictions()

static core_analytics\manager::get_potential_context_restrictions ( ?array  $contextlevels = null,
string  $query = null 
)
static

Return the context restrictions that can be applied to the provided context levels.

Exceptions
coding_exception
Parameters
array | null$contextlevelsThe list of context levels provided by the analyser. Null if all of them.
string | null$query
Return values
arrayAssociative array with contextid as key and the short version of the context name as value.

◆ get_prediction()

static core_analytics\manager::get_prediction (   $predictionid,
  $requirelogin = false 
)
static

Returns a prediction.

Parameters
int$predictionid
bool$requirelogin
Return values
arrayarray($model, $prediction, $context)

◆ get_predictions_processor()

static core_analytics\manager::get_predictions_processor (   $predictionclass = false,
  $checkisready = true 
)
static

Returns the provided predictions processor class.

Parameters
false | string$predictionclassReturns the system default processor if false
bool$checkisready
Return values
core_analytics

◆ get_predictions_processor_name()

static core_analytics\manager::get_predictions_processor_name ( \core_analytics\predictor  $predictionsprocessor)
static

Returns the name of the provided predictions processor.

Parameters
core_analytics\predictor$predictionsprocessor
Return values
string

◆ get_target()

static core_analytics\manager::get_target (   $fullclassname)
static

Returns the specified target.

Parameters
mixed$fullclassname
Return values
core_analytics

◆ get_time_splitting()

static core_analytics\manager::get_time_splitting (   $fullclassname)
static

Returns a time splitting method by its classname.

Parameters
string$fullclassname
Return values
core_analytics

◆ get_time_splitting_methods_for_evaluation()

static core_analytics\manager::get_time_splitting_methods_for_evaluation ( bool  $all = false)
static

Returns the time-splitting methods for model evaluation.

Parameters
bool$allReturn all the time-splitting methods that can potentially be used for evaluation or the default ones.
Return values
core_analytics

◆ is_analytics_enabled()

static core_analytics\manager::is_analytics_enabled ( )
static

Is analytics enabled globally?

return bool

◆ is_mlbackend_used()

static core_analytics\manager::is_mlbackend_used (   $plugin)
static

Whether the provided plugin is used by any model.

Parameters
string$plugin
Return values
bool

◆ is_valid()

static core_analytics\manager::is_valid (   $fullclassname,
  $baseclass 
)
static

Returns whether a time splitting method is valid or not.

Parameters
string$fullclassname
string$baseclass
Return values
bool

◆ load_default_models_for_all_components()

static core_analytics\manager::load_default_models_for_all_components ( )
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.

Return values
arrayindexed by the frankenstyle component

◆ load_default_models_for_component()

static core_analytics\manager::load_default_models_for_component ( string  $componentname)
static

Return the list of models declared by the given component.

Parameters
string$componentnameThe name of the component to load models for.
Exceptions
coding_exceptionException thrown in case of invalid syntax.
Return values
arrayThe $models description array.

◆ model_declaration_identifier()

static core_analytics\manager::model_declaration_identifier ( array  $model)
static

Returns a string uniquely representing the given model declaration.

Parameters
array$modelModel declaration
Return values
stringcomplying with PARAM_ALPHANUM rules and starting with an 'id' prefix

◆ reset_prediction_processors()

static core_analytics\manager::reset_prediction_processors ( )
static

Resets the cached prediction processors.

Return values
null

◆ update_default_models_for_component()

static core_analytics\manager::update_default_models_for_component ( string  $componentname)
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.

Parameters
string$componentnameThe name of the component to load models for.
Return values
arraycore_analytics\model[] List of actually created models.

◆ validate_models_declaration()

static core_analytics\manager::validate_models_declaration ( array  $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, ], ];

Parameters
array$modelsList of declared models.
Exceptions
coding_exceptionException thrown in case of invalid syntax.

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