]> git.treefish.org Git - banana.git/blob - summary.php
forgot some files.
[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   require 'include/exams.inc';
7
8   if(isset($_POST['submit']) && $_POST['mnumber']!="") {
9     $mnumber = trim($_POST['mnumber']);
10     $password = trim($_POST['password']);
11     
12     require 'include/usercheck.inc';
13
14     block("black", "summary for " . $_POST['mnumber']);
15
16     if ( isset($SESSIONS_next) ) {
17        print "<b>Submitted for next session on " . $SESSIONS[$SESSIONS_next]['timestr']  . "</b>";
18
19        print "<table>";
20
21        if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $SESSIONS_next")->fetch(PDO::FETCH_NUM)[0] == 0) {
22          print "<tr><td>0 (0/" . $SESSIONS[$SESSIONS_next]['nexamples'] . ")</td></tr>";
23        }
24        else {
25          $wdone = $db->query("SELECT thisdone,manydone FROM workdone WHERE mnumber = $mnumber AND session = $SESSIONS_next")->fetch(PDO::FETCH_NUM);
26          print "<tr><td>" . $wdone[0] . "&nbsp;(" . $wdone[1] . "/" . $SESSIONS[$SESSIONS_next]['nexamples'] . ")</td></tr><br>";
27        }
28
29        print "</table>";
30
31        print "<br>";
32     }
33
34     print "<b>Examples submitted so far</b>";
35     print "<table>";
36
37     $tot_done = 0;
38
39     if( isset($SESSIONS) ) {
40       foreach ($SESSIONS as $session) {
41         if ( isset($SESSIONS_next) ) {
42           if ($session['id'] == $SESSIONS_next) { break; }
43         }        
44
45         $exdone = $db->query("SELECT thisdone, manydone FROM workdone WHERE mnumber=" . $mnumber . " AND session=" . $session['id'])->fetch(PDO::FETCH_NUM);
46
47         if ( $exdone[1] == "" ) { $exdone[1] = "0"; }
48
49         $tot_done = $tot_done + $exdone[1];
50
51         print "<tr>";
52         print "<td>" . $session['timestr'] . "&nbsp;&nbsp;</td>";
53         print "<td>" . $session['examples'] . "(" . $session['nexamples'] . ")" . "&nbsp;&nbsp;</td>";
54         print "<td>" . $exdone[1] . "/" . $session['nexamples'] . "(" . $exdone[0] . ")" . "&nbsp;&nbsp;</td>";
55         print "</tr>";
56       }
57     }
58     print "<tr>";
59     print "<td></td><td></td><td><b>" . $tot_done . "/" . $SESSIONS_totex . " ==> " . round(100 * $tot_done / $SESSIONS_totex) . "%</b></td>";
60     print "</tr>";
61
62     print "</table>";
63
64     print "<br>";
65
66     print "<b>Exams</b><br>";
67
68     print "<table>";
69
70     $examscore=0;
71     foreach ($EXAMS as $exam) {
72       $scorestr = $db->query("SELECT scorestr FROM examscore WHERE mnumber=" . $mnumber . " AND exam=" . $exam['id'])->fetch(PDO::FETCH_NUM)[0];
73       $singlescore = 0;
74       if ($scorestr != "") {
75         foreach (explode(',',$scorestr) as $points) { $singlescore = $singlescore + $points; }
76         $examscore = $examscore + $singlescore/$exam['totscore']; 
77       }
78       
79       print "<tr>";
80       print "<td>" . $exam['timestr'] . "&nbsp;&nbsp;</td>";
81       print "<td>{" . $scorestr . "}=" . $singlescore . "/" . $exam['totscore'] . "&nbsp;&nbsp;</td>";
82       print "<td>" . round(100*$singlescore/$exam['totscore']) . "%&nbsp;&nbsp;</td>";
83       print "</tr>";
84     }
85     $examscore = ($examscore / $EXAMS_n)*100;
86
87     if ($EXAMS_n > 0 ) {
88       print "<tr>";
89       print "<td></td><td></td>";
90       print "<td><b>" . round($examscore) . "%</b></td>";            
91       print "</tr>";
92     }
93
94     print "</table>";
95
96     print "<br>";
97
98     print "<b>Blackboard</b>";
99     $blackdone = $db->query("SELECT blackboard FROM students WHERE mnumber=" . $mnumber)->fetch(PDO::FETCH_NUM)[0];
100     
101     print "<br>";
102
103     for( $ib=0; $ib<$blackdone; $ib++ ) { echo "&nbsp;*&nbsp;"; }
104
105     exit;
106   }  
107 ?>
108
109 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
110   <table bgcolor="black">
111     <tr><th><b><font color="white">Summary</font></b></th><tr>
112   </table>
113
114   <table>
115     <tr>  
116       <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
117     </tr>
118     <tr>  
119       <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
120     </tr>
121     <tr><th colspan=2></th></tr>
122
123     <tr>
124       <th align="left"><input type="submit" name="submit" value="Show"></th> <th></th>
125     </tr>
126   </table>
127 </form>