From ce99f1fa5a1e8ef8c3f8bedd53c071b3e94f1446 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 7 Sep 2017 07:52:56 +0200 Subject: [PATCH] MDL-59657 analytics: No predictions until training is completed --- admin/tool/analytics/model.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/admin/tool/analytics/model.php b/admin/tool/analytics/model.php index b2268f166fe41..6d64c428c6750 100644 --- a/admin/tool/analytics/model.php +++ b/admin/tool/analytics/model.php @@ -161,8 +161,13 @@ // Looks dumb to get a new instance but better be conservative. $model = new \core_analytics\model($model->get_model_obj()); - $predictresults = $model->predict(); - $predictlogs = $model->get_analyser()->get_logs(); + if ($model->is_trained()) { + $predictresults = $model->predict(); + $predictlogs = $model->get_analyser()->get_logs(); + } else { + $predictresults = false; + $predictlogs = array(); + } $renderer = $PAGE->get_renderer('tool_analytics'); echo $renderer->render_get_predictions_results($trainresults, $trainlogs, $predictresults, $predictlogs);