require 'include/db.inc';
require 'include/common.inc';
- if($_GET['mnumber']!="") {
- // would be better to store timestamp in blackboard db!
- if( time()-$_GET['tstamp'] < 5 ) {
- $db->query("UPDATE students SET blackboard=blackboard+1 WHERE mnumber=" . trim($_GET['mnumber']));
- block("lightgreen", "added blackboard");
+ if($_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 ) {
+ $db->query("UPDATE students SET blackboard=blackboard+1, lastblackboard=" . $_GET['tstamp'] . " WHERE mnumber=" . trim($_GET['mnumber']));
+ }
+ else {
+ $db->query("UPDATE students SET blackboard=blackboard-1, lastblackboard=" . $_GET['tstamp'] . " WHERE mnumber=" . trim($_GET['mnumber']));
}
}
print "<td>" . $student['lastname'] . " </td>";
print "<td>" . $student['mnumber'] . " </td>";
print "<td>" . $student['blackboard'] . " </td>";
- print "<td>" . "<a href='blackboard.php?mnumber=" . $student['mnumber'] . "&tstamp=" . time() . "'>+1" . "</a></td>";
+ print "<td>" . "<a href='blackboard.php?mnumber=" . $student['mnumber'] . "&tstamp=" . time() . "&sign=0'>+1" . "</a></td>";
+ print "<td>" . "<a href='blackboard.php?mnumber=" . $student['mnumber'] . "&tstamp=" . time() . "&sign=1'>-1" . "</a></td>";
print "</tr>";
}
print "</table>";
block("black", "summary for session " . $SESSIONS[$SESSIONS_actual]['timestr'] . " (" . $SESSIONS[$SESSIONS_actual]['examples'] . ")");
- $result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY lastname");
+ $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><td><b>Blackboard </b></td>";
block("black", "summary of everything for " . date("d.m.Y H:i"));
- $result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY lastname");
+ $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><td><b>Blackboard </b></td>";
if (! isset($db)) {
if ($db = new PDO('sqlite:banane.db')) {
$db->query('CREATE TABLE IF NOT EXISTS students
- (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, PRIMARY KEY (mnumber))');
+ (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, lastblackboard TIMESTAMP, PRIMARY KEY (mnumber))');
$db->query('CREATE TABLE IF NOT EXISTS workdone
(mnumber int, session int, manydone int, thisdone string)');
$db->query('CREATE TABLE IF NOT EXISTS prefs