Jump to content

Help with php quiz


jimmys

Recommended Posts

Hello.

I try to write a simple multiple choice quiz. I have my questions and answers in a xml file and I read the file into an array. My main problems is how I'll connect the various sessions where the different questions appear in order to keep the score and sum it up in the end. Also, how do I check if the selected answer is correct or not? Assuming that the correct answers are in an array in php code, can I use javascript to check the answers?

Any help?

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/218884-help-with-php-quiz/
Share on other sites

All I did is to parse the xml file and put the data into an array

 

$questions[$no][$i]

 

where $no is the number of the question and on the $i positions I have on 0 the question and on 1 the answers

 

function char($parser,$data){

global $questions, $no, $type, $i;

switch($type){

case 1: $questions[$no][0] = $data; break; //this is the question

case 2: $questions[$no][1][0] = $data; break; //this is the correct answer

case 3: $questions[$no][1][$i] = $data; $i++; break; //these are the incorrect answers

}

}

 

Then I just created a form and put my first question.

I'm actually a newbie in php so I may miss the basics too.

Link to comment
https://forums.phpfreaks.com/topic/218884-help-with-php-quiz/#findComment-1135179
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.