Your IP : 216.73.217.87
<?php
include 'includes/config.php';
include 'includes/common.php';
$quizID = (int) $_GET['id'];
$quizes = new Quizes();
$quizInfo = $quizes->getQuiz('quiz_id="' . $quizID . '"');
if ($quizInfo) {
$questions = new Questions();
$questionsList = $questions->getQuestions('quiz_id="' . $quizID . '"');
if (isset($_POST['submit'])) {
$answers = new Answers();
$totalQuestions = $questionsList['count']['questions'];
$correctAnswers = 0;
foreach ($_POST as $key => $value) {
$answerInfo = $answers->getAnswer('question_id="' . $key . '" AND answer="' . $value . '"');
if ($answerInfo['is_true']) {
$correctAnswers++;
}
}
$correctAnswersPercent = round(($correctAnswers / $totalQuestions) * 100);
$mark = ($correctAnswers / $totalQuestions) * 4 + 2;
}
include TEMPLATE_DIR . DIRECTORY_SEPARATOR . 'view_quiz.phtml';
} else {
include TEMPLATE_DIR . DIRECTORY_SEPARATOR . 'error.phtml';
}