getUser() != $user->getId()) {
header("Location: //".$_SERVER['HTTP_HOST']);
exit();
}
$res = $result->getResult();
foreach($res as $p=>$r) {
$_POST[$p] = $r;
}
$_POST['mark'] = 1;
} elseif (isset($_REQUEST['results']) && is_object($user)) {
$results = $user->getResults();
}
if (isset($_POST['mark'])) {
unset($_POST['mark']);
$score['total'] = $score['correct'] = $score['wrong'] = 0;
foreach($_POST as $i=>$q) {
$question = Question::getById($i);
$answer = Answer::getById($q);
if(!is_object($question) || !is_object($answer)) continue;
if($answer->isCorrect()) {
$score['correct']++;
} else {
$output .= "".$question->getQuestion()."
";
$corAnswer = $question->getCorrectAnswer();
$output .= "Your Answer: ".$answer->getAnswer()."
Correct Answer: ".$corAnswer->getAnswer().'
';
$score['wrong']++;
}
$score['total']++;
}
if(is_object($user)) {
$user->storeResult($_POST, $score);
}
} else {
define('QUESTION_COUNT', isset($_GET['questions'])?intval($_GET['questions']):"60");
$questions = Question::getQuestions(QUESTION_COUNT);
}
?>