</strong></h4> <h2>Question <?php echo $num; ?> :</h2> <p><?php echo $question->getText(); ?> </p> <form id="questionBox" method="post" action="<?php echo $root; ?> /quiz/process"> <ul> <?php $shuffledAnswers = SimpleQuiz\Utils\Base\Utils::shuffleAssoc($answers); $acount = 0; foreach ($shuffledAnswers as $answer) { echo '<li><input type="radio" id="answer' . $acount . '" value="' . $answer . '" name="answers" />' . PHP_EOL; echo '<label for="answer' . $acount . '">' . $answer . '</label></li>' . PHP_EOL; $acount++; } ?> </ul> <p> <input type="hidden" name="nonce" value="<?php echo $nonce; ?> " /> <input type="hidden" name="num" value="<?php echo $num;
$quiz->populateQuestions()->populateUsers(); $timetaken = ''; $nonce = md5(uniqid()); $session->set('nonce', $nonce); $num = $session->get('num') ? $session->get('num') : 1; if (isset($_SESSION['last']) && $_SESSION['last'] === true) { $session->set('nonce', null); //first two vars formatted for insertion into database as datetime fields $starttime = $session->get('starttime'); $endtime = date('Y-m-d H:i:s'); //store $timetaken in session if (!isset($_SESSION['timetaken'])) { $end = time(); $start = strtotime($starttime); $time = $end - $start; $timetaken = SimpleQuiz\Utils\Base\Utils::calculateTimeTaken($time); $_SESSION['timetaken'] = $timetaken; $quiz->addQuizTaker($session->get('user'), $session->get('score'), $starttime, $endtime, $time); } else { $timetaken = $_SESSION['timetaken']; } } $app->render('quiz/test.php', array('quiz' => $quiz, 'num' => $num, 'nonce' => $nonce, 'timetaken' => $timetaken, 'categories' => $categories, 'session' => $session)); } else { $app->flashnow('quizerror', 'The quiz you have selected does not exist. Return to the main menu to try again'); $app->render('quiz/error.php', array('categories' => $categories, 'session' => $session)); $app->stop(); } })->conditions(array('id' => '\\d+')); $app->get('/quiz/:id/results/', function ($id) use($app) { $quiz = $app->quiz;