mirror of
https://github.com/idanoo/nzart-exam-generator.git
synced 2024-12-04 14:23:10 +00:00
Made full exam mock actual exam by grabbing 1 question per 10 for each section
This commit is contained in:
parent
3d98b9a290
commit
9e95985703
@ -44,6 +44,13 @@ class DataItem {
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public static function count($query)
|
||||
{
|
||||
$db = new db();
|
||||
$db->query($query);
|
||||
return array_pop($db->single());
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
$typeName = static::_getType();
|
||||
$id = $typeName."_id";
|
||||
|
@ -18,9 +18,10 @@ class Question extends DataItem {
|
||||
return "question";
|
||||
}
|
||||
|
||||
public static function getQuestions($count = false)
|
||||
public static function getQuestions($count)
|
||||
{
|
||||
$questions = static::getAllWhere(false, "order by rand()", false, $count);
|
||||
if($count == "60") return self::getExamQuestions();
|
||||
$questions = self::getAllWhere(false, "order by rand()", false, $count);
|
||||
foreach ($questions as $q) {
|
||||
$q->answers = $q->getAnswers();
|
||||
shuffle($q->answers);
|
||||
@ -28,6 +29,23 @@ class Question extends DataItem {
|
||||
return $questions;
|
||||
}
|
||||
|
||||
public static function getExamQuestions()
|
||||
{
|
||||
$questions = [];
|
||||
$i=1;
|
||||
while ($i<=30) {
|
||||
$limit = parent::count("SELECT COUNT(*)/10 FROM question WHERE FLOOR(questiondata_number) = ".$i);
|
||||
$questions = array_merge($questions, self::getAllWhere("FLOOR(questiondata_number) = ".$i, "order by rand()", false, intval($limit)));
|
||||
$i++;
|
||||
}
|
||||
foreach ($questions as $q) {
|
||||
$q->answers = $q->getAnswers();
|
||||
shuffle($q->answers);
|
||||
}
|
||||
return $questions;
|
||||
|
||||
}
|
||||
|
||||
public function getQuestion()
|
||||
{
|
||||
return $this->questiondata_content;
|
||||
@ -47,4 +65,9 @@ class Question extends DataItem {
|
||||
{
|
||||
return $this->questiondata_image;
|
||||
}
|
||||
|
||||
public function getCountFromNumber()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
12
index.php
12
index.php
@ -45,11 +45,7 @@ if (isset($_POST['mark'])) {
|
||||
$user->storeResult($_POST, $score);
|
||||
}
|
||||
} else {
|
||||
if(isset($_GET['questions'])) {
|
||||
define('QUESTION_COUNT', intval($_GET['questions']));
|
||||
} else {
|
||||
define('QUESTION_COUNT', 60);
|
||||
}
|
||||
define('QUESTION_COUNT', isset($_GET['questions'])?intval($_GET['questions']):"60");
|
||||
$questions = Question::getQuestions(QUESTION_COUNT);
|
||||
}
|
||||
?><!doctype html>
|
||||
@ -95,10 +91,8 @@ if (isset($_POST['mark'])) {
|
||||
</div>
|
||||
<div id="header"><h1>Unofficial NZART Practice Exam</h1></div>
|
||||
<div id="body" class="center">
|
||||
New Exam: <a href="/index.php?questions=10">10 Questions</a> -
|
||||
<a href="/index.php?questions=20">30 Questions (Half Exam)</a> -
|
||||
<a href="/index.php?questions=60">60 Questions (Full Exam)</a> -
|
||||
<a href="/index.php?questions=600">600 Questions (All Questions)</a>
|
||||
New Exam: <a href="/index.php?questions=10">10 Questions (Random)</a> -
|
||||
<a href="/index.php">60 Questions (Full Exam)</a> -
|
||||
<br/><br/>
|
||||
<?php if(isset($score)) {
|
||||
echo "<h3>Score ".(($score['correct']/$score['total'])*100)."% (".$score['correct']."/".$score['total'].")</h3>";
|
||||
|
Loading…
Reference in New Issue
Block a user