require 'include/db.inc';
require 'include/common.inc';
- if($_GET['mnumber']!="" &&
+ if( isset($_GET['mnumber']) &&
$db->query("SELECT COUNT(*) FROM students WHERE mnumber=" . trim($_GET['mnumber']) . " AND lastblackboard=" . trim($_GET['tstamp']))->fetch(PDO::FETCH_NUM)[0] == 0) {
if( $_GET['sign'] == 0 ) {
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 . "' />";
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><td><b>Blackboard </b></td>";
while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
- $exdone = $db->query("SELECT manydone FROM workdone WHERE mnumber=" . $student['mnumber'])->fetch(PDO::FETCH_NUM);
$totexdone = 0;
- foreach($exdone as $subdone) { $totexdone += $subdone; }
+ if( $db->query("SELECT COUNT(*) FROM workdone WHERE mnumber=" . $student['mnumber'])->fetch(PDO::FETCH_NUM)[0] > 0 ) {
+ $exdone = $db->query("SELECT manydone FROM workdone WHERE mnumber=" . $student['mnumber'])->fetch(PDO::FETCH_NUM);
+ foreach($exdone as $subdone) { $totexdone += $subdone; }
+ }
print "<tr>";
print "<td>" . $student['firstname'] . "</td>";
print "<td>" . $student['lastname'] . "</td>";
if($SESSIONS_actual == -1) unset($SESSIONS_actual);
$SESSIONS_totex = 0;
+ $SESSIONS_totex_nextinc = 0;
if(isset($SESSIONS)) {
foreach ($SESSIONS as $session) {
- if($session['id'] < $SESSIONS_next || (! isset($SESSIONS_next)) ) { $SESSIONS_totex += $session['nexamples']; }
- if( $session['id'] != $SESSIONS_actual ) { $SESSIONS_last = $session['id']; }
+ if( (! isset($SESSIONS_next)) || $session['id'] < $SESSIONS_next ) { $SESSIONS_totex += $session['nexamples']; }
+ if( (! isset($SESSIONS_actual)) || $session['id'] != $SESSIONS_actual ) { $SESSIONS_last = $session['id']; }
+ if( (! isset($SESSIONS_next)) || $session['id'] <= $SESSIONS_next ) { $SESSIONS_totex_nextinc += $session['nexamples']; }
}
}
- $SESSIONS_totex_nextinc = 0;
- if( isset($SESSIONS) && isset($SESSIONS_next) ) {
- foreach ($SESSIONS as $session) {
- if($session['id'] <= $SESSIONS_next) { $SESSIONS_totex_nextinc += $session['nexamples']; }
- }
- }
}
?>