nzart-exam-generator/includes/classes/class.question.php
Daniel Mason 0824aca6b9 progress
2017-01-01 00:23:57 +13:00

50 lines
No EOL
1 KiB
PHP
Executable file

<?php
/**
* Created by PhpStorm.
* User: daniel
* Date: 12/30/16
* Time: 2:09 PM
*/
class Question extends DataItem {
public static function _getClass()
{
return "Question";
}
public static function _getType()
{
return "question";
}
public static function getQuestions($count = false)
{
$questions = static::getAllWhere(false, "order by rand()", false, $count);
foreach ($questions as $q) {
$q->answers = $q->getAnswers();
shuffle($q->answers);
}
return $questions;
}
public function getQuestion()
{
return $this->questiondata_content;
}
public function getAnswers()
{
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;
}
}