X-Git-Url: https://git.treefish.org/banana.git/blobdiff_plain/d38ececa64cec676367c348bc795cd1158dd723b..b22b28d88c9f6d951e1008e71843436b7df42b6a:/admin/blackboard.php diff --git a/admin/blackboard.php b/admin/blackboard.php index 814a879..a28d8dc 100644 --- a/admin/blackboard.php +++ b/admin/blackboard.php @@ -3,11 +3,14 @@ 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'])); } } @@ -21,7 +24,7 @@ query("SELECT firstname, lastname, mnumber, blackboard FROM students"); + $result=$db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY LOWER(lastname)"); print ""; while ($student = $result->fetch(PDO::FETCH_ASSOC)) { @@ -30,7 +33,8 @@ print ""; print ""; print ""; - print ""; + print ""; + print ""; print ""; } print "
" . $student['lastname'] . "  " . $student['mnumber'] . "  " . $student['blackboard'] . "  " . "+1" . "" . "+1" . "" . "-1" . "
";