From: Alexander Schmidt Date: Thu, 29 Nov 2012 13:39:19 +0000 (+0100) Subject: added exams X-Git-Url: https://git.treefish.org/banana.git/commitdiff_plain/7c6abf783f4b583b0c8bc43ad434fcce37a3dcc7?ds=sidebyside;hp=7b7a9103e0252d7accb3c456e0f16e50ce3ace96 added exams --- diff --git a/admin/include/db.inc b/admin/include/db.inc index 9bce2c3..7c4da1d 100644 --- a/admin/include/db.inc +++ b/admin/include/db.inc @@ -1,14 +1,18 @@ query('CREATE TABLE IF NOT EXISTS students - (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, PRIMARY KEY (mnumber))'); + $db->query('CREATE TABLE IF NOT EXISTS students + (mnumber int, firstname string, lastname string, email string, password string, blackboard int DEFAULT 0, lastblackboard TIMESTAMP, PRIMARY KEY (mnumber))'); $db->query('CREATE TABLE IF NOT EXISTS workdone - (mnumber int, session int, manydone int, thisdone string)'); + (mnumber int, session int, manydone int, thisdone string, tstamp TIMESTAMP)'); $db->query('CREATE TABLE IF NOT EXISTS prefs (key string, value string, PRIMARY KEY (key))'); $db->query('CREATE TABLE IF NOT EXISTS sessions - (id int NOT NULL, timestr string NOT NULL, PRIMARY KEY (id))'); + (id int NOT NULL, examples string, nexamples int, PRIMARY KEY (id))'); + $db->query('CREATE TABLE IF NOT EXISTS exams + (id int NOT NULL, score string, PRIMARY KEY (id))'); + $db->query('CREATE TABLE IF NOT EXISTS examscore + (mnumber int, exam int, scorestr string, tstamp TIMESTAMP)'); } } ?> diff --git a/admin/include/nav.inc b/admin/include/nav.inc index 1aa06bb..b4b7df8 100644 --- a/admin/include/nav.inc +++ b/admin/include/nav.inc @@ -8,12 +8,16 @@ session overview | +exam overview + | summary | blackboard | sessions | +exams + | preferences | password diff --git a/admin/summary.php b/admin/summary.php index 71ea061..3ed725d 100644 --- a/admin/summary.php +++ b/admin/summary.php @@ -2,6 +2,7 @@ require 'include/head.inc'; require 'include/db.inc'; require 'include/session.inc'; + require 'include/exams.inc'; require 'include/common.inc'; if ($db->query("SELECT COUNT(*) FROM students")->fetch(PDO::FETCH_NUM)[0] == 0) { @@ -14,21 +15,42 @@ $result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY LOWER(lastname)"); print ""; - print ""; + print ""; + while ($student = $result->fetch(PDO::FETCH_ASSOC)) { $totexdone = 0; if( $db->query("SELECT COUNT(*) FROM workdone WHERE mnumber=" . $student['mnumber'])->fetch(PDO::FETCH_NUM)[0] > 0 ) { $exdone = $db->query("SELECT manydone FROM workdone WHERE mnumber=" . $student['mnumber']); while ( $subdone = $exdone->fetch(PDO::FETCH_NUM) ) { $totexdone += $subdone[0]; } } + + $examscore=0; + foreach ($EXAMS as $exam) { + $scorestr = $db->query("SELECT scorestr FROM examscore WHERE mnumber=" . $student['mnumber'] . " AND exam=" . $exam['id'])->fetch(PDO::FETCH_NUM)[0]; + if ($scorestr != "") { + $singlescore = 0; + foreach (explode(',',$scorestr) as $points) { $singlescore = $singlescore + $points; } + $examscore = $examscore + $singlescore/$exam['totscore']; + } + } + $examscore = ($examscore / $EXAMS_n)*100; + print ""; print ""; print ""; print ""; - print ""; - print ""; + print ""; + print ""; + print ""; print ""; } + print "
First name Last name Matr.nummer Examples Blackboard First name Last name Matr.nummer Blackboard Examples Exams 
" . $student['firstname'] . "" . $student['lastname'] . "" . $student['mnumber'] . "" . $totexdone . "/" . $SESSIONS_totex_nextinc . "" . $student['blackboard'] . ""; + print($student['blackboard']); + print ""; + printf("%3d", round(100 * floatval($totexdone) / floatval($SESSIONS_totex_nextinc))); + print "%"; + printf("%3d", round($examscore)); + print "%
"; ?> \ No newline at end of file diff --git a/include/db.inc b/include/db.inc index 16e36f9..efd7aae 100644 --- a/include/db.inc +++ b/include/db.inc @@ -8,7 +8,11 @@ $db->query('CREATE TABLE IF NOT EXISTS prefs (key string, value string, PRIMARY KEY (key))'); $db->query('CREATE TABLE IF NOT EXISTS sessions - (id int NOT NULL, examples string, nexamples int, PRIMARY KEY (id))'); + (id int NOT NULL, examples string, nexamples int, PRIMARY KEY (id))'); + $db->query('CREATE TABLE IF NOT EXISTS exams + (id int NOT NULL, score string, PRIMARY KEY (id))'); + $db->query('CREATE TABLE IF NOT EXISTS examscore + (mnumber int, exam int, scorestr string, tstamp TIMESTAMP)'); } } ?> diff --git a/summary.php b/summary.php index d63c765..3ebfea9 100644 --- a/summary.php +++ b/summary.php @@ -3,6 +3,7 @@ require 'include/db.inc'; require 'include/session.inc'; require 'include/common.inc'; + require 'include/exams.inc'; if(isset($_POST['submit']) && $_POST['mnumber']!="") { $mnumber = trim($_POST['mnumber']); @@ -55,13 +56,45 @@ } } print ""; - print "" . $tot_done . "/" . $SESSIONS_totex . ""; + print "" . $tot_done . "/" . $SESSIONS_totex . " ==> " . round(100 * $tot_done / $SESSIONS_totex) . "%"; print ""; print ""; print "
"; + print "Exams
"; + + print ""; + + $examscore=0; + foreach ($EXAMS as $exam) { + $scorestr = $db->query("SELECT scorestr FROM examscore WHERE mnumber=" . $mnumber . " AND exam=" . $exam['id'])->fetch(PDO::FETCH_NUM)[0]; + $singlescore = 0; + if ($scorestr != "") { + foreach (explode(',',$scorestr) as $points) { $singlescore = $singlescore + $points; } + $examscore = $examscore + $singlescore/$exam['totscore']; + } + + print ""; + print ""; + print ""; + print ""; + print ""; + } + $examscore = ($examscore / $EXAMS_n)*100; + + if ($EXAMS_n > 0 ) { + print ""; + print ""; + print ""; + print ""; + } + + print "
" . $exam['timestr'] . "  {" . $scorestr . "}=" . $singlescore . "/" . $exam['totscore'] . "  " . round(100*$singlescore/$exam['totscore']) . "%  
" . round($examscore) . "%
"; + + print "
"; + print "Blackboard"; $blackdone = $db->query("SELECT blackboard FROM students WHERE mnumber=" . $mnumber)->fetch(PDO::FETCH_NUM)[0];