Apr 102009
Just a quick heads up to let you know that you can now download all of the source code for the PHP Quiz. This might make it easier for you to get up and running without trying to follow all of the series. I’ve also included the small amount of JavaScript too.
You can download it here. I’ll also put a download link at the top of each post in the series.
Cheers,
ElanMan
Hello. Thanks for your good work. I have question. How to display users choice in the end of quiz? Right now script displays only correct answers. I wont to display in red color my answers, and in blue correct answers. How can i do that?
And i have second question. How to display more then one quiz? I wont to have more then one quiz in my site. Right now i have leaderboard only for one quiz, and i wont to have for more. Please help my with that.
Hi Ahmed,
the quiz should display the user’s choices at the end on the results.php page. Have a look at the working example.
As for having multiple quizes on a site, I’m currently working on a new quiz script that will make this sort of thing much easier to achieve and will alsao work with mysql, which a lot of people have requested.
Stay tuned
hehe by (Woops!) on results page
I didn’t saw that before. So that problem no longer exist. But i have another question. When you exactly planning to release that new script?
I was looking for quiz and i am happy i havea found exactly what i wanted here))
i was testing the script and founded that there is something that i would like to change in it. i need to see in Acronym quiz this:
1. correct answers are always first in answers page.this is very bad for quiz users .i want to select the right answer by myself and change the order as i wish .
i’ve read you posts here and i couldn’t find enought information about how to make my Correct answer in different places.
Question1?
1.
2.Correct
3.
4.
Question2?
1.
2.
3.
4.Correct
Question3?
1.Correct
2.
3.
4.
the wrong answers work well.
the second problem is that the number of question is 20 and i want it to be for example 11 the answers page is awfully wrong. is there something else to add or change?
this is what i want so much and want you to ask for a help.i am ready to pay as much as it needs to.
Hi bigfan

The correct answer isn’t always listed first in the possible answers. Have you tried the online example? The correct answer should be randomly placed/shuffled.
TBH, this quiz was just a simple demo to understand SimpleXML and was never meant to be a decent quiz app.
To that end, I’m creating a simple, more robust quiz framework that I’ll publish asap which will work with MySQL instead of xml files.
Thanks for your comments
Hey bigfan, I’ve just taken the quiz and indeed the correct answer is always the first. Not sure why atm as it wasn’t like that originally. I’ve changed some of the online code a while back and have probably altered it.
Have you downloaded the file? Chances are that that has the original code in it.
Apologies
Hey Ben.
Still waiting for the revised version of the quiz sir!
Any ETA?
for my assigment ..i need simple quize code….so plz provid me code and how to connect with database…
thank you!!!
hey, i like the quiz submitted..i needed the answers to be verified on click by the user..could you pls help….
thanks
hey, the download link is busted i think.. i click the link and it takes me to a messed up html page instead of downloading the .zip.
help?
scratch that, i just downloaded the file and removed the .html extension.
The questions are coming out with the correct answer first as ‘bigfan’ mentioned. The code is the same as that of the tutorial. Any help would be greatly appreciated.
it’a a good code
@joseastwood
Sorry about the download link not working. Turns out wp-super-cache was causing the problem. Hopefully should be fixed now. Thanks for letting me know.
As for the correct answers coming out first, I’ll have to have a look at the code again.
Plans for a new, improved version have yet to be implemented so the least I can do is fix the code people are already downloading…
Will update this post when I’ve sorted this out.
Thanks again
OK, it seems the array_rand function has changed since php 5.2.10.
As a result, I’ve changed the shuffle_assoc function in functions.php to the following:
You’ll also need to change the following two lines in test.php:
and make them look like this:
You should now have randomly placed correct answers again.
I’ll upload the amended code shortly
EDIT:
The amended code has now been added to the download above.
Cheers
you can load questions and answer from database into array ????
Dear Elanman!
The download link has broken.This is message:500 Internal Server Error!
Hi there,
I’ve checked the download and it seems to work ok for me. Perhaps my server was having a temporary glitch. Please try again and let me know if you still have problems.
Hi guy!I still have the same problem.This is full message:”cannot download this file.Details:HTTP/1.1.500 Internal Server Error”.Can you upload the code to other host(mediafire.com,rapidshare.com,etc…) or send me to mail:truongdang.works@gmail.com!
Hi, I’ve put the code on sourceforge. You can download a zip file from here.
Hope that works for you.
Hi,
I downloaded frm source forge and implementwed in server. But it is not working properly.
How can we call questions randomly frm XML.
Shin
Hi Shin, when you say it’s not working properly, what errors are you getting? What version of php are you using? Have you set the correct permissions on leaders.xml?
Hi there, I have downloaded the script , however I am getting a can not send headers on processor.php , already sent from functions.php
How can I fix that?
Hi Nick, try downloading the zip file from sourceforge and let me know if you still have any problems.
May i know does this codes work with mysql?
ElanMan, thanks for your work, but in newer versions of PHP when processor.php starts, it just write “Warning: Cannot modify header information – headers already sent by (output started at /Users/dalibor/Sites/web-acronyms/functions.php:114) in /Users/dalibor/Sites/web-acronyms/processor.php on line 60″ … any ideas? I need help. Thank you.
Have you downloaded the zip file from sourceforge?
Yes, I have. Thanks for quick reply.
And you’re still having problems?

I’ll look in to it
Thanks for the comments
Yes, still doesn’t work, probably same problem like Nick wrote. Thanks, if you try fix it
Hi again DS,
tbh I’m having a problem recreating the ‘headers already sent’ error on my local machine.
I haven’t had a lot of time to look at though.
It’s possible that there is some trailing whitespace in functions.php after the closing php tag.
I’ll have a better look at this tomorrow, in the meantime, have a check for whitespace.
What version of php are you using? I’m on 5.3.5.
Thanks again for the feedback
Hi ElanMan! I used 5.3.6 but maybe it depends more on server configuration, then version of PHP. Anyway, many thanks! … but it was definitely a whitespace on last line in functions.php … so simple
Hi ElanMan, I am trying to download the code and I am poped for Login, where I can registar.. Please help
Hi, Keshab, you can download the files from Sourceforge here
nice work it helps a lot thanks