--- /dev/null
+<?php
+ require 'include/head.inc';
+ require 'include/db.inc';
+ require 'include/session.inc';
+ require 'include/common.inc';
+
+ if ( isset($SESSIONS_actual) ) {
+ $showsession = $SESSIONS_actual;
+ }
+ else if ( isset($SESSIONS_last) ) {
+ block("red", "no next session");
+ $showsession = $SESSIONS_last;
+ }
+ else {
+ block("red", "no sessions defined");
+ exit;
+ }
+
+ if( isset($_GET['sessionselected']) ) { $showsession = trim($_GET['sessionselected']); }
+
+ if( isset($_GET['sessionid']) && isset($_GET['mnumber']) && isset($_GET['tstamp']) && isset($_GET['editsub']) ) {
+ $up_sessionid = trim($_GET['sessionid']);
+ $up_mnumber = trim($_GET['mnumber']);
+ $up_tstamp = trim($_GET['tstamp']);
+ $up_editsub = trim($_GET['editsub']);
+
+ 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 ) {
+ $db->query("UPDATE workdone SET thisdone='$up_editsub', manydone=" . count(explode(",",$up_editsub)) . ",tstamp=$up_tstamp WHERE mnumber=$up_mnumber AND session=$up_sessionid");
+ block("lightgreen", "modified submit");
+ }
+ }
+
+ print "<form action='sessionoverview.php'>";
+ print "<select name='sessionselected' onchange='this.form.submit()'>";
+ foreach($SESSIONS as $session) {
+ $note = "";
+ if( $session['id'] == $SESSIONS_actual ) { $note = "(next)"; }
+ if( $session['id'] == $SESSIONS_last ) { $note = "(last)"; }
+ if( $showsession != $session['id'] ) {
+ print "<option value=" . $session['id'] . ">" . $session['timestr'] . " " . $note . "</option>";
+ }
+ else {
+ print "<option value=" . $session['id'] . " selected='selected'>" . $session['timestr'] . " " . $note . "</option>";
+ }
+ }
+ print "</select>";
+ print "</form>";
+
+ block("black", "summary for session " . $SESSIONS[$showsession]['timestr'] . " (" . $SESSIONS[$showsession]['examples'] . ")");
+
+ $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>";
+
+ if( $showsession == $SESSIONS_actual ) {
+ print "<td><b>Blackboard </b></td>";
+ }
+ else {
+ print "<td><b>Modify </b></td>";
+ }
+
+ while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
+ $result2 = $db->query("SELECT manydone, thisdone FROM workdone WHERE mnumber=" . $student['mnumber'] . " AND session=" . $showsession)->fetch(PDO::FETCH_NUM);
+
+ $exdone = $result2[0];
+ if ($exdone == "") { $exdone=0; }
+
+ $thisdone = $result2[1];
+
+ print "<tr>";
+ print "<td>" . $student['firstname'] . "</td>";
+ print "<td>" . $student['lastname'] . "</td>";
+ print "<td>" . $student['mnumber'] . "</td>";
+ print "<td>" . $thisdone . " (" . $exdone . "/" . $SESSIONS[$showsession]['nexamples'] . ")</td>";
+
+ if( $showsession != $SESSIONS_actual ) {
+ print "<td><form style='margin: 0; padding: 0' action='sessionoverview.php'>";
+ if( isset($_GET['sessionselected']) ) { print "<input type='hidden' name='sessionselected' value='" . $_GET['sessionselected'] . "' />"; }
+ print "<input type='hidden' name='sessionid' value='" . $showsession . "' />";
+ print "<input type='hidden' name='mnumber' value='" . $student['mnumber'] . "' />";
+ print "<input type='hidden' name='tstamp' value='" . time() . "' />";
+ print "<input size='10' name='editsub' type='text' value='" . $thisdone . "'>";
+ print "</form></td>";
+ }
+ else {
+ print "<td>" . $student['blackboard'] . "</td>";
+ }
+
+ print "</tr>";
+ }
+ print "</table>";
+?>