MDL-66091 analytics: Targets choose if there should be a report or not

This commit is contained in:
David Monllaó
2019-09-17 13:58:55 +08:00
parent 21202090f7
commit 486e797c5f
8 changed files with 70 additions and 20 deletions
+4 -1
View File
@@ -484,6 +484,9 @@ class manager {
/**
* 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.
*
* @param \context $context
* @return \core_analytics\model[]
*/
@@ -494,7 +497,7 @@ class manager {
$models = self::get_all_models(true, true, $context);
foreach ($models as $key => $model) {
// Check that it not only have predictions but also generates insights from them.
if (!$model->uses_insights()) {
if (!$model->uses_insights() || !$model->get_target()->link_insights_report()) {
unset($models[$key]);
}
}