From: Alexander Schmidt Date: Wed, 26 Sep 2012 13:25:51 +0000 (+0200) Subject: ... X-Git-Url: https://git.treefish.org/banana.git/commitdiff_plain/8db41c98817b1b48532dc3cebf4bea166e42bb70?ds=sidebyside;hp=4678f209fb04682d0981cadb566d63f5726f9e09 ... --- diff --git a/admin/.htaccess b/admin/.htaccess new file mode 100644 index 0000000..3b1c13c --- /dev/null +++ b/admin/.htaccess @@ -0,0 +1,5 @@ +AuthUserFile /afs/treefish.org/user/alex/www/mechanics/alex/admin/.htpasswd +AuthGroupFile /dev/null +AuthName "Banana Admin" +AuthType Basic +require user admin diff --git a/admin/.htpasswd b/admin/.htpasswd new file mode 100644 index 0000000..5e4cb7a --- /dev/null +++ b/admin/.htpasswd @@ -0,0 +1 @@ +admin:c2j7bF02Yuxnw diff --git a/admin/banane.db b/admin/banane.db new file mode 120000 index 0000000..0e89486 --- /dev/null +++ b/admin/banane.db @@ -0,0 +1 @@ +../banane.db \ No newline at end of file diff --git a/admin/blackboard.php b/admin/blackboard.php new file mode 100644 index 0000000..b683221 --- /dev/null +++ b/admin/blackboard.php @@ -0,0 +1,39 @@ +query("UPDATE students SET blackboard=blackboard+1 WHERE mnumber=" . trim($_POST['mnumber'])); + block("lightgreen", "added blackboard"); + } + + block("black", "add blackboard"); +?> + +
+ + + + + +
Matr.nummer:
+
+ +query("SELECT firstname, lastname, mnumber, blackboard FROM students"); + + print ""; + while ($student = $result->fetch(PDO::FETCH_ASSOC)) { + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + } + print "
" . $student['firstname'] . " " . $student['lastname'] . "  " . $student['mnumber'] . "  " . $student['blackboard'] . "
"; + +?> \ No newline at end of file diff --git a/admin/include/banner.inc b/admin/include/banner.inc new file mode 120000 index 0000000..33a8951 --- /dev/null +++ b/admin/include/banner.inc @@ -0,0 +1 @@ +../../include/banner.inc \ No newline at end of file diff --git a/admin/include/common.inc b/admin/include/common.inc new file mode 120000 index 0000000..070e8c3 --- /dev/null +++ b/admin/include/common.inc @@ -0,0 +1 @@ +../../include/common.inc \ No newline at end of file diff --git a/admin/include/db.inc b/admin/include/db.inc new file mode 100644 index 0000000..9bce2c3 --- /dev/null +++ b/admin/include/db.inc @@ -0,0 +1,14 @@ +query('CREATE TABLE IF NOT EXISTS students + (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, 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 + (key string, value string, PRIMARY KEY (key))'); + $db->query('CREATE TABLE IF NOT EXISTS sessions + (id int NOT NULL, timestr string NOT NULL, PRIMARY KEY (id))'); + } + } +?> diff --git a/admin/include/head.inc b/admin/include/head.inc new file mode 100644 index 0000000..29c15a8 --- /dev/null +++ b/admin/include/head.inc @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/admin/include/nav.inc b/admin/include/nav.inc new file mode 100644 index 0000000..d473d97 --- /dev/null +++ b/admin/include/nav.inc @@ -0,0 +1,21 @@ + + +summary + | +blackboard + | +sessions + | +preferences + | +password + | +USER + +

diff --git a/admin/include/prefs.inc b/admin/include/prefs.inc new file mode 120000 index 0000000..0325019 --- /dev/null +++ b/admin/include/prefs.inc @@ -0,0 +1 @@ +../../include/prefs.inc \ No newline at end of file diff --git a/admin/include/session.inc b/admin/include/session.inc new file mode 120000 index 0000000..f5b0715 --- /dev/null +++ b/admin/include/session.inc @@ -0,0 +1 @@ +../../include/session.inc \ No newline at end of file diff --git a/admin/index.php b/admin/index.php new file mode 120000 index 0000000..74acd8b --- /dev/null +++ b/admin/index.php @@ -0,0 +1 @@ +blackboard.php \ No newline at end of file diff --git a/admin/password.php b/admin/password.php new file mode 100644 index 0000000..6459c94 --- /dev/null +++ b/admin/password.php @@ -0,0 +1,38 @@ + + +
+ + +
set admin password
+ + + + + + + + + +
Password:
+
diff --git a/admin/prefs.php b/admin/prefs.php new file mode 100644 index 0000000..76e14d7 --- /dev/null +++ b/admin/prefs.php @@ -0,0 +1,36 @@ +query("DELETE FROM prefs WHERE key='exname'"); + $db->query("INSERT INTO prefs (key,value) VALUES ('exname','" . trim($_POST['exname']) . "')"); + + $db->query("DELETE FROM prefs WHERE key='groupname'"); + $db->query("INSERT INTO prefs (key,value) VALUES ('groupname','" . trim($_POST['groupname']) . "')"); + + block("lightgreen", "set preferences"); + break; + } + +?> + +
+ + + + + + + + + + + + + + +
Exercise Name:
Group Name:
+
\ No newline at end of file diff --git a/admin/sessions.php b/admin/sessions.php new file mode 100644 index 0000000..a04f485 --- /dev/null +++ b/admin/sessions.php @@ -0,0 +1,50 @@ +query("INSERT INTO sessions (id,examples,nexamples) VALUES (" . strtotime(trim($_POST['stime'])) . ",'" . $_POST['examples'] . "','" . count(explode(',',$_POST['examples'])) . "')"); + block("lightgreen", "added session"); + } + + if($_GET['delete']!="") { + $db->query("DELETE FROM sessions WHERE id=" . $_GET['delete']); + block("red", "deleted session"); + } + + require 'include/session.inc'; + + block("black", "add session"); +?> + +
+ + + + + + + + +
Time: (e.g. 10.9.2012 10:30)
Examples: (e.g. 1a,1b,1c,2,3a,3b)
+
+ +"; + foreach ($SESSIONS as $session) { + print ""; + print "" . $session['id'] . "  "; + print "" . $session['timestr'] . "  "; + print "" . $session['examples'] . "(" . $session['nexamples'] . ")" . "  "; + if ($session['workdone'] == 0) { + print "delete"; + } + else { print "locked"; } + print ""; + } + print ""; + +?> \ No newline at end of file diff --git a/admin/summary.php b/admin/summary.php new file mode 100644 index 0000000..345f5a0 --- /dev/null +++ b/admin/summary.php @@ -0,0 +1,27 @@ +query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY lastname"); + + print ""; + print ""; + 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; } + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + } + print "
First name Last name Matr.nummer Examples Blackboard 
" . $student['firstname'] . "" . $student['lastname'] . "" . $student['mnumber'] . "" . $totexdone . "/" . $SESSIONS_totex . "" . $student['blackboard'] . "
"; + +?> \ No newline at end of file diff --git a/createdb.inc b/createdb.inc deleted file mode 100644 index 05f2637..0000000 --- a/createdb.inc +++ /dev/null @@ -1,8 +0,0 @@ -query('CREATE TABLE IF NOT EXISTS students - (mnumber int, firstname string, lastname string, email string, password string, PRIMARY KEY (mnumber))'); - $db->query('CREATE TABLE IF NOT EXISTS workdone - (mnumber int, session int, manydone int, thisdone string)'); - } -?> diff --git a/head.inc b/head.inc deleted file mode 100644 index 77d7385..0000000 --- a/head.inc +++ /dev/null @@ -1,15 +0,0 @@ - $line) { - $lecture[$line_num] = $line; - } - - print ""; - print ""; - print ""; - print "
Banana Exercise Management
$lecture[0] $lecture[1], Group: $lecture[2]
"; - - print "
"; -?> \ No newline at end of file diff --git a/include/banner.inc b/include/banner.inc new file mode 100644 index 0000000..1599111 --- /dev/null +++ b/include/banner.inc @@ -0,0 +1,16 @@ + $line) { + $lecture[$line_num] = $line; + } + + print ""; + print ""; + print ""; + print "
Banana Exercise Management
 " . $PREFS['exname'] . ", Gruppe: " . $PREFS['groupname'] . " 
"; + + print "
"; +?> diff --git a/include/common.inc b/include/common.inc new file mode 100644 index 0000000..38de013 --- /dev/null +++ b/include/common.inc @@ -0,0 +1,7 @@ +"; + print " $text "; + print ""; + } +?> diff --git a/include/db.inc b/include/db.inc new file mode 100644 index 0000000..3612374 --- /dev/null +++ b/include/db.inc @@ -0,0 +1,14 @@ +query('CREATE TABLE IF NOT EXISTS students + (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, 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 + (key string, value string, PRIMARY KEY (key))'); + $db->query('CREATE TABLE IF NOT EXISTS sessions + (id int NOT NULL, examples string, nexamples int, PRIMARY KEY (id))'); + } + } +?> diff --git a/include/head.inc b/include/head.inc new file mode 100644 index 0000000..29c15a8 --- /dev/null +++ b/include/head.inc @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/include/nav.inc b/include/nav.inc new file mode 100644 index 0000000..59f1950 --- /dev/null +++ b/include/nav.inc @@ -0,0 +1,18 @@ + + + +submit + | +summary + | +register + | +ADMIN + +

diff --git a/include/prefs.inc b/include/prefs.inc new file mode 100644 index 0000000..58aac3e --- /dev/null +++ b/include/prefs.inc @@ -0,0 +1,9 @@ +query("SELECT key, value FROM prefs"); + while ($row = $result->fetch(PDO::FETCH_ASSOC)) { + $PREFS[$row['key']] = $row['value']; + } + +?> diff --git a/include/session.inc b/include/session.inc new file mode 100644 index 0000000..7b5b798 --- /dev/null +++ b/include/session.inc @@ -0,0 +1,18 @@ +query("SELECT id,examples,nexamples FROM sessions ORDER BY id"); + $SESSIONS_next = -1; + while ($session = $result->fetch(PDO::FETCH_ASSOC)) { + $SESSIONS[$session['id']] = array("id" => $session['id'], "timestr" => date("d.m.Y H:i", $session['id']), + "workdone" => $db->query("SELECT COUNT(*) FROM workdone WHERE session=" . $session['id'])->fetch(PDO::FETCH_NUM)[0], + "examples" => $session['examples'], "nexamples" => $session['nexamples']); + if ( strtotime("now") < $session['id'] && ( $SESSIONS_next==-1 || $SESSIONS_next > $session['id'] ) ) { + $SESSIONS_next = $session['id']; + } + } + if($SESSIONS_next == -1) unset($SESSIONS_next); + + $SESSIONS_totex = 0; + foreach ($SESSIONS as $session) { + if($session['id'] < $SESSIONS_next) { $SESSIONS_totex += $session['nexamples']; } + } +?> diff --git a/include/usercheck.inc b/include/usercheck.inc new file mode 100644 index 0000000..e6cab54 --- /dev/null +++ b/include/usercheck.inc @@ -0,0 +1,22 @@ +query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 0) { + print ''; + print ''; + print '
Mat.nummer not found
'; + print "Mat.Nummer was not found. You have to register first!"; + break; + } + + if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber AND password = \"$password\"")->fetch(PDO::FETCH_NUM)[0] == 0) { + print ''; + print ''; + print '
wrong password
'; + break; + } + +?> \ No newline at end of file diff --git a/lastsubmit.php b/lastsubmit.php deleted file mode 100644 index c2577b9..0000000 --- a/lastsubmit.php +++ /dev/null @@ -1,71 +0,0 @@ -query("SELECT thisdone FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0]; - if ($result == "") { - print ""; - print ""; - print "
no submit
"; - print "No results were submitted for " . end($sessions)[0] . "."; - break; - } - else { - print ""; - print ""; - print "
Last submit of $mnumber for " . end($sessions)[0] . "
"; - print $result; - } - } - else { - $result = $db->query("SELECT students.firstname, students.lastname, students.mnumber, workdone.manydone, workdone.thisdone FROM workdone, students WHERE workdone.session = $sessionid AND workdone.mnumber = students.mnumber"); - - print ""; - print ""; - print "
Last submits for " . end($sessions)[0] . "
"; - - print ""; - - while ($row = $result->fetch(PDO::FETCH_NUM)) { - print ""; - echo ""; - print ""; - } - - print "
$row[0] $row[1]    $row[2]    $row[4]    $row[3]/$lstsession_nex
"; - } - - break; - } -?> - -
- - -
Last submission
- - - - - - - - - - - - - -
Mat.nummer:
Password:
-
diff --git a/lecture.inc b/lecture.inc deleted file mode 100644 index b431d8d..0000000 --- a/lecture.inc +++ /dev/null @@ -1,6 +0,0 @@ - $line) { - $lecture[$line_num] = $line; - } -?> diff --git a/nav.inc b/nav.inc deleted file mode 100644 index f69d3e8..0000000 --- a/nav.inc +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -submit - | -register - | -last submit - -

diff --git a/register.php b/register.php index 69b99fe..0a844ac 100644 --- a/register.php +++ b/register.php @@ -1,5 +1,5 @@ query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 1) { diff --git a/session.inc b/session.inc deleted file mode 100644 index 30bae4d..0000000 --- a/session.inc +++ /dev/null @@ -1,9 +0,0 @@ - $line) { - $sessions[$line_num] = explode("\t",$line); - } - - $lstsession_nex = count(explode(',',end($sessions)[1])); -?> diff --git a/submit.php b/submit.php index 2e88c85..aabc3fe 100644 --- a/submit.php +++ b/submit.php @@ -1,26 +1,20 @@ $line) { - $sessions[$line_num] = explode("\t",$line); - } - - if ( strtotime("now") > strtotime(end($sessions)[0]) ) { - print ''; - print ''; - print '
submission closed
'; + if ( ! isset($SESSIONS_next) ) { + block("red", "submission closed"); break; } if(isset($_POST['submit']) && $_POST['mnumber']!="") { - require 'usercheck.inc'; - + require 'include/usercheck.inc'; + $exchecked = $_POST['exchecked']; $mnumber = $_POST['mnumber']; - $sessionid = strtotime(end($sessions)[0]); + $sessionid = $SESSIONS[$SESSIONS_next]['id']; if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0] == 1) { print ''; @@ -42,18 +36,11 @@ break; } - if(trim(end($sessions)[0]) == "") { - print '
'; - print ''; - print '
no exercises defined
'; - break; - } - ?>
- +
submit examples for
submit examples for
@@ -72,7 +59,7 @@ $exid "; $exnum++; if ($exnum%3 == 0) { print ""; } diff --git a/summary.php b/summary.php new file mode 100644 index 0000000..3354ca3 --- /dev/null +++ b/summary.php @@ -0,0 +1,72 @@ +Examples Submitted"; + print "
"; + + $tot_done = 0; + + foreach ($SESSIONS as $session) { + if ($session['id'] == $SESSIONS_next) { break; } + + $exdone = $db->query("SELECT thisdone, manydone FROM workdone WHERE mnumber=" . $mnumber . " AND session=" . $session['id'])->fetch(PDO::FETCH_NUM); + + if ( $exdone[1] == "" ) { $exdone[1] = "0"; } + + $tot_done = $tot_done + $exdone[1]; + + print ""; + print ""; + print ""; + print ""; + print ""; + } + print ""; + print ""; + print ""; + + print "
" . $session['timestr'] . "  " . $session['examples'] . "(" . $session['nexamples'] . ")" . "  " . $exdone[1] . "/" . $session['nexamples'] . "(" . $exdone[0] . ")" . "  
" . $tot_done . "/" . $SESSIONS_totex . "
"; + + print "
"; + + print "Blackboard"; + $blackdone = $db->query("SELECT blackboard FROM students WHERE mnumber=" . $mnumber)->fetch(PDO::FETCH_NUM)[0]; + + print "
"; + + for( $ib=0; $ib<$blackdone; $ib++ ) { echo " * "; } + + break; + } +?> + + + + +
Last submission
+ + + + + + + + + + + + + +
Mat.nummer:
Password:
+
diff --git a/usercheck.inc b/usercheck.inc deleted file mode 100644 index 19e51d3..0000000 --- a/usercheck.inc +++ /dev/null @@ -1,22 +0,0 @@ -query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 0) { - print ''; - print ''; - print '
Mat.nummer not found
'; - print "Mat.Nummer was not found. You have to register first!"; - break; - } - - if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber AND password = \"$password\"")->fetch(PDO::FETCH_NUM)[0] == 0) { - print ''; - print ''; - print '
wrong password
'; - break; - } - -?> \ No newline at end of file diff --git a/var/.gitignore b/var/.gitignore deleted file mode 100644 index 27fc3b0..0000000 --- a/var/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.txt -banane.db diff --git a/var/lecture.txt.sample b/var/lecture.txt.sample deleted file mode 100644 index 577ca1e..0000000 --- a/var/lecture.txt.sample +++ /dev/null @@ -1,3 +0,0 @@ -Theoretische Mechanik -WS2012 -Alex diff --git a/var/sessions.txt.sample b/var/sessions.txt.sample deleted file mode 100644 index 25eb55d..0000000 --- a/var/sessions.txt.sample +++ /dev/null @@ -1 +0,0 @@ -27.09.2012 10:30 1a,1b,1c,2a,2b,3