]> git.treefish.org Git - banana.git/blob - admin/exams.php
forgot some files.
[banana.git] / admin / exams.php
1 <?php
2   require 'include/head.inc';
3   require 'include/db.inc';
4   require 'include/common.inc'; 
5
6   if(isset($_POST['submit']) && $_POST['stime']!="" && $_POST['score']!="") {
7     $db->query("INSERT INTO exams (id,score) VALUES (" . strtotime(trim($_POST['stime'])) . ",'" . $_POST['score'] . "')");
8     block("lightgreen", "added exam");
9   }
10
11   if(isset($_GET['delete'])) {
12     $db->query("DELETE FROM exams WHERE id=" . $_GET['delete']);
13     block("red", "deleted exam");
14   }
15
16   require 'include/exams.inc';
17
18   block("black", "add exam");
19 ?>
20
21 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
22   <table>
23     <tr>  
24       <th align="left">Time:</th> <th><input type="text" name="stime"></th><th></th><th>(e.g. 10.9.2012 10:30)</th>
25     </tr>
26     <tr>  
27       <th align="left">Score:</th> <th><input type="text" name="score"></th>
28       <th><input type="submit" name="submit" value="Add"></th><th>(e.g. 4,5,5)</th>
29     </tr>
30   </table>
31 </form>
32
33 <?php
34   if ( $EXAMS_n == 0 ) {
35     block("red", "no exams defined");
36     exit;
37   }
38
39   block("black", "exam overview");
40
41   print "<table>";
42   foreach ($EXAMS as $exam) {
43     print "<tr>";
44     print "<td>" . $exam['id'] . "&nbsp;&nbsp;</td>";
45     print "<td>" . $exam['timestr'] . "&nbsp;&nbsp;</td>";
46     print "<td>" . $exam['scorestr'] . "(" . $exam['nquests'] . ")" . "&nbsp;&nbsp;</td>";
47     print "<td>" . $exam['totscore'] . "&nbsp;&nbsp;</td>";
48     if ($exam['nresults'] == 0) {
49       print "<td><a href='exams.php?delete=" . $exam['id']  . "'>delete</a></td>";
50     }
51     else { print "<td>locked</td>"; }
52     print "</tr>";
53   }
54   print "</table>";
55      
56 ?>