From 8b8d7fcd17302c1d4663f85f1b1fab8a4949a954 Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Thu, 28 Feb 2013 16:01:40 +0800 Subject: [PATCH] MDL-34774 Lesson module: fixed report stats for 'high score' and 'low score' values where there is only one attempt with 0 score --- mod/lesson/report.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 99294739728..b702f0c349b 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -286,10 +286,10 @@ if ($action === 'delete') { $numofattempts++; $avescore += $try["grade"]; $avetime += $timetotake; - if ($try["grade"] > $highscore || $highscore == NULL) { + if ($try["grade"] > $highscore || $highscore === NULL) { $highscore = $try["grade"]; } - if ($try["grade"] < $lowscore || $lowscore == NULL) { + if ($try["grade"] < $lowscore || $lowscore === NULL) { $lowscore = $try["grade"]; } if ($timetotake > $hightime || $hightime == NULL) { @@ -348,10 +348,10 @@ if ($action === 'delete') { } else { $lowtime = format_time($lowtime); } - if ($highscore == NULL) { + if ($highscore === NULL) { $highscore = get_string("notcompleted", "lesson"); } - if ($lowscore == NULL) { + if ($lowscore === NULL) { $lowscore = get_string("notcompleted", "lesson"); } @@ -364,7 +364,14 @@ if ($action === 'delete') { $stattable->align = array('center', 'center', 'center', 'center', 'center', 'center'); $stattable->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); $stattable->attributes['class'] = 'standardtable generaltable'; - $stattable->data[] = array($avescore.'%', $avetime, $highscore.'%', $lowscore.'%', $hightime, $lowtime); + + if (is_numeric($highscore)) { + $highscore .= '%'; + } + if (is_numeric($lowscore)) { + $lowscore .= '%'; + } + $stattable->data[] = array($avescore.'%', $avetime, $highscore, $lowscore, $hightime, $lowtime); echo html_writer::table($stattable); } else if ($action === 'reportdetail') {