diff --git a/includes/classes/class.answer.php b/includes/classes/class.answer.php index d05cc11..56ede3e 100755 --- a/includes/classes/class.answer.php +++ b/includes/classes/class.answer.php @@ -28,4 +28,9 @@ class Answer extends DataItem { return $this->answerdata_correct; } + + public static function checkIfCorrect($answer) + { + + } } \ No newline at end of file diff --git a/includes/classes/class.dataitem.php b/includes/classes/class.dataitem.php index 5319f14..fb75983 100755 --- a/includes/classes/class.dataitem.php +++ b/includes/classes/class.dataitem.php @@ -8,10 +8,11 @@ class DataItem { $this->_db = new db(); //Will optimise this to get existing conn at some point. } - public function getById($id) { - $this->_db->query("SELECT * FROM `".static::_getType()."` WHERE ".static::_getType()."_id = :id"); - $this->_db->bind(":id", $id); - return $this->_db->getObject(); + public static function getById($id) { + $db = new db(); + $db->query("SELECT * FROM `".static::_getType()."` WHERE ".static::_getType()."_id = :id"); + $db->bind(":id", $id); + return $db->getObject(); } private function _getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) { diff --git a/includes/classes/class.question.php b/includes/classes/class.question.php index 7d1e6d7..02973f5 100755 --- a/includes/classes/class.question.php +++ b/includes/classes/class.question.php @@ -38,6 +38,11 @@ class Question extends DataItem { return Answer::getAllWhere("answerdata_question = ".$this->getId()); } + public function getCorrectAnswer() + { + return Answer::getWhere("answerdata_question = ".$this->getId()." and answerdata_correct = 1"); + } + public function getImage() { return $this->questiondata_image; diff --git a/index.php b/index.php index 529d132..4a6b66e 100755 --- a/index.php +++ b/index.php @@ -1,7 +1,10 @@
@@ -20,7 +23,23 @@ $questions = Question::getQuestions(QUESTION_COUNT);