From: Alexander Schmidt Date: Tue, 25 Sep 2012 15:18:25 +0000 (+0200) Subject: ... X-Git-Url: https://git.treefish.org/banana.git/commitdiff_plain/2c45a56043747bc7b524cdff4d00ff925b1a9544?ds=sidebyside ... --- 2c45a56043747bc7b524cdff4d00ff925b1a9544 diff --git a/createdb.inc b/createdb.inc new file mode 100644 index 0000000..05f2637 --- /dev/null +++ b/createdb.inc @@ -0,0 +1,8 @@ +query('CREATE TABLE IF NOT EXISTS students + (mnumber int, firstname string, lastname string, email string, password string, PRIMARY KEY (mnumber))'); + $db->query('CREATE TABLE IF NOT EXISTS workdone + (mnumber int, session int, manydone int, thisdone string)'); + } +?> diff --git a/head.inc b/head.inc new file mode 100644 index 0000000..77d7385 --- /dev/null +++ b/head.inc @@ -0,0 +1,15 @@ + $line) { + $lecture[$line_num] = $line; + } + + print ""; + print ""; + print ""; + print "
Banana Exercise Management
$lecture[0] $lecture[1], Group: $lecture[2]
"; + + print "
"; +?> \ No newline at end of file diff --git a/lastsubmit.php b/lastsubmit.php new file mode 100644 index 0000000..19abb2b --- /dev/null +++ b/lastsubmit.php @@ -0,0 +1,65 @@ +query("SELECT thisdone FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0]; + if ($result == "") { + print ""; + print ""; + print "
no submit
"; + print "No results were submitted for " . end($sessions)[0] . "."; + break; + } + else { + print $result; + } + } + else { + $result = $db->query("SELECT students.firstname, students.lastname, students.mnumber, workdone.manydone, workdone.thisdone FROM workdone, students WHERE workdone.session = $sessionid AND workdone.mnumber = students.mnumber"); + //print $result[0]; + + print ""; + + while ($row = $result->fetch(PDO::FETCH_NUM)) { + print ""; + echo ""; + print ""; + } + + print "
$row[0] $row[1]    $row[2]    $row[4]    $row[3]/$lstsession_nex
"; + } + + break; + } +?> + +
+ + +
Last submission
+ + + + + + + + + + + + + +
Mat.nummer:
Password:
+
diff --git a/lecture.inc b/lecture.inc new file mode 100644 index 0000000..b431d8d --- /dev/null +++ b/lecture.inc @@ -0,0 +1,6 @@ + $line) { + $lecture[$line_num] = $line; + } +?> diff --git a/nav.inc b/nav.inc new file mode 100644 index 0000000..f69d3e8 --- /dev/null +++ b/nav.inc @@ -0,0 +1,20 @@ + + + + + +submit + | +register + | +last submit + +

diff --git a/register.php b/register.php new file mode 100644 index 0000000..69b99fe --- /dev/null +++ b/register.php @@ -0,0 +1,76 @@ +query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 1) { + print ""; + print ""; + print "
user already registered
"; + break; + } + + $db->query("INSERT INTO students (mnumber,firstname,lastname,email,password) + VALUES (\"$mnumber\",\"$firstname\",\"$lastname\",\"$email\",\"$password\")"); + + print ""; + print ""; + print "
registration successfull
"; + + echo "$firstname $lastname was successfully registered.
"; + + // send password-email // + $lec_lines = file('var/lecture.txt'); + foreach ($lec_lines as $line_num => $line) { + $lecture[$line_num] = $line; + } + $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . trim($lecture[0]) . " " . trim($lecture[1]) . ".\nRemember your password: $password\n\nYours,\nBanana."; + //$nachricht = wordwrap($nachricht,70); + $empfaenger = 'niemand@example.com'; + $betreff = 'Der Betreff'; + $header = 'From: banana@treefish.org' . "\r\n" . + 'Reply-To: noreply@treefish.org' . "\r\n" . + 'X-Mailer: PHP/' . phpversion(); + mail($email, "Banana Registration: " . trim($lecture[0]) . " " . trim($lecture[1]), $nachricht, $header); + + break; +} +?> + +
+ + +
registration
+ + + + + + + + + + + + + + + + + + + + + +
First name:
Last name:
Mat.nummer:
Email:
Password:
+
diff --git a/session.inc b/session.inc new file mode 100644 index 0000000..30bae4d --- /dev/null +++ b/session.inc @@ -0,0 +1,9 @@ + $line) { + $sessions[$line_num] = explode("\t",$line); + } + + $lstsession_nex = count(explode(',',end($sessions)[1])); +?> diff --git a/submit.php b/submit.php new file mode 100644 index 0000000..69d9ab8 --- /dev/null +++ b/submit.php @@ -0,0 +1,82 @@ + $line) { + $sessions[$line_num] = explode("\t",$line); + } + + if ( strtotime("now") > strtotime(end($sessions)[0]) ) { + print ''; + print ''; + print '
submission closed
'; + break; + } + + if(isset($_POST['submit']) && $_POST['mnumber']!="") { + require 'usercheck.inc'; + + $exchecked = $_POST['exchecked']; + + $mnumber = $_POST['mnumber']; + $sessionid = strtotime(end($sessions)[0]); + + if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0] == 1) { + print ''; + print ''; + print '
You already submitted results for this session
'; + print "You can only submit your calculated examples once!"; + break; + } + + $excount = count($exchecked); + $donestring = implode(', ', $exchecked); + + $db->query("INSERT INTO workdone (mnumber,session,manydone,thisdone) + VALUES (\"$mnumber\", \"$sessionid\", \"$excount\", \"$donestring\")"); + + print ''; + print ''; + print '
submitted
'; + break; + } +?> + +
+ + +
submit examples for
+ + + + + + + + + + + + + + + + + + + + + +
Mat.nummer:
Password:
Examples: + + $exid "; + $exnum++; + if ($exnum%3 == 0) { print ""; } + } + ?> +
+
diff --git a/usercheck.inc b/usercheck.inc new file mode 100644 index 0000000..19e51d3 --- /dev/null +++ b/usercheck.inc @@ -0,0 +1,22 @@ +query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 0) { + print ''; + print ''; + print '
Mat.nummer not found
'; + print "Mat.Nummer was not found. You have to register first!"; + break; + } + + if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber AND password = \"$password\"")->fetch(PDO::FETCH_NUM)[0] == 0) { + print ''; + print ''; + print '
wrong password
'; + break; + } + +?> \ No newline at end of file diff --git a/var/lecture.txt.sample b/var/lecture.txt.sample new file mode 100644 index 0000000..577ca1e --- /dev/null +++ b/var/lecture.txt.sample @@ -0,0 +1,3 @@ +Theoretische Mechanik +WS2012 +Alex diff --git a/var/sessions.txt.sample b/var/sessions.txt.sample new file mode 100644 index 0000000..25eb55d --- /dev/null +++ b/var/sessions.txt.sample @@ -0,0 +1 @@ +27.09.2012 10:30 1a,1b,1c,2a,2b,3