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( $up_editsub == "" ) { $up_manydone = 0; }
28 else{ $up_manydone = count(explode(",",$up_editsub)); }
30 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 ) {
31 $db->query("DELETE FROM workdone WHERE mnumber=$up_mnumber AND session=$up_sessionid");
32 $db->query("INSERT INTO workdone (session,mnumber,thisdone,manydone,tstamp) values ($up_sessionid,$up_mnumber,\"$up_editsub\",$up_manydone,$up_tstamp)");
33 block("lightgreen", "modified submit");
37 print "<form action='sessionoverview.php'>";
38 print "<select name='sessionselected' onchange='this.form.submit()'>";
39 foreach($SESSIONS as $session) {
41 if( isset($SESSIONS_actual) && $session['id'] == $SESSIONS_actual ) { $note = "(next)"; }
42 if( isset($SESSIONS_last) && $session['id'] == $SESSIONS_last ) { $note = "(last)"; }
43 if( $showsession != $session['id'] ) {
44 print "<option value=" . $session['id'] . ">" . $session['timestr'] . " " . $note . "</option>";
47 print "<option value=" . $session['id'] . " selected='selected'>" . $session['timestr'] . " " . $note . "</option>";
53 block("black", "summary for session " . $SESSIONS[$showsession]['timestr'] . " (" . $SESSIONS[$showsession]['examples'] . ")");
55 $result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY LOWER(lastname)");
58 print "<td><b>First name </b></td><td><b>Last name </b></td><td><b>Matr.nummer </b></td><td><b>Examples </b></td>";
60 if( isset($SESSIONS_actual) && $showsession == $SESSIONS_actual ) {
61 print "<td><b>Blackboard </b></td>";
64 print "<td><b>Modify </b></td>";
67 while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
68 $result2 = $db->query("SELECT manydone, thisdone FROM workdone WHERE mnumber=" . $student['mnumber'] . " AND session=" . $showsession)->fetch(PDO::FETCH_NUM);
70 $exdone = $result2[0];
71 if ($exdone == "") { $exdone=0; }
73 $thisdone = $result2[1];
76 print "<td>" . $student['firstname'] . "</td>";
77 print "<td>" . $student['lastname'] . "</td>";
78 print "<td>" . $student['mnumber'] . "</td>";
79 print "<td>" . $thisdone . " (" . $exdone . "/" . $SESSIONS[$showsession]['nexamples'] . ")</td>";
81 if( (! isset($SESSIONS_actual)) || $showsession != $SESSIONS_actual ) {
82 print "<td><form style='margin: 0; padding: 0' action='sessionoverview.php'>";
83 if( isset($_GET['sessionselected']) ) { print "<input type='hidden' name='sessionselected' value='" . $_GET['sessionselected'] . "' />"; }
84 print "<input type='hidden' name='sessionid' value='" . $showsession . "' />";
85 print "<input type='hidden' name='mnumber' value='" . $student['mnumber'] . "' />";
86 print "<input type='hidden' name='tstamp' value='" . time() . "' />";
87 print "<input size='10' name='editsub' type='text' value='" . $thisdone . "'>";
91 print "<td>" . $student['blackboard'] . "</td>";