2 require 'include/head.inc';
3 require 'include/db.inc';
4 require 'include/exams.inc';
5 require 'include/common.inc';
7 if ( isset($EXAMS_actual) ) {
8 $showexam = $EXAMS_actual;
10 else if ( isset($EXAMS_last) ) {
11 block("red", "no next exam");
12 $showexam = $EXAMS_last;
15 block("red", "no exams defined");
19 if( isset($_GET['examselected']) ) { $showexam = trim($_GET['examselected']); }
21 if( isset($_GET['examid']) && isset($_GET['mnumber']) && isset($_GET['tstamp']) && isset($_GET['scorestr']) ) {
22 $up_examid = trim($_GET['examid']);
23 $up_mnumber = trim($_GET['mnumber']);
24 $up_tstamp = trim($_GET['tstamp']);
25 $up_scorestr = trim($_GET['scorestr']);
27 if( $db->query("SELECT COUNT(*) FROM examscore WHERE mnumber=$up_mnumber AND exam=$up_examid AND tstamp=$up_tstamp")->fetch(PDO::FETCH_NUM)[0] == 0 ) {
28 $db->query("DELETE FROM examscore WHERE mnumber=$up_mnumber AND exam=$up_examid");
29 $db->query("INSERT INTO examscore (exam,mnumber,scorestr,tstamp) values ($up_examid,$up_mnumber,\"$up_scorestr\",$up_tstamp)");
30 block("lightgreen", "modified submit");
34 print "<form action='examoverview.php'>";
35 print "<select name='examselected' onchange='this.form.submit()'>";
36 foreach($EXAMS as $exam) {
38 if( isset($EXAMS_actual) && $exam['id'] == $EXAMS_actual ) { $note = "(next)"; }
39 if( isset($EXAMS_last) && $exam['id'] == $EXAMS_last ) { $note = "(last)"; }
40 if( $showexam != $exam['id'] ) {
41 print "<option value=" . $exam['id'] . ">" . $exam['timestr'] . " " . $note . "</option>";
44 print "<option value=" . $exam['id'] . " selected='selected'>" . $exam['timestr'] . " " . $note . "</option>";
50 block("black", "summary for exam " . $EXAMS[$showexam]['timestr'] . " (" . $EXAMS[$showexam]['scorestr'] . ")");
52 $result = $db->query("SELECT firstname, lastname, mnumber FROM students ORDER BY LOWER(lastname)");
55 print "<td><b>First name </b></td><td><b>Last name </b></td><td><b>Matr.nummer </b></td><td><b>Total Score </b></td>";
57 # if( isset($EXAMS_actual) && $showexam == $EXAMS_actual ) {
58 # print "<td><b>Blackboard </b></td>";
61 # print "<td><b>Modify </b></td>";
64 while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
65 $result2 = $db->query("SELECT scorestr FROM examscore WHERE mnumber=" . $student['mnumber'] . " AND exam=" . $showexam)->fetch(PDO::FETCH_NUM);
67 $exdone = $result2[0];
68 if ($exdone == "") { $exdone=0; }
70 $scorestr = $result2[0];
73 foreach (explode(',',$scorestr) as $points) {
74 $totscore = $totscore + $points;
78 print "<td>" . $student['firstname'] . "</td>";
79 print "<td>" . $student['lastname'] . "</td>";
80 print "<td>" . $student['mnumber'] . "</td>";
81 print "<td>" . $totscore . "/" . $EXAMS[$showexam]['totscore'] . "</td>";
83 print "<td><form style='margin: 0; padding: 0' action='examoverview.php'>";
84 if( isset($_GET['examselected']) ) { print "<input type='hidden' name='examselected' value='" . $_GET['examselected'] . "' />"; }
85 print "<input type='hidden' name='examid' value='" . $showexam . "' />";
86 print "<input type='hidden' name='mnumber' value='" . $student['mnumber'] . "' />";
87 print "<input type='hidden' name='tstamp' value='" . time() . "' />";
88 print "<input size='10' name='scorestr' type='text' value='" . $scorestr . "'>";