From a3eb8b3f0be1154b1f59ce67648abe74228c56f2 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Wed, 30 Jan 2013 14:50:04 +0100 Subject: reportall: Show users progress --- sqlbox/reportall.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sqlbox') diff --git a/sqlbox/reportall.php b/sqlbox/reportall.php index 2e002b4..c3a2813 100644 --- a/sqlbox/reportall.php +++ b/sqlbox/reportall.php @@ -44,8 +44,8 @@ foreach ($boxes as $box) $b[$box->id] = $box->name; $table = new html_table; -$table->head = array_merge(array("Nutzer"), $b); -$table->align = array_merge(array("left"), array_fill(0, count($b), 'center')); +$table->head = array_merge(array("Nutzer", "Fortschritt"), $b); +$table->align = array_merge(array("left", "left"), array_fill(0, count($b), 'center')); $users = $DB->get_records("user", array('deleted'=>'0')); foreach ($users as $user) { @@ -60,10 +60,15 @@ foreach ($users as $user) { ON s.id = sol.sqlboxid ORDER BY s.id", array('id'=>$user->id)); $s = array(); - foreach ($solutions as $solution) + $progress = 0; + foreach ($solutions as $solution) { $s[$solution->id] = ($solution->correct == '1') ? '☑' : ($solution->correct == '0' ? '☒' : '☐'); + if ($solution->correct == '1') + $progress++; + } + $progress /= count($s); - $table->data[] = array_merge(array($name), $s); + $table->data[] = array_merge(array($name, round($progress * 100) . "%"), $s); } echo html_writer::table($table); -- cgit