2 require 'include/head.inc';
3 require 'include/db.inc';
4 require 'include/session.inc';
5 require 'include/common.inc';
7 if ( isset($SESSIONS_actual) ) {
8 $showsession = $SESSIONS_actual;
10 else if ( isset($SESSIONS_last) ) {
11 block("red", "no next session");
12 $showsession = $SESSIONS_last;
15 block("red", "no sessions defined");
19 if( isset($_GET['sessionselected']) ) { $showsession = trim($_GET['sessionselected']); }
21 if( isset($_GET['sessionid']) && isset($_GET['mnumber']) && isset($_GET['tstamp']) && isset($_GET['editsub']) ) {
22 $up_sessionid = trim($_GET['sessionid']);
23 $up_mnumber = trim($_GET['mnumber']);
24 $up_tstamp = trim($_GET['tstamp']);
25 $up_editsub = trim($_GET['editsub']);
27 if( $db->query("SELECT COUNT(*) FROM workdone WHERE mnumber=$up_mnumber AND session=$up_sessionid AND tstamp=$up_tstamp")->fetch(PDO::FETCH_NUM)[0] == 0 ) {
28 $db->query("UPDATE workdone SET thisdone='$up_editsub', manydone=" . count(explode(",",$up_editsub)) . ",tstamp=$up_tstamp WHERE mnumber=$up_mnumber AND session=$up_sessionid");
29 block("lightgreen", "modified submit");
33 print "<form action='sessionoverview.php'>";
34 print "<select name='sessionselected' onchange='this.form.submit()'>";
35 foreach($SESSIONS as $session) {
37 if( isset($SESSIONS_actual) && $session['id'] == $SESSIONS_actual ) { $note = "(next)"; }
38 if( isset($SESSIONS_last) && $session['id'] == $SESSIONS_last ) { $note = "(last)"; }
39 if( $showsession != $session['id'] ) {
40 print "<option value=" . $session['id'] . ">" . $session['timestr'] . " " . $note . "</option>";
43 print "<option value=" . $session['id'] . " selected='selected'>" . $session['timestr'] . " " . $note . "</option>";
49 block("black", "summary for session " . $SESSIONS[$showsession]['timestr'] . " (" . $SESSIONS[$showsession]['examples'] . ")");
51 $result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY LOWER(lastname)");
54 print "<td><b>First name </b></td><td><b>Last name </b></td><td><b>Matr.nummer </b></td><td><b>Examples </b></td>";
56 if( isset($SESSIONS_actual) && $showsession == $SESSIONS_actual ) {
57 print "<td><b>Blackboard </b></td>";
60 print "<td><b>Modify </b></td>";
63 while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
64 $result2 = $db->query("SELECT manydone, thisdone FROM workdone WHERE mnumber=" . $student['mnumber'] . " AND session=" . $showsession)->fetch(PDO::FETCH_NUM);
66 $exdone = $result2[0];
67 if ($exdone == "") { $exdone=0; }
69 $thisdone = $result2[1];
72 print "<td>" . $student['firstname'] . "</td>";
73 print "<td>" . $student['lastname'] . "</td>";
74 print "<td>" . $student['mnumber'] . "</td>";
75 print "<td>" . $thisdone . " (" . $exdone . "/" . $SESSIONS[$showsession]['nexamples'] . ")</td>";
77 if( (! isset($SESSIONS_actual)) || $showsession != $SESSIONS_actual ) {
78 print "<td><form style='margin: 0; padding: 0' action='sessionoverview.php'>";
79 if( isset($_GET['sessionselected']) ) { print "<input type='hidden' name='sessionselected' value='" . $_GET['sessionselected'] . "' />"; }
80 print "<input type='hidden' name='sessionid' value='" . $showsession . "' />";
81 print "<input type='hidden' name='mnumber' value='" . $student['mnumber'] . "' />";
82 print "<input type='hidden' name='tstamp' value='" . time() . "' />";
83 print "<input size='10' name='editsub' type='text' value='" . $thisdone . "'>";
87 print "<td>" . $student['blackboard'] . "</td>";