id == $_GET['id']){ $user = $current_user; auth(AUTH_PUPIL); }else{ auth(AUTH_STAFF); if (!is_numeric($_GET['id'])) msgscrn("User not found","The user id is invalid.","",""); $user = User::get($_GET['id']); if (!$user) msgscrn("User not found","The user does not exist.","","rc"); } // Get assigned tests $ass = $user->tests(); // Averaging variables $sigma = 0.0; // Sum of scores $count = 0; // Number of scores // Hold some the processed scores, so we don't need to call the database again $the_tests = Array(); foreach ($ass as $a){ // Check the test has not already been added $is_in = false; foreach ($the_tests as $t){ if ($a->test()->id == $t['testID']){ $is_in = true; break; } } if ($is_in) continue; // Get score from database $res = Score::getfromusertest($user->id,$a->testID); $score = 0; $score_got = false; foreach ($res as $r){ if (!$score_got==false || $r->score >= $score){ $score_got = true; $score = $r->score; } } // Get maximum score $max = count($a->test()->words()) * 2; // Update average $perc = (($score+0.0) / ($max+0.0)) * 100; $sigma += $perc; $count += 1; // Add test overview to array array_push($the_tests,Array( "testID" => $a->test()->id, "date" => $a->test()->datecreated, "score" => $perc, "actual" => $score, "max" => $max, "title" => $a->test()->title, "taken" => $score_got )); } // Calculate average $aver = ($sigma / $count); // Show page showHeader("Pupil Report"); // Show header echo "

Report

\n"; ?>

There should be a graph here!

Your browser may not support this.
$aver) $stat = "Above average"; elseif ($t['score'] < $aver) $stat = "Below average"; else $stat = "Average"; // Output table row echo "\n"; }else // Output table row echo "\n"; } echo "
DateTest nameScore
".$t['date']."".$t['title'] . "".$t['actual']."/ ".$t['max']." - ".$t['score']."%$stat
".$t['date']."".$t['title'] . "Test not taken!
\n

Average score: ".$aver."%

\n"; // Create the graph ?>