From c09f058462d7f61b43fc137caca3d92c9b5cf6d9 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 30 Nov 2016 11:33:13 +1300 Subject: [PATCH] Tidy up coding violations in fix for #225 --- classes/summary.php | 4 +++- renderer.php | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/classes/summary.php b/classes/summary.php index 15c38d8..1001fb3 100644 --- a/classes/summary.php +++ b/classes/summary.php @@ -289,9 +289,11 @@ class mod_attendance_summary { {$where} GROUP BY atl.studentid, sts.setnumber, sts.acronym"; $this->userstakensessionsbyacronym = array(); - foreach ($DB->get_recordset_sql($sql, $params) AS $rec) { + $records = $DB->get_recordset_sql($sql, $params); + foreach ($records as $rec) { $this->userstakensessionsbyacronym[$rec->userid][$rec->setnumber][$rec->acronym] = $rec->numtakensessions; } + $records->close(); } /** diff --git a/renderer.php b/renderer.php index 467424b..cba7e5c 100644 --- a/renderer.php +++ b/renderer.php @@ -900,7 +900,7 @@ class mod_attendance_renderer extends plugin_renderer_base { } $setnumber = -1; - foreach ($reportdata->statuses AS $sts) { + foreach ($reportdata->statuses as $sts) { if ($sts->setnumber != $setnumber) { $colclass = empty($colclass) ? 'columncontrast' : null; $setnumber = $sts->setnumber; @@ -978,9 +978,12 @@ class mod_attendance_renderer extends plugin_renderer_base { $usersummary = $reportdata->summary->get_taken_sessions_summary_for($user->id); } - foreach ($reportdata->statuses AS $sts) { - $row->cells[] = isset($usersummary->userstakensessionsbyacronym[$sts->setnumber][$sts->acronym]) ? - $usersummary->userstakensessionsbyacronym[$sts->setnumber][$sts->acronym] : 0; + foreach ($reportdata->statuses as $sts) { + if (isset($usersummary->userstakensessionsbyacronym[$sts->setnumber][$sts->acronym])) { + $row->cells[] = $usersummary->userstakensessionsbyacronym[$sts->setnumber][$sts->acronym]; + } else { + $row->cells[] = 0; + } } $row->cells[] = $usersummary->numtakensessions; @@ -1038,7 +1041,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $cell->style = 'white-space:nowrap;'; $statrow->cells[] = $cell; } - foreach ($reportdata->statuses AS $sts) { + foreach ($reportdata->statuses as $sts) { $statrow->cells[] = ''; } $statrow->cells[] = '';