nzart-exam-generator/index.php

85 lines
3.9 KiB
PHP
Raw Normal View History

2016-12-30 05:16:13 +00:00
<?php
require_once('includes/include.php');
2016-12-31 11:23:57 +00:00
$questions = [];
if(!isset($_POST['mark'])) {
define('QUESTION_COUNT', 60); //How many questions to ask.
$questions = Question::getQuestions(QUESTION_COUNT);
}
2016-12-30 05:16:13 +00:00
?><!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>NZART - Practice Exam</title>
<meta name="description" content="Unofficial NZART Practice Exam">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div id="container">
<div id="header"><h1>Unofficial NZART Practice Exam</h1></div>
<div id="body" class="center">
2016-12-31 11:23:57 +00:00
<?php if(isset($_POST['mark'])) {
?><a href="/">Return to new Questions</a><br/><br/><?php
unset($_POST['mark']);
foreach($_POST as $i=>$q) {
$question = Question::getById($i);
$answer = Answer::getById($q);
echo $question->getQuestion()."<br>";
if($answer->isCorrect()) {
echo "Correct - ".$answer->getAnswer()."<br>";
} else {
$corAnswer = $question->getCorrectAnswer();
echo "Wrong.<br>Your Answer: ".$answer->getAnswer()."<br>Correct Answer:".$corAnswer->getAnswer();
}
}
} else { ?>
2016-12-30 05:16:13 +00:00
60 Questions
2016-12-31 11:23:57 +00:00
<form action="/" method="POST">
2016-12-30 05:16:13 +00:00
<table>
<tbody>
<?php
$letters = range('A', 'Z');
foreach($questions as $i=>$q) {
echo "<tr>";
echo "<td>".($i+1)."</td>";
2016-12-31 11:23:57 +00:00
echo "<td style='padding-left:10px'>".$q->getQuestion()."</td>";
2016-12-30 05:16:13 +00:00
echo "</tr>";
2016-12-31 07:36:47 +00:00
if(!empty($q->getImage())) {
echo "<tr>";
echo "<td></td><td><img src='img/".str_replace("\"",'',$q->getImage())."'></td>";
echo "</tr>";
}
2016-12-30 05:16:13 +00:00
foreach($q->answers as $x=>$ans) {
echo "<tr>";
2016-12-31 11:23:57 +00:00
echo "<td></td>";
echo "<td style='padding-left:10px'><input type='radio' name='".$q->getId()."' value='".$ans->getId()."'> ".($letters[$x]." ".$ans->getAnswer())."</td>";
2016-12-30 05:16:13 +00:00
echo "</tr>";
}
2016-12-31 07:36:47 +00:00
echo "<tr><td>&nbsp;</td><td></td></tr>";
2016-12-30 05:16:13 +00:00
}
?>
2016-12-31 11:23:57 +00:00
<tr><td></td><td><input type="hidden" name="mark" value="1"><button type="submit">Submit</button></td></tr>
2016-12-30 05:16:13 +00:00
</tbody>
</table>
2016-12-31 11:23:57 +00:00
</form>
<?php } ?>
2016-12-30 05:16:13 +00:00
</div>
<div id="footer">
All Questions and images from NZART question bank located
2016-12-31 07:28:37 +00:00
<a href="http://www.nzart.org.nz/exam/download-examination-files/">Here</a><br/>
Last updated 31-12-2016.
2016-12-30 05:16:13 +00:00
</div>
</div>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.12.0.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
</body>
</html>