$up_tstamp = trim($_GET['tstamp']);
$up_editsub = trim($_GET['editsub']);
+ if( $up_editsub == "" ) { $up_manydone = 0; }
+ else{ $up_manydone = count(explode(",",$up_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");
+ $db->query("DELETE FROM workdone WHERE mnumber=$up_mnumber AND session=$up_sessionid");
+ $db->query("INSERT INTO workdone (session,mnumber,thisdone,manydone,tstamp) values ($up_sessionid,$up_mnumber,\"$up_editsub\",$up_manydone,$up_tstamp)");
block("lightgreen", "modified submit");
}
}
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( isset($SESSIONS_actual) && $session['id'] == $SESSIONS_actual ) { $note = "(next)"; }
+ if( isset($SESSIONS_last) && $session['id'] == $SESSIONS_last ) { $note = "(last)"; }
if( $showsession != $session['id'] ) {
print "<option value=" . $session['id'] . ">" . $session['timestr'] . " " . $note . "</option>";
}
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 ) {
+ if( isset($SESSIONS_actual) && $showsession == $SESSIONS_actual ) {
print "<td><b>Blackboard </b></td>";
}
else {
print "<td>" . $student['mnumber'] . "</td>";
print "<td>" . $thisdone . " (" . $exdone . "/" . $SESSIONS[$showsession]['nexamples'] . ")</td>";
- if( $showsession != $SESSIONS_actual ) {
+ if( (! isset($SESSIONS_actual)) || $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 . "' />";