Images now load on main page + styling

This commit is contained in:
Daniel Mason 2016-12-31 20:36:47 +13:00
parent 0727b3c2ab
commit b6876e601e
2 changed files with 12 additions and 1 deletions

View File

@ -20,7 +20,7 @@ class Question extends DataItem {
public static function getQuestions($count = false)
{
$questions = static::getAllWhere(false, false, false, $count);
$questions = static::getAllWhere(false, "order by rand()", false, $count);
foreach ($questions as $q) {
$q->answers = $q->getAnswers();
shuffle($q->answers);
@ -37,4 +37,9 @@ class Question extends DataItem {
{
return Answer::getAllWhere("answerdata_question = ".$this->getId());
}
public function getImage()
{
return $this->questiondata_image;
}
}

View File

@ -30,12 +30,18 @@ $questions = Question::getQuestions(QUESTION_COUNT);
echo "<td>".($i+1)."</td>";
echo "<td>".$q->getQuestion()."</td>";
echo "</tr>";
if(!empty($q->getImage())) {
echo "<tr>";
echo "<td></td><td><img src='img/".str_replace("\"",'',$q->getImage())."'></td>";
echo "</tr>";
}
foreach($q->answers as $x=>$ans) {
echo "<tr>";
echo "<td style='padding-left:10px'>".$letters[$x]."</td>";
echo "<td style='padding-left:10px'>".$ans->getAnswer()."</td>";
echo "</tr>";
}
echo "<tr><td>&nbsp;</td><td></td></tr>";
}
?>
</tbody>