From dbab79b760a05f86f3f22c20cea1fd96a93ecb74 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 16 Aug 2017 13:56:17 +1200 Subject: [PATCH] Don't show 0% in user report if no taken sessions. --- renderer.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/renderer.php b/renderer.php index 3c2bcb7..7b382e7 100644 --- a/renderer.php +++ b/renderer.php @@ -961,13 +961,19 @@ class mod_attendance_renderer extends plugin_renderer_base { 'studentid' => $userdata->user->id, 'view' => ATT_VIEW_ALL)); $row->cells[] = html_writer::link($attendanceurl, $ca->attname); + $usersummary = new stdClass(); if (isset($userdata->summary[$ca->attid])) { $usersummary = $userdata->summary[$ca->attid]->get_all_sessions_summary_for($userdata->user->id); $row->cells[] = $usersummary->numtakensessions; $row->cells[] = format_float($usersummary->takensessionspoints, 1, true, true) . ' / ' . format_float($usersummary->takensessionsmaxpoints, 1, true, true); - $row->cells[] = format_float($usersummary->takensessionspercentage * 100) . '%'; + if (empty($usersummary->numtakensessions)) { + $row->cells[] = '-'; + } else { + $row->cells[] = format_float($usersummary->takensessionspercentage * 100) . '%'; + } + } $table->data[] = $row; if ($usersummary->numtakensessions > 0) {