Fixed average

This commit is contained in:
Daniel Mason 2017-01-02 22:11:33 +13:00
parent 121772cebc
commit d262d86e11

View File

@ -110,22 +110,21 @@ if (isset($_POST['mark'])) {
$date = date("Y-m-d", $result->getTime()); $date = date("Y-m-d", $result->getTime());
$day[$date][] = date("h:i a", $result->getTime())." - Score ".(($score['correct']/$score['total'])*100)."% (".$score['correct']."/".$score['total']."). ". $day[$date][] = date("h:i a", $result->getTime())." - Score ".(($score['correct']/$score['total'])*100)."% (".$score['correct']."/".$score['total']."). ".
"<a href='index.php?viewresult=".$result->getId()."'>View Result</a><br/>"; "<a href='index.php?viewresult=".$result->getId()."'>View Result</a><br/>";
if(!isset($day[$date]['total'])) { $day[$date]['total'][] = ($score['correct'] / $score['total']) * 100;
$day[$date]['total'] = ($score['correct'] / $score['total']) * 100;
} else {
$original = $day[$date]['total'];
$day[$date]['total'] = ($original + (($score['correct'] / $score['total']) * 100)) / 2;
}
} }
foreach ($day as $t=>$da) { foreach ($day as $t=>$da) {
echo "<span style='font-weight:bold'>".$t."</span><br/>"; echo "<span style='font-weight:bold'>".$t."</span><br/>";
$total = $da['total']; $total = 0;
foreach($da['total'] as $t) {
$total = $total+$t;
}
$total = round(($total/count($da['total'])),2);
unset($da['total']); unset($da['total']);
foreach($da as $c=>$d) { foreach($da as $c=>$d) {
echo $d; echo $d;
} }
echo round($total,2)."% Average<br/><br/>"; echo $total."% Average<br/><br/>";
} }
} else { } else {