diff --git a/includes/classes/class.dataitem.php b/includes/classes/class.dataitem.php
index fb75983..e3a81c4 100755
--- a/includes/classes/class.dataitem.php
+++ b/includes/classes/class.dataitem.php
@@ -12,7 +12,14 @@ class DataItem {
$db = new db();
$db->query("SELECT * FROM `".static::_getType()."` WHERE ".static::_getType()."_id = :id");
$db->bind(":id", $id);
- return $db->getObject();
+ $result = $db->single();
+ if(!$result) return false;
+ $className = static::_getClass();
+ $obj = new $className();
+ foreach ($result as $key=>$val) {
+ $obj->$key = $val;
+ }
+ return $obj;
}
private function _getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
diff --git a/index.php b/index.php
index 4a6b66e..52cbfdb 100755
--- a/index.php
+++ b/index.php
@@ -4,6 +4,24 @@ $questions = [];
if(!isset($_POST['mark'])) {
define('QUESTION_COUNT', 60); //How many questions to ask.
$questions = Question::getQuestions(QUESTION_COUNT);
+ $total = false;
+} else {
+ unset($_POST['mark']);
+ $total = count($_POST);
+ $correct = $wrong = 0;
+ $output = "";
+ foreach($_POST as $i=>$q) {
+ $question = Question::getById($i);
+ $answer = Answer::getById($q);
+ if($answer->isCorrect()) {
+ $correct++;
+ } else {
+ $output .= "".$question->getQuestion()."
";
+ $corAnswer = $question->getCorrectAnswer();
+ $output .= "Wrong.
Your Answer: ".$answer->getAnswer()."
Correct Answer: ".$corAnswer->getAnswer().'
';
+ $wrong++;
+ }
+ }
}
?>
@@ -23,20 +41,10 @@ if(!isset($_POST['mark'])) {