From 3592b64ac1309e04dd1fac63ac16b4405049f80e Mon Sep 17 00:00:00 2001 From: David Monllao Date: Mon, 14 Aug 2017 15:12:27 +0200 Subject: [PATCH] MDL-59265 report_insights: Fix PHP notice when no predictions --- report/insights/classes/output/insights_list.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/report/insights/classes/output/insights_list.php b/report/insights/classes/output/insights_list.php index 71d7fedf6f9..3f67c4adc87 100644 --- a/report/insights/classes/output/insights_list.php +++ b/report/insights/classes/output/insights_list.php @@ -91,12 +91,16 @@ class insights_list implements \renderable, \templatable { $total = 0; if ($this->model->uses_insights()) { - list($total, $predictions) = $this->model->get_predictions($this->context, $this->page, $this->perpage); + $predictionsdata = $this->model->get_predictions($this->context, $this->page, $this->perpage); $data->insights = array(); - foreach ($predictions as $prediction) { - $insightrenderable = new \report_insights\output\insight($prediction, $this->model, true); - $data->insights[] = $insightrenderable->export_for_template($output); + if ($predictionsdata) { + list($total, $predictions) = $predictionsdata; + + foreach ($predictions as $prediction) { + $insightrenderable = new \report_insights\output\insight($prediction, $this->model, true); + $data->insights[] = $insightrenderable->export_for_template($output); + } } if (empty($data->insights) && $this->page == 0) {