4 $lines = file('var/sessions.txt');
6 foreach ($lines as $line_num => $line) {
7 $sessions[$line_num] = explode("\t",$line);
10 if ( strtotime("now") > strtotime(end($sessions)[0]) ) {
11 print '<table bgcolor="red">';
12 print '<tr><th><b><font color="white">submission closed</font></b></th><tr>';
17 if(isset($_POST['submit']) && $_POST['mnumber']!="") {
18 require 'usercheck.inc';
20 $exchecked = $_POST['exchecked'];
22 $mnumber = $_POST['mnumber'];
23 $sessionid = strtotime(end($sessions)[0]);
25 if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0] == 1) {
26 print '<table bgcolor="red">';
27 print '<tr><th><b><font color="white">You already submitted results for this session</font></b></th><tr>';
29 print "You can only submit your calculated examples once!";
33 $excount = count($exchecked);
34 $donestring = implode(', ', $exchecked);
36 $db->query("INSERT INTO workdone (mnumber,session,manydone,thisdone)
37 VALUES (\"$mnumber\", \"$sessionid\", \"$excount\", \"$donestring\")");
39 print '<table bgcolor="lightgreen">';
40 print '<tr><th><b><font color="white">submitted</font></b></th><tr>';
45 if(trim(end($sessions)[0]) == "") {
46 print '<table bgcolor="red">';
47 print '<tr><th><b><font color="white">no exercises defined</font></b></th><tr>';
54 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
55 <table bgcolor="black">
56 <tr><th><b><font color="white">submit examples for <?php echo end($sessions)[0]; ?></font></b></th><tr>
61 <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
64 <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
67 <tr><th colspan=2></th></tr>
70 <th align="left">Examples:</th>
75 foreach (explode(",",end($sessions)[1]) as $exid) {
76 print " <input type='checkbox' name='exchecked[]' value=$exid>$exid ";
78 if ($exnum%3 == 0) { print ""; }
84 <tr><th colspan=2></th></tr>
87 <th align="left"><input type="submit" name="submit" value="Submit"></th> <th></th>