From 8db41c98817b1b48532dc3cebf4bea166e42bb70 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Wed, 26 Sep 2012 15:25:51 +0200 Subject: [PATCH] ... --- admin/.htaccess | 5 ++ admin/.htpasswd | 1 + admin/banane.db | 1 + admin/blackboard.php | 39 ++++++++++++++ admin/include/banner.inc | 1 + admin/include/common.inc | 1 + admin/include/db.inc | 14 +++++ admin/include/head.inc | 4 ++ admin/include/nav.inc | 21 ++++++++ admin/include/prefs.inc | 1 + admin/include/session.inc | 1 + admin/index.php | 1 + admin/password.php | 38 ++++++++++++++ admin/prefs.php | 36 +++++++++++++ admin/sessions.php | 50 ++++++++++++++++++ admin/summary.php | 27 ++++++++++ createdb.inc | 8 --- head.inc => include/banner.inc | 5 +- include/common.inc | 7 +++ include/db.inc | 14 +++++ include/head.inc | 4 ++ nav.inc => include/nav.inc | 8 ++- include/prefs.inc | 9 ++++ include/session.inc | 18 +++++++ usercheck.inc => include/usercheck.inc | 2 +- lastsubmit.php | 71 ------------------------- lecture.inc | 6 --- register.php | 4 +- session.inc | 9 ---- submit.php | 33 ++++-------- summary.php | 72 ++++++++++++++++++++++++++ var/.gitignore | 2 - var/lecture.txt.sample | 3 -- var/sessions.txt.sample | 1 - 34 files changed, 384 insertions(+), 133 deletions(-) create mode 100644 admin/.htaccess create mode 100644 admin/.htpasswd create mode 120000 admin/banane.db create mode 100644 admin/blackboard.php create mode 120000 admin/include/banner.inc create mode 120000 admin/include/common.inc create mode 100644 admin/include/db.inc create mode 100644 admin/include/head.inc create mode 100644 admin/include/nav.inc create mode 120000 admin/include/prefs.inc create mode 120000 admin/include/session.inc create mode 120000 admin/index.php create mode 100644 admin/password.php create mode 100644 admin/prefs.php create mode 100644 admin/sessions.php create mode 100644 admin/summary.php delete mode 100644 createdb.inc rename head.inc => include/banner.inc (60%) create mode 100644 include/common.inc create mode 100644 include/db.inc create mode 100644 include/head.inc rename nav.inc => include/nav.inc (86%) create mode 100644 include/prefs.inc create mode 100644 include/session.inc rename usercheck.inc => include/usercheck.inc (96%) delete mode 100644 lastsubmit.php delete mode 100644 lecture.inc delete mode 100644 session.inc create mode 100644 summary.php delete mode 100644 var/.gitignore delete mode 100644 var/lecture.txt.sample delete mode 100644 var/sessions.txt.sample 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/include/banner.inc similarity index 60% rename from head.inc rename to include/banner.inc index 77d7385..1599111 100644 --- a/head.inc +++ b/include/banner.inc @@ -1,4 +1,5 @@ "; print "Banana Exercise Management"; - print " $lecture[0] $lecture[1], Group: $lecture[2] "; + print " " . $PREFS['exname'] . ", Gruppe: " . $PREFS['groupname'] . " "; print ""; print "
"; -?> \ No newline at end of file +?> 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/nav.inc b/include/nav.inc similarity index 86% rename from nav.inc rename to include/nav.inc index f69d3e8..59f1950 100644 --- a/nav.inc +++ b/include/nav.inc @@ -1,7 +1,3 @@ - -