require 'include/head.inc';
require 'include/db.inc';
require 'include/session.inc';
+ require 'include/exams.inc';
require 'include/common.inc';
if ($db->query("SELECT COUNT(*) FROM students")->fetch(PDO::FETCH_NUM)[0] == 0) {
$result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY LOWER(lastname)");
print "<table>";
- print "<td><b>First name </b></td><td><b>Last name </b></td><td><b>Matr.nummer </b></td><td><b>Examples </b></td><td><b>Blackboard </b></td>";
+ print "<td><b>First name </b></td><td><b>Last name </b></td><td><b>Matr.nummer </b></td><td><b>Blackboard </b></td><td><b>Examples </b></td><td><b>Exams </b></td>";
+
while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
- $exdone = $db->query("SELECT manydone FROM workdone WHERE mnumber=" . $student['mnumber'])->fetch(PDO::FETCH_NUM);
$totexdone = 0;
- foreach($exdone as $subdone) { $totexdone += $subdone; }
+ if( $db->query("SELECT COUNT(*) FROM workdone WHERE mnumber=" . $student['mnumber'])->fetch(PDO::FETCH_NUM)[0] > 0 ) {
+ $exdone = $db->query("SELECT manydone FROM workdone WHERE mnumber=" . $student['mnumber']);
+ while ( $subdone = $exdone->fetch(PDO::FETCH_NUM) ) { $totexdone += $subdone[0]; }
+ }
+
+ $examscore=0;
+ foreach ($EXAMS as $exam) {
+ $scorestr = $db->query("SELECT scorestr FROM examscore WHERE mnumber=" . $student['mnumber'] . " AND exam=" . $exam['id'])->fetch(PDO::FETCH_NUM)[0];
+ if ($scorestr != "") {
+ $singlescore = 0;
+ foreach (explode(',',$scorestr) as $points) { $singlescore = $singlescore + $points; }
+ $examscore = $examscore + $singlescore/$exam['totscore'];
+ }
+ }
+ $examscore = ($examscore / $EXAMS_n)*100;
+
print "<tr>";
print "<td>" . $student['firstname'] . "</td>";
print "<td>" . $student['lastname'] . "</td>";
print "<td>" . $student['mnumber'] . "</td>";
- print "<td>" . $totexdone . "/" . $SESSIONS_totex_nextinc . "</td>";
- print "<td>" . $student['blackboard'] . "</td>";
+ print "<td>";
+ print($student['blackboard']);
+ print "</td>";
+ print "<td>";
+ printf("%3d", round(100 * floatval($totexdone) / floatval($SESSIONS_totex_nextinc)));
+ print "%</td>";
+ print "<td>";
+ printf("%3d", round($examscore));
+ print "%</td>";
print "</tr>";
}
+
print "</table>";
?>
\ No newline at end of file