Hi. Today I'm working for a quiz with random questions but how can I do an answer checker?
This is the function:
function onRandomQuestionQuiz()
{
$tot_question = 75;
switch(rand(1, $tot_question))
{
case 1:
{
$question = "blablabla?";
$answerA = "blabla";
$answerB = "blablabla";
$answerC = "bla";
$answerD = "what is it?";
$answer = "D";
}
//There are 75 cases with questions and answers
}
}
return array ($question, $answerA, $answerB, $answerC, $answerD, $answer);
}
And this is the quiz form:
echo "Quiz";
echo "<br />";
echo "<form action='?p=index&sub=register&step=checkquiz' method='post'";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='011'/>".$answerA;
echo "<input type='radio' name='012'/>".$answerB;
echo "<input type='radio' name='013'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='021'/>".$answerA;
echo "<input type='radio' name='022'/>".$answerB;
echo "<input type='radio' name='033'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='031'/>".$answerA;
echo "<input type='radio' name='032'/>".$answerB;
echo "<input type='radio' name='033'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='041'/>".$answerA;
echo "<input type='radio' name='042'/>".$answerB;
echo "<input type='radio' name='043'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='051'/>".$answerA;
echo "<input type='radio' name='052'/>".$answerB;
echo "<input type='radio' name='053'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='061'/>".$answerA;
echo "<input type='radio' name='062'/>".$answerB;
echo "<input type='radio' name='063'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='071'/>".$answerA;
echo "<input type='radio' name='072'/>".$answerB;
echo "<input type='radio' name='073'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='081'/>".$answerA;
echo "<input type='radio' name='082'/>".$answerB;
echo "<input type='radio' name='083'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='091'/>".$answerA;
echo "<input type='radio' name='092'/>".$answerB;
echo "<input type='radio' name='093'/>".$answerC;
echo "<br />";
list ($question, $answerA, $answerB, $answerC, $answerD, $answer) = onRandomQuestionQuiz();
echo "<b>".$question."</b>";
echo "<input type='radio' name='101'/>".$answerA;
echo "<input type='radio' name='102'/>".$answerB;
echo "<input type='radio' name='103'/>".$answerC;
echo "<br />";
echo "<input type='submit' value='OK'/></form>";
Can you help me for the checker, please?
The code prints the same questions... can you help me to fix it?