From 3c3f90df083bbb478d7c4636797df9c2929813a2 Mon Sep 17 00:00:00 2001 From: Nadav Kavalerchik Date: Mon, 20 Jan 2014 19:42:49 +0200 Subject: [PATCH] Calculate the sum of statuses for all users in each session Hi Dan, Here is another patch the calculates the sum of statuses for all users in each session. Please review and see if you can accept. Nadav :-) --- renderer.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/renderer.php b/renderer.php index ab1983f..e3af1ad 100755 --- a/renderer.php +++ b/renderer.php @@ -812,6 +812,27 @@ class mod_attendance_renderer extends plugin_renderer_base { $table->data[] = $row; } + // Calculate the sum of statuses for each user + $statrow = new html_table_row(); + $statrow->cells[] = ''; + $statrow->cells[] = get_string('summary'); + foreach ($reportdata->sessions as $sess) { + $sessionstats = array(); + foreach ($reportdata->users as $user) { + foreach($reportdata->statuses as $status) { + if ($reportdata->sessionslog[$user->id][$sess->id]->statusid == $status->id) $sessionstats[$status->id]++; + } + } + + $statsoutput = '
'; + foreach($reportdata->statuses as $status) { + $statsoutput .= "$status->description:".$sessionstats[$status->id]."
"; + } + $statrow->cells[] = $statsoutput; + + } + $table->data[] = $statrow; + return html_writer::table($table); }