]> git.treefish.org Git - banana.git/blob - summary.php
d63c765add8912c4629db9b331cf90d7fc8e4cb4
[banana.git] / summary.php
1 <?php
2   require 'include/head.inc';
3   require 'include/db.inc';
4   require 'include/session.inc';
5   require 'include/common.inc';
6
7   if(isset($_POST['submit']) && $_POST['mnumber']!="") {
8     $mnumber = trim($_POST['mnumber']);
9     $password = trim($_POST['password']);
10     
11     require 'include/usercheck.inc';
12
13     block("black", "summary for " . $_POST['mnumber']);
14
15     if ( isset($SESSIONS_next) ) {
16        print "<b>Submitted for next session on " . $SESSIONS[$SESSIONS_next]['timestr']  . "</b>";
17
18        print "<table>";
19
20        if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $SESSIONS_next")->fetch(PDO::FETCH_NUM)[0] == 0) {
21          print "<tr><td>0 (0/" . $SESSIONS[$SESSIONS_next]['nexamples'] . ")</td></tr>";
22        }
23        else {
24          $wdone = $db->query("SELECT thisdone,manydone FROM workdone WHERE mnumber = $mnumber AND session = $SESSIONS_next")->fetch(PDO::FETCH_NUM);
25          print "<tr><td>" . $wdone[0] . "&nbsp;(" . $wdone[1] . "/" . $SESSIONS[$SESSIONS_next]['nexamples'] . ")</td></tr><br>";
26        }
27
28        print "</table>";
29
30        print "<br>";
31     }
32
33     print "<b>Examples submitted so far</b>";
34     print "<table>";
35
36     $tot_done = 0;
37
38     if( isset($SESSIONS) ) {
39       foreach ($SESSIONS as $session) {
40         if ( isset($SESSIONS_next) ) {
41           if ($session['id'] == $SESSIONS_next) { break; }
42         }        
43
44         $exdone = $db->query("SELECT thisdone, manydone FROM workdone WHERE mnumber=" . $mnumber . " AND session=" . $session['id'])->fetch(PDO::FETCH_NUM);
45
46         if ( $exdone[1] == "" ) { $exdone[1] = "0"; }
47
48         $tot_done = $tot_done + $exdone[1];
49
50         print "<tr>";
51         print "<td>" . $session['timestr'] . "&nbsp;&nbsp;</td>";
52         print "<td>" . $session['examples'] . "(" . $session['nexamples'] . ")" . "&nbsp;&nbsp;</td>";
53         print "<td>" . $exdone[1] . "/" . $session['nexamples'] . "(" . $exdone[0] . ")" . "&nbsp;&nbsp;</td>";
54         print "</tr>";
55       }
56     }
57     print "<tr>";
58     print "<td></td><td></td><td><b>" . $tot_done . "/" . $SESSIONS_totex . "</b></td>";
59     print "</tr>";
60
61     print "</table>";
62
63     print "<br>";
64
65     print "<b>Blackboard</b>";
66     $blackdone = $db->query("SELECT blackboard FROM students WHERE mnumber=" . $mnumber)->fetch(PDO::FETCH_NUM)[0];
67     
68     print "<br>";
69
70     for( $ib=0; $ib<$blackdone; $ib++ ) { echo "&nbsp;*&nbsp;"; }
71
72     exit;
73   }  
74 ?>
75
76 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
77   <table bgcolor="black">
78     <tr><th><b><font color="white">Summary</font></b></th><tr>
79   </table>
80
81   <table>
82     <tr>  
83       <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
84     </tr>
85     <tr>  
86       <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
87     </tr>
88     <tr><th colspan=2></th></tr>
89
90     <tr>
91       <th align="left"><input type="submit" name="submit" value="Show"></th> <th></th>
92     </tr>
93   </table>
94 </form>