From 43ef30edccff73d5ae8e69a1203c69ed7f19ea15 Mon Sep 17 00:00:00 2001 From: Luuk Verhoeven Date: Fri, 29 Dec 2023 22:19:51 +0100 Subject: [PATCH] Refactor for MOODLE41 & PHP 7.4 --- components/plot/line/plugin.class.php | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/components/plot/line/plugin.class.php b/components/plot/line/plugin.class.php index 06181057..17b2c352 100755 --- a/components/plot/line/plugin.class.php +++ b/components/plot/line/plugin.class.php @@ -75,25 +75,10 @@ public function execute($id, $data, $finalreport) { if ($finalreport) { foreach ($finalreport as $r) { - - $val = 0; - $hash = null; - $hashkeyexists = isset($r[$data->serieid]); - $yaxiskeyexists = isset($r[$data->yaxis]); - - if ($hashkeyexists) { - $hash = md5(strtolower($r[$data->serieid])); - $sname[$hash] = $r[$data->serieid]; - } - - if ($yaxiskeyexists && is_numeric($r[$data->yaxis])) { - $val = $r[$data->yaxis]; - } - - if ($hash !== null) { - $series[$hash][] = $val; - } - + $hash = md5(strtolower($r[$data->serieid] ?? '')); + $sname[$hash] = $r[$data->serieid] ?? null; + $val = (isset($r[$data->yaxis]) && is_numeric($r[$data->yaxis])) ? $r[$data->yaxis] : 0; + $series[$hash][] = $val; $minvalue = ($val < $minvalue) ? $val : $minvalue; $maxvalue = ($val > $maxvalue) ? $val : $maxvalue; }