1 This files describes API changes in analytics sub system,
2 information provided here is intended especially for developers.
6 * "Time-splitting method" have been replaced by "Analysis interval" for the language strings that are
7 displayed in the Moodle UI. The name of several time-splitting methods have been updated according
8 to the new description of the field.
9 * A new target::can_use_timesplitting method must be implemented to discard time-splitting methods that can not
11 * Targets can now implement get_insight_body and get_insight_body_for_prediction to set the body of the insight.
12 * Indicators can add information about calculated values by calling add_shared_calculation_info(). This
13 data is later available for targets in get_insight_body_for_prediction(), it can be accessed
14 appending ':extradata' to the indicator name (e.g. $sampledata['\mod_yeah\analytics\indicator\ou:extradata')
15 * A new \core_analytics\local\time_splitting\past_periodic abstract class has been added. Time-splitting
16 methods extending \core_analytics\local\time_splitting\periodic directly should be extending past_periodic
17 now. 'periodic' can still be directly extended by implementing get_next_range and get_first_start methods.
18 * Targets can now specify a list of bulk actions in bulk_actions(). core_analytics\prediction_action is now
19 extending core_analytics\action and a new core_analytics\bulk_action class has been added. Actions can now
20 specify a type in its constructor: core_analytics\action::TYPE_POSITIVE, TYPE_NEUTRAL or TYPE_NEGATIVE. A list
21 of default bulk actions is available in \core_analytics\default_bulk_actions.
22 * The default suggested actions provided to users changed:
23 * For targets with one single sample per analysable (e.g. upcoming activities due) the default actions are
24 Useful and Not useful.
25 * For targets with multiple samples per analysable (e.g. students at risk) the default actions are
26 Accept, Not applicable and Incorrectly flagged.
27 * The suggested actions for the existing models have been reworded:
28 * Predictions flagged as "Acknowledged" in models whose targets use analysers that provide one sample per
29 analysable (e.g. upcoming activities due) have been updated to "Useful" flag.
30 * Predictions flagged as "Not useful" in models whose targets use analysers that provide multiple samples
31 per analysable (e.g. students at risk or no teaching) have been updated to "Incorrectly flagged".
32 * \core_analytics\predictor::delete_output_dir has a new 2nd parameter, $uniquemodelid.
33 * Analyser's get_analysables_iterator and get_iterator_sql have a new $contexts parameter to limit the returned analysables to
34 the ones that depend on the provided contexts.
35 * Analysers can implement a context_restriction_support() method to restrict models to a subset of the
36 contents in the site. Only CONTEXT_COURSE and CONTEXT_COURSECAT are supported.
40 * \core_analytics\regressor::evaluate_regression and \core_analytics\classifier::evaluate_classification
41 have been updated to include a new $trainedmodeldir param. This new param will be used to evaluate the
42 existing trained model.
43 * Plugins and core subsystems can now declare default prediction models by describing them in
44 their db/analytics.php file. Models should not be created manually via the db/install.php
46 * The method \core_analytics\manager::add_builtin_models() has been deprecated. The functionality
47 has been replaced with automatic update of models provided by the core moodle component. There
48 is no need to call this method explicitly any more. Instead, adding new models can be achieved
49 by updating the lib/db/analytics.php file and bumping the core version.
50 * \core_analytics\model::execute_prediction_callbacks now returns an array with both sample's contexts
51 and the prediction records.
52 * \core_analytics\model::export() now expects the renderer instance as an argument.
53 * Time splitting methods:
54 * \core_analytics\local\time_splitting\base::append_rangeindex and
55 \core_analytics\local\time_splitting\base::infer_sample_info are now marked as final and can not
57 * Can now overwrite include_range_info_in_training_data() and
58 get_training_ranges() methods. They can be used to create time splitting methods with a pre-defined
60 * Can now overwrite cache_indicator_calculations(). You should return false if the time frames generated
61 by your time-splitting method are unique and / or can hardly be reused by further models.
62 * Can now overwrite valid_for_evaluation(). You can return false if the time-splitting method can not be
63 used to evaluate prediction models or if it does not make sense to evaluate prediction models with it,
64 as for example upcoming_periodic children classes.
65 * \core_analytics\local\analyser\base::get_most_recent_prediction_range has been moved to
66 \core_analytics\local\time_splitting\base::get_most_recent_prediction_range and it is not overwritable
67 by time splitting methods.
69 * The visibility of the following methods must now be public: ignored_predicted_classes()
70 and get_insights_users()
71 * Prediction_actions() has now a 3rd parameter $isinsightuser. This parameter is true
72 when we are listing actions for the user that will receives the insight.
73 * Can now implement a always_update_analysis_time() method so analysable elements' timeanalysed is
74 only updated when analysable elements have been successfully evaluated. It is useful for lightweight targets.
75 * Can not implement two new methods to tune the insights generated by the model: get_insight_subject()
76 and get_insight_context_url().
78 * The visibility of get_all_samples() method must now be public.
79 * get_analysables() method has been deprecated in favour of a new get_analysables_interator()
80 for performance reasons.
81 * Can overwrite a new one_sample_per_analysable() method if the analysables they use only have
82 one sample. The insights generated by models will then include the suggested actions in
87 * There are two new methods for analysers, processes_user_data() and join_sample_user(). You
88 need to overwrite them if your analyser uses user data. As a general statement, you should
89 overwrite these new methods if your samples return 'user' data. These new methods are used
90 for analytics' privacy API implementation.