#[1] - first question
#answer=3 - which number is correct answer
#title=Window curtains
#pageurl=draperies-and-curtains.htm
#question=what is 3 times 2 - the question being asked
#1=5 - possible answers
#2=1.5
#3=6
#4=0
# TODO
# Need test bed to spit out all scinarios - question and incorrect text
$outstr = "\n";
$outstr .= "\n";
$verbose = 1;
$postvars = ($_SERVER['REQUEST_METHOD'] == 'POST') ? $HTTP_POST_VARS : $HTTP_GET_VARS;
$which_quiz = "./".$postvars['which'].".quiz";
$which_question = $postvars['qindex'];
$which_answer = $postvars['qanswer'];
$report = $postvars['report'];
if (is_readable($which_quiz) != true) {
return;
}
$quiz_questions = parse_ini_file($which_quiz, true);
#print_r($quiz_questions);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (($logfile = fopen("./quiz.txt", 'a+')) && $verbose == 1) {
fwrite($logfile, "POST ".$_SERVER['REMOTE_ADDR']."
");
fwrite($logfile, " quiz ".$which_quiz."
");
fwrite($logfile, " question ".$quiz_questions[$which_question]['question']."
");
fwrite($logfile, " answer ".$quiz_questions[$which_question][$which_answer]."
");
fwrite($logfile, " date ".date("m-d-y H:i:s")."
\n");
fclose($logfile);
} else {
$verbose = 0; # If fopen failed, force verbose off
}
}
#print_r($quiz_questions);
$question_count = 0;
# Figure out how many questions there are
while ($quiz_questions[$question_count++]['answer'] != '');
$question_count--;
$which_question = ($which_question != '') ? $which_question : 0;
if ($report == '') {
# Need to display a question
# Include hidden field with 'report' set to something
$outstr .= "