This commit is contained in:
Daniel Mason 2017-01-01 00:23:57 +13:00
parent b6876e601e
commit 0824aca6b9
4 changed files with 42 additions and 9 deletions

View file

@ -28,4 +28,9 @@ class Answer extends DataItem
{
return $this->answerdata_correct;
}
public static function checkIfCorrect($answer)
{
}
}

View file

@ -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) {

View file

@ -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;