////////////////////////////////////////////////////////////
//
// xmlQuiz v1.1 - a simple quiz script
//
////////////////////////////////////////////////////////////
//
// This script allows you to quiz users on any number of
// questions and calculate the score.
//
// See readme.txt for more information.
//
// Author: Jon Thomas
');
if (!isset($post_answers)) {
echo "" . $questions[0]['text'] . "\n";
echo "\n";
}
//
// PRINT NEXT QUESTION
//
elseif (count($questions) > count($post_answers)) {
// get number of next question
$nextQuestion = count($post_answers);
// print question
echo "" . $questions[$nextQuestion]['text'] . "\n";
echo "\n";
}
//
// CALCULATE AND PRINT SCORE
//
else {
// get number of questions
$noQuestions = count($questions);
// get number of correct answers
for ($i = 0; $i < $noQuestions; $i++) {
// increment "noCorrectAnswers" variable if user has correct answer
if (strtoupper( trim ( $questions[$i]['answer'] ) ) == strtoupper ( trim ( $post_answers[$i] ) ) ) {
$noCorrectAnswers++;
}
}
// calculate score
$score = ($noCorrectAnswers / $noQuestions) * 100;
// round score to nearest whole precentage point
$score = round($score);
// print score
echo "Correct answers: $score%\n"; if ($score <= 10) { $title = '���-���? Ƹ����� ���?'; $text = '���������� �� ���� �������, � ��� ����. � - ����������� ������.'; } if ($score > 10) { $title = '��, ��������, ��� ��������� ��� ��������� ���������, ��� ��� ��������� �������� ����-����!'; $text = '� ��������� ��� �������, ��� �������� ������ �����! ������, � ��������� ��� ������ ������?'; } if ($score > 35) { $title = '� ����� ��� � ����!'; $text = '��, ��� �����������, � ����� ��� � �� ����� ���� ����. ������ ����������, ��� ���� ������ ������������ ���� �� ����� ����-����!'; } if (($score > 70 ) && ($noCorrectAnswers < $noQuestions)) { $title = '� ����-����! �������!'; $text = '� ������ �� ����, ��������� � �����������. � �������, ��� �� ��� ��������, ��� ������ ���� ���������, � ��� ���, � ��� �����!'; } if ($noCorrectAnswers == $noQuestions) { $title = '� - ������������ ���! � - ����!'; $text = 'Ƹ����� ����� - ��� �����. � ���������� � ������ ������ ��� ������� ��� ���� � ����. ��� ������ ��� � �����������. � 100% ����!'; } $x = ''; $x .= '
�� ������ ���������� ���������� ����� �� ����� ��������HTML Code: ' ); echo ( '' ); $fw=fopen("statistics.txt","a"); fputs($fw,"IP: [" . $_SERVER['REMOTE_ADDR'] . "]: $score\n"); fclose($fw); } echo ( ' |