...
authorAlexander Schmidt <alex@treefish.org>
Wed, 26 Sep 2012 13:25:51 +0000 (15:25 +0200)
committerAlexander Schmidt <alex@treefish.org>
Wed, 26 Sep 2012 13:25:51 +0000 (15:25 +0200)
37 files changed:
admin/.htaccess [new file with mode: 0644]
admin/.htpasswd [new file with mode: 0644]
admin/banane.db [new symlink]
admin/blackboard.php [new file with mode: 0644]
admin/include/banner.inc [new symlink]
admin/include/common.inc [new symlink]
admin/include/db.inc [new file with mode: 0644]
admin/include/head.inc [new file with mode: 0644]
admin/include/nav.inc [new file with mode: 0644]
admin/include/prefs.inc [new symlink]
admin/include/session.inc [new symlink]
admin/index.php [new symlink]
admin/password.php [new file with mode: 0644]
admin/prefs.php [new file with mode: 0644]
admin/sessions.php [new file with mode: 0644]
admin/summary.php [new file with mode: 0644]
createdb.inc [deleted file]
head.inc [deleted file]
include/banner.inc [new file with mode: 0644]
include/common.inc [new file with mode: 0644]
include/db.inc [new file with mode: 0644]
include/head.inc [new file with mode: 0644]
include/nav.inc [new file with mode: 0644]
include/prefs.inc [new file with mode: 0644]
include/session.inc [new file with mode: 0644]
include/usercheck.inc [new file with mode: 0644]
lastsubmit.php [deleted file]
lecture.inc [deleted file]
nav.inc [deleted file]
register.php
session.inc [deleted file]
submit.php
summary.php [new file with mode: 0644]
usercheck.inc [deleted file]
var/.gitignore [deleted file]
var/lecture.txt.sample [deleted file]
var/sessions.txt.sample [deleted file]

diff --git a/admin/.htaccess b/admin/.htaccess
new file mode 100644 (file)
index 0000000..3b1c13c
--- /dev/null
@@ -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 (file)
index 0000000..5e4cb7a
--- /dev/null
@@ -0,0 +1 @@
+admin:c2j7bF02Yuxnw
diff --git a/admin/banane.db b/admin/banane.db
new file mode 120000 (symlink)
index 0000000..0e89486
--- /dev/null
@@ -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 (file)
index 0000000..b683221
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+  require 'include/head.inc';
+  require 'include/db.inc';
+  require 'include/common.inc';
+  
+  if(isset($_POST['submit']) && $_POST['mnumber']!="") {
+    $db->query("UPDATE students SET blackboard=blackboard+1 WHERE mnumber=" . trim($_POST['mnumber']));
+    block("lightgreen", "added blackboard");
+  }
+
+  block("black", "add blackboard");
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+  <table>
+    <tr>  
+      <th align="left">Matr.nummer:</th> <th><input type="text" name="mnumber"></th>
+      <th><input type="submit" name="submit" value="Add"></th>
+    </tr>
+  </table>
+</form>
+
+<?php
+  block("black", "blackboard overview");
+
+  $result=$db->query("SELECT firstname, lastname, mnumber, blackboard FROM students");
+
+  print "<table>";
+  while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
+    print "<tr>";
+    print "<td>" . $student['firstname'] . "&nbsp;</td>";
+    print "<td>" . $student['lastname'] . "&nbsp;&nbsp;</td>";
+    print "<td>" . $student['mnumber'] . "&nbsp;&nbsp;</td>";
+    print "<td>" . $student['blackboard'] . "</td>";
+    print "</tr>";
+  }
+  print "</table>";
+     
+?>
\ No newline at end of file
diff --git a/admin/include/banner.inc b/admin/include/banner.inc
new file mode 120000 (symlink)
index 0000000..33a8951
--- /dev/null
@@ -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 (symlink)
index 0000000..070e8c3
--- /dev/null
@@ -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 (file)
index 0000000..9bce2c3
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+  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))');
+      $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 (file)
index 0000000..29c15a8
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+  require 'banner.inc';
+  require 'nav.inc';
+?>
\ No newline at end of file
diff --git a/admin/include/nav.inc b/admin/include/nav.inc
new file mode 100644 (file)
index 0000000..d473d97
--- /dev/null
@@ -0,0 +1,21 @@
+<style type="text/css">
+  a:link { text-decoration:none; font-weight:normal; color:blue; }
+  a:visited { text-decoration:none; font-weight:normal; color:blue; }
+  a:hover { text-decoration:none; font-weight:normal; background-color:yellow; }
+  a:active { text-decoration:none; font-weight:normal; color:blue; }
+  a:focus { text-decoration:none; font-weight:normal; color:blue; }
+</style>
+
+<a href="summary.php">summary</a>
+ | 
+<a href="blackboard.php">blackboard</a>
+ | 
+<a href="sessions.php">sessions</a>
+ | 
+<a href="prefs.php">preferences</a>
+ | 
+<a href="password.php">password</a>
+ | 
+<a href="../">USER</a>
+
+<br><br>
diff --git a/admin/include/prefs.inc b/admin/include/prefs.inc
new file mode 120000 (symlink)
index 0000000..0325019
--- /dev/null
@@ -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 (symlink)
index 0000000..f5b0715
--- /dev/null
@@ -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 (symlink)
index 0000000..74acd8b
--- /dev/null
@@ -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 (file)
index 0000000..6459c94
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+  require 'include/head.inc';
+  require 'include/common.inc';
+
+  if(isset($_POST['submit']) && $_POST['password']!="") {
+
+    $fh_pass = fopen(".htpasswd", 'w');
+    fwrite($fh_pass, "admin:" . crypt($_POST['password'], base64_encode($_POST['password'])) . "\n");
+    fclose($fh_pass);
+
+    $fh_access = fopen(".htaccess", 'w');
+    fwrite($fh_access, "AuthUserFile " . getcwd() . "/.htpasswd\n");
+    fwrite($fh_access, "AuthGroupFile /dev/null\n");
+    fwrite($fh_access, "AuthName \"Banana Admin\"\n");
+    fwrite($fh_access, "AuthType Basic\n");
+    fwrite($fh_access, "require user admin\n");
+    fclose($fh_access);
+
+    block("lightgreen", "admin password set");
+    break;
+  }
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+  <table bgcolor="black">
+    <tr><th><b><font color="white">set admin password</font></b></th><tr>
+  </table>
+
+  <table>
+    <tr>  
+      <th align="left">Password:</th> <th><input type="text" name="password"></th>
+    </tr>
+  
+    <tr>
+      <th></th><th align="right" columnspan=2><input type="submit" name="submit" value="Set"></th>
+    </tr>
+  </table>
+</form>
diff --git a/admin/prefs.php b/admin/prefs.php
new file mode 100644 (file)
index 0000000..76e14d7
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+  require 'include/head.inc';
+  require 'include/db.inc';
+  require 'include/common.inc';
+  require 'include/prefs.inc';
+
+  if(isset($_POST['submit']) && $_POST['exname']!="" && $_POST['groupname']!="") {
+    $db->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;
+  }
+
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+  <?php block("black", "preferences"); ?>
+
+  <table>
+    <tr>  
+      <th align="left">Exercise Name:</th> <th><input type="text" name="exname" value="<?php echo $PREFS['exname'] ?>"></th>
+    </tr>
+
+    <tr>  
+      <th align="left">Group Name:</th> <th><input type="text" name="groupname" value="<?php echo $PREFS['groupname'] ?>"></th>
+    </tr>
+  
+    <tr>
+      <th></th><th align="right"><input type="submit" name="submit" value="Set"></th>
+    </tr>
+  </table>
+</form>
\ No newline at end of file
diff --git a/admin/sessions.php b/admin/sessions.php
new file mode 100644 (file)
index 0000000..a04f485
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+  require 'include/head.inc';
+  require 'include/db.inc';
+  require 'include/common.inc'; 
+
+  if(isset($_POST['submit']) && $_POST['stime']!="" && $_POST['examples']!="") {
+    $db->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");
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+  <table>
+    <tr>  
+      <th align="left">Time:</th> <th><input type="text" name="stime"></th><th></th><th>(e.g. 10.9.2012 10:30)</th>
+    </tr>
+    <tr>  
+      <th align="left">Examples:</th> <th><input type="text" name="examples"></th>
+      <th><input type="submit" name="submit" value="Add"></th><th>(e.g. 1a,1b,1c,2,3a,3b)</th>
+    </tr>
+  </table>
+</form>
+
+<?php
+  block("black", "session overview");
+
+  print "<table>";
+  foreach ($SESSIONS as $session) {
+    print "<tr>";
+    print "<td>" . $session['id'] . "&nbsp;&nbsp;</td>";
+    print "<td>" . $session['timestr'] . "&nbsp;&nbsp;</td>";
+    print "<td>" . $session['examples'] . "(" . $session['nexamples'] . ")" . "&nbsp;&nbsp;</td>";
+    if ($session['workdone'] == 0) {
+      print "<td><a href='sessions.php?delete=" . $session['id']  . "'>delete</a></td>";
+    }
+    else { print "<td>locked</td>"; }
+    print "</tr>";
+  }
+  print "</table>";
+     
+?>
\ No newline at end of file
diff --git a/admin/summary.php b/admin/summary.php
new file mode 100644 (file)
index 0000000..345f5a0
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+  require 'include/head.inc';
+  require 'include/db.inc';
+  require 'include/session.inc';
+  require 'include/common.inc';
+
+  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");
+
+  print "<table>";
+  print "<td><b>First name&nbsp;</b></td><td><b>Last name&nbsp;</b></td><td><b>Matr.nummer&nbsp;</b></td><td><b>Examples&nbsp;</b></td><td><b>Blackboard&nbsp;</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; }
+    print "<tr>";
+    print "<td>" . $student['firstname'] . "</td>";
+    print "<td>" . $student['lastname'] . "</td>";
+    print "<td>" . $student['mnumber'] . "</td>";
+    print "<td>" . $totexdone . "/" . $SESSIONS_totex . "</td>";
+    print "<td>" . $student['blackboard'] . "</td>";
+    print "</tr>";
+  }
+  print "</table>";
+
+?>
\ No newline at end of file
diff --git a/createdb.inc b/createdb.inc
deleted file mode 100644 (file)
index 05f2637..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-  if ($db = new PDO('sqlite:var/banane.db')) {
-    $db->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 (file)
index 77d7385..0000000
--- a/head.inc
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-  $lec_lines = file('var/lecture.txt');
-
-  foreach ($lec_lines as $line_num => $line) {
-    $lecture[$line_num] = $line;
-  }
-
-  print "<table>";
-    print "<tr><th align=\"left\">Banana Exercise Management</th><tr>";
-    print "<tr><th bgcolor=blue><font color=white> $lecture[0] $lecture[1], Group: $lecture[2] </font></th></tr>";
-  print "</table>";
-
-  print "<br>";
-?>
\ No newline at end of file
diff --git a/include/banner.inc b/include/banner.inc
new file mode 100644 (file)
index 0000000..1599111
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+  include 'prefs.inc';
+
+  $lec_lines = file('var/lecture.txt');
+
+  foreach ($lec_lines as $line_num => $line) {
+    $lecture[$line_num] = $line;
+  }
+
+  print "<table>";
+    print "<tr><th align=\"left\">Banana Exercise Management</th><tr>";
+    print "<tr><th bgcolor=blue><font color=white>&nbsp;" . $PREFS['exname'] . ", Gruppe: " . $PREFS['groupname'] . "&nbsp;</font></th></tr>";
+  print "</table>";
+
+  print "<br>";
+?>
diff --git a/include/common.inc b/include/common.inc
new file mode 100644 (file)
index 0000000..38de013
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+  function block($color, $text) {
+    print "<table bgcolor=\" $color \">";
+      print "<tr><th><b><font color=\"white\"> $text </font></b></th><tr>";
+    print "</table>";
+  }
+?>
diff --git a/include/db.inc b/include/db.inc
new file mode 100644 (file)
index 0000000..3612374
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+  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))');
+      $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 (file)
index 0000000..29c15a8
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+  require 'banner.inc';
+  require 'nav.inc';
+?>
\ No newline at end of file
diff --git a/include/nav.inc b/include/nav.inc
new file mode 100644 (file)
index 0000000..59f1950
--- /dev/null
@@ -0,0 +1,18 @@
+<style type="text/css">
+  a:link { text-decoration:none; font-weight:normal; color:blue; }
+  a:visited { text-decoration:none; font-weight:normal; color:blue; }
+  a:hover { text-decoration:none; font-weight:normal; background-color:yellow; }
+  a:active { text-decoration:none; font-weight:normal; color:blue; }
+  a:focus { text-decoration:none; font-weight:normal; color:blue; }
+</style>
+
+
+<a href="submit.php">submit</a>
+ | 
+<a href="summary.php">summary</a>
+ | 
+<a href="register.php">register</a>
+ | 
+<a href="admin">ADMIN</a>
+
+<br><br>
diff --git a/include/prefs.inc b/include/prefs.inc
new file mode 100644 (file)
index 0000000..58aac3e
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+  include 'db.inc';
+
+  $result = $db->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 (file)
index 0000000..7b5b798
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+  $result=$db->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 (file)
index 0000000..e6cab54
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+  require 'db.inc';
+
+  $mnumber = $_POST['mnumber'];
+  $password = $_POST['password'];
+
+  if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 0) {
+    print '<table bgcolor="red">';
+      print '<tr><th><b><font color="white">Mat.nummer not found</font></b></th><tr>';
+    print '</table>';
+    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 '<table bgcolor="red">';
+      print '<tr><th><b><font color="white">wrong password</font></b></th><tr>';
+    print '</table>';
+    break;
+  }
+  
+?>
\ No newline at end of file
diff --git a/lastsubmit.php b/lastsubmit.php
deleted file mode 100644 (file)
index c2577b9..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-  include 'nav.inc';
-  include 'lecture.inc';
-
-  if(isset($_POST['submit']) && $_POST['mnumber']!="") {
-    require 'createdb.inc';
-    require 'session.inc';
-
-    $mnumber = trim($_POST['mnumber']);
-    $password = trim($_POST['password']);
-
-    $sessionid = strtotime(end($sessions)[0]);
-
-    if (! ( $mnumber == 007 AND $password == 007 )) {
-      require 'usercheck.inc';
-      $result = $db->query("SELECT thisdone FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0];
-      if ($result == "") { 
-        print "<table bgcolor=\"red\">";
-          print "<tr><th><b><font color=\"white\">no submit</font></b></th><tr>";
-        print "</table>";
-        print "No results were submitted for " . end($sessions)[0] . ".";
-        break;
-      }
-      else {
-        print "<table bgcolor=\"lightgreen\">";
-          print "<tr><th><b><font color=\"white\">Last submit of $mnumber for " . end($sessions)[0] . "</font></b></th><tr>";
-        print "</table>";
-        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 "<table bgcolor=\"lightgreen\">";
-        print "<tr><th><b><font color=\"white\">Last submits for " . end($sessions)[0] . "</font></b></th><tr>";
-      print "</table>";
-
-      print "<table>";
-
-      while ($row = $result->fetch(PDO::FETCH_NUM)) {
-        print "<tr>";
-        echo "<td>$row[0] $row[1] &nbsp;&nbsp;</td> <td>$row[2] &nbsp;&nbsp;</td> <td>$row[4] &nbsp;&nbsp;</td> <td>$row[3]/$lstsession_nex </td>";
-        print "</tr>";
-      }
-
-      print "</table>";
-    }
-
-    break;
-  }
-?>
-
-<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-  <table bgcolor="black">
-    <tr><th><b><font color="white">Last submission</font></b></th><tr>
-  </table>
-
-  <table>
-    <tr>  
-      <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
-    </tr>
-    <tr>  
-      <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
-    </tr>
-    <tr><th colspan=2></th></tr>
-
-    <tr>
-      <th align="left"><input type="submit" name="submit" value="Show"></th> <th></th>
-    </tr>
-  </table>
-</form>
diff --git a/lecture.inc b/lecture.inc
deleted file mode 100644 (file)
index b431d8d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-  $lec_lines = file('var/lecture.txt');
-  foreach ($lec_lines as $line_num => $line) {
-    $lecture[$line_num] = $line;
-  }
-?>
diff --git a/nav.inc b/nav.inc
deleted file mode 100644 (file)
index f69d3e8..0000000
--- a/nav.inc
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-  require "head.inc";
-?>
-
-<style type="text/css">
-  a:link { text-decoration:none; font-weight:normal; color:blue; }
-  a:visited { text-decoration:none; font-weight:normal; color:blue; }
-  a:hover { text-decoration:none; font-weight:normal; background-color:yellow; }
-  a:active { text-decoration:none; font-weight:normal; color:blue; }
-  a:focus { text-decoration:none; font-weight:normal; color:blue; }
-</style>
-
-
-<a href="submit.php">submit</a>
- | 
-<a href="register.php">register</a>
- | 
-<a href="lastsubmit.php">last submit</a>
-
-<br><br>
index 69b99fe..0a844ac 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-require 'nav.inc';
+require 'include/head.inc';
 
 if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!="" 
                           && $_POST['mnumber']!="" && $_POST['email']!="" && $_POST['password']!="")
@@ -10,7 +10,7 @@ if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!=""
   $email = $_POST['email'];
   $password = $_POST['password'];
 
-  require 'createdb.inc';
+  require 'include/db.inc';
 
   // user already exists //
   if($db->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 (file)
index 30bae4d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-  $lines_sessions = file('var/sessions.txt');
-
-  foreach ($lines_sessions as $line_num => $line) {
-    $sessions[$line_num] = explode("\t",$line);
-  }
-
-  $lstsession_nex = count(explode(',',end($sessions)[1]));
-?>
index 2e88c85..aabc3fe 100644 (file)
@@ -1,26 +1,20 @@
 <?php
-  require 'nav.inc';
+  require 'include/head.inc';
+  require 'include/session.inc';
+  require 'include/common.inc';
 
-  $lines = file('var/sessions.txt');
-
-  foreach ($lines as $line_num => $line) {
-    $sessions[$line_num] = explode("\t",$line);
-  }
-
-  if ( strtotime("now") > strtotime(end($sessions)[0]) ) {
-    print '<table bgcolor="red">';
-      print '<tr><th><b><font color="white">submission closed</font></b></th><tr>';
-    print '</table>';
+  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 '<table bgcolor="red">';
     break;
   }
 
-  if(trim(end($sessions)[0]) == "") {
-    print '<table bgcolor="red">';
-      print '<tr><th><b><font color="white">no exercises defined</font></b></th><tr>';
-    print '</table>';
-    break;
-  }
-
 ?>
 
   <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
   <table bgcolor="black">
-    <tr><th><b><font color="white">submit examples for <?php echo end($sessions)[0]; ?></font></b></th><tr>
+    <tr><th><b><font color="white">submit examples for <?php echo $SESSIONS[$SESSIONS_next]['timestr']; ?></font></b></th><tr>
   </table>
 
   <table>
@@ -72,7 +59,7 @@
 
         <?php
           $exnum=0;
-         foreach (explode(",",end($sessions)[1]) as $exid) {
+         foreach (explode(",",$SESSIONS[$SESSIONS_next]['examples']) as $exid) {
            print " <input type='checkbox' name='exchecked[]' value=$exid>$exid ";
            $exnum++;
            if ($exnum%3 == 0) { print ""; }
diff --git a/summary.php b/summary.php
new file mode 100644 (file)
index 0000000..3354ca3
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+  require 'include/head.inc';
+  require 'include/db.inc';
+  require 'include/session.inc';
+  require 'include/common.inc';
+
+  if(isset($_POST['submit']) && $_POST['mnumber']!="") {
+    $mnumber = trim($_POST['mnumber']);
+    $password = trim($_POST['password']);
+    
+    require 'include/usercheck.inc';
+
+    block("black", "summary for " . $_POST['mnumber']);
+
+    print "<b>Examples Submitted</b>";
+    print "<table>";
+
+    $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 "<tr>";
+      print "<td>" . $session['timestr'] . "&nbsp;&nbsp;</td>";
+      print "<td>" . $session['examples'] . "(" . $session['nexamples'] . ")" . "&nbsp;&nbsp;</td>";
+      print "<td>" . $exdone[1] . "/" . $session['nexamples'] . "(" . $exdone[0] . ")" . "&nbsp;&nbsp;</td>";
+      print "</tr>";
+    }
+    print "<tr>";
+    print "<td></td><td></td><td><b>" . $tot_done . "/" . $SESSIONS_totex . "</b></td>";
+    print "</tr>";
+
+    print "</table>";
+
+    print "<br>";
+
+    print "<b>Blackboard</b>";
+    $blackdone = $db->query("SELECT blackboard FROM students WHERE mnumber=" . $mnumber)->fetch(PDO::FETCH_NUM)[0];
+    
+    print "<br>";
+
+    for( $ib=0; $ib<$blackdone; $ib++ ) { echo "&nbsp;*&nbsp;"; }
+
+    break;
+  }  
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+  <table bgcolor="black">
+    <tr><th><b><font color="white">Last submission</font></b></th><tr>
+  </table>
+
+  <table>
+    <tr>  
+      <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
+    </tr>
+    <tr>  
+      <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
+    </tr>
+    <tr><th colspan=2></th></tr>
+
+    <tr>
+      <th align="left"><input type="submit" name="submit" value="Show"></th> <th></th>
+    </tr>
+  </table>
+</form>
diff --git a/usercheck.inc b/usercheck.inc
deleted file mode 100644 (file)
index 19e51d3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-  require 'createdb.inc';
-
-  $mnumber = $_POST['mnumber'];
-  $password = $_POST['password'];
-
-  if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 0) {
-    print '<table bgcolor="red">';
-      print '<tr><th><b><font color="white">Mat.nummer not found</font></b></th><tr>';
-    print '</table>';
-    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 '<table bgcolor="red">';
-      print '<tr><th><b><font color="white">wrong password</font></b></th><tr>';
-    print '</table>';
-    break;
-  }
-  
-?>
\ No newline at end of file
diff --git a/var/.gitignore b/var/.gitignore
deleted file mode 100644 (file)
index 27fc3b0..0000000
+++ /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 (file)
index 577ca1e..0000000
+++ /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 (file)
index 25eb55d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-27.09.2012 10:30       1a,1b,1c,2a,2b,3