jimmys Posted November 16, 2010 Share Posted November 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
litebearer Posted November 16, 2010 Share Posted November 16, 2010 Show us what you have coded thus far Quote Link to comment Share on other sites More sharing options...
jimmys Posted November 16, 2010 Author Share Posted November 16, 2010 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. Quote Link to comment Share on other sites More sharing options...
jimmys Posted November 16, 2010 Author Share Posted November 16, 2010 Do I need to store somehow the correct answers in a different variable which will be globally accessible? Or do I pass it the one I have somehow with the post method, through the questions? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.