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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.