mirror of
https://github.com/idanoo/nzart-exam-generator.git
synced 2024-12-04 22:26:58 +00:00
Now shows score + wrong questions
This commit is contained in:
parent
0824aca6b9
commit
6dff0d62ab
@ -12,7 +12,14 @@ class DataItem {
|
|||||||
$db = new db();
|
$db = new db();
|
||||||
$db->query("SELECT * FROM `".static::_getType()."` WHERE ".static::_getType()."_id = :id");
|
$db->query("SELECT * FROM `".static::_getType()."` WHERE ".static::_getType()."_id = :id");
|
||||||
$db->bind(":id", $id);
|
$db->bind(":id", $id);
|
||||||
return $db->getObject();
|
$result = $db->single();
|
||||||
|
if(!$result) return false;
|
||||||
|
$className = static::_getClass();
|
||||||
|
$obj = new $className();
|
||||||
|
foreach ($result as $key=>$val) {
|
||||||
|
$obj->$key = $val;
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
private function _getAllWhere($where = false, $orderBy = false, $join = false, $limit = false) {
|
||||||
|
36
index.php
36
index.php
@ -4,6 +4,24 @@ $questions = [];
|
|||||||
if(!isset($_POST['mark'])) {
|
if(!isset($_POST['mark'])) {
|
||||||
define('QUESTION_COUNT', 60); //How many questions to ask.
|
define('QUESTION_COUNT', 60); //How many questions to ask.
|
||||||
$questions = Question::getQuestions(QUESTION_COUNT);
|
$questions = Question::getQuestions(QUESTION_COUNT);
|
||||||
|
$total = false;
|
||||||
|
} else {
|
||||||
|
unset($_POST['mark']);
|
||||||
|
$total = count($_POST);
|
||||||
|
$correct = $wrong = 0;
|
||||||
|
$output = "";
|
||||||
|
foreach($_POST as $i=>$q) {
|
||||||
|
$question = Question::getById($i);
|
||||||
|
$answer = Answer::getById($q);
|
||||||
|
if($answer->isCorrect()) {
|
||||||
|
$correct++;
|
||||||
|
} else {
|
||||||
|
$output .= "<span style='font-weight:bold'>".$question->getQuestion()."</span><br>";
|
||||||
|
$corAnswer = $question->getCorrectAnswer();
|
||||||
|
$output .= "Wrong.<br>Your Answer: ".$answer->getAnswer()."<br>Correct Answer: ".$corAnswer->getAnswer().'<br><br>';
|
||||||
|
$wrong++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?><!doctype html>
|
?><!doctype html>
|
||||||
<html class="no-js" lang="">
|
<html class="no-js" lang="">
|
||||||
@ -23,20 +41,10 @@ if(!isset($_POST['mark'])) {
|
|||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="header"><h1>Unofficial NZART Practice Exam</h1></div>
|
<div id="header"><h1>Unofficial NZART Practice Exam</h1></div>
|
||||||
<div id="body" class="center">
|
<div id="body" class="center">
|
||||||
<?php if(isset($_POST['mark'])) {
|
<?php if($total) {
|
||||||
?><a href="/">Return to new Questions</a><br/><br/><?php
|
?><a href="/">Return to a new set of questions</a><br/><br/><?php
|
||||||
unset($_POST['mark']);
|
echo "<h3>Score ".(($correct/$total)*100)."% (".$correct."/".$total.")</h3>";
|
||||||
foreach($_POST as $i=>$q) {
|
echo $output;
|
||||||
$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 { ?>
|
} else { ?>
|
||||||
60 Questions
|
60 Questions
|
||||||
<form action="/" method="POST">
|
<form action="/" method="POST">
|
||||||
|
Loading…
Reference in New Issue
Block a user