]> git.treefish.org Git - banana.git/blobdiff - admin/exams.php
forgot some files.
[banana.git] / admin / exams.php
diff --git a/admin/exams.php b/admin/exams.php
new file mode 100644 (file)
index 0000000..902956b
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+  require 'include/head.inc';
+  require 'include/db.inc';
+  require 'include/common.inc'; 
+
+  if(isset($_POST['submit']) && $_POST['stime']!="" && $_POST['score']!="") {
+    $db->query("INSERT INTO exams (id,score) VALUES (" . strtotime(trim($_POST['stime'])) . ",'" . $_POST['score'] . "')");
+    block("lightgreen", "added exam");
+  }
+
+  if(isset($_GET['delete'])) {
+    $db->query("DELETE FROM exams WHERE id=" . $_GET['delete']);
+    block("red", "deleted exam");
+  }
+
+  require 'include/exams.inc';
+
+  block("black", "add exam");
+?>
+
+<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">Score:</th> <th><input type="text" name="score"></th>
+      <th><input type="submit" name="submit" value="Add"></th><th>(e.g. 4,5,5)</th>
+    </tr>
+  </table>
+</form>
+
+<?php
+  if ( $EXAMS_n == 0 ) {
+    block("red", "no exams defined");
+    exit;
+  }
+
+  block("black", "exam overview");
+
+  print "<table>";
+  foreach ($EXAMS as $exam) {
+    print "<tr>";
+    print "<td>" . $exam['id'] . "&nbsp;&nbsp;</td>";
+    print "<td>" . $exam['timestr'] . "&nbsp;&nbsp;</td>";
+    print "<td>" . $exam['scorestr'] . "(" . $exam['nquests'] . ")" . "&nbsp;&nbsp;</td>";
+    print "<td>" . $exam['totscore'] . "&nbsp;&nbsp;</td>";
+    if ($exam['nresults'] == 0) {
+      print "<td><a href='exams.php?delete=" . $exam['id']  . "'>delete</a></td>";
+    }
+    else { print "<td>locked</td>"; }
+    print "</tr>";
+  }
+  print "</table>";
+     
+?>
\ No newline at end of file