...

View Full Version : Random Question Producer



colby2152
02-19-2009, 06:42 PM
Say I have a database setup full of a questions (I have barely any experience with mySQL databases online) each with a given answer (A through E). Is there a script that will randomly call a predetermined number of questions randomly from this database, display them on the web page and give the user the solutions after the questions are finished?

Very vague I know, but I am a novice here who has found no help on Google over many searches.

Fumigator
02-19-2009, 08:45 PM
It's a very popular application and you can find plenty of pre-built quizes via google. Try the keywords +php +quiz +script.

Old Pedant
02-19-2009, 10:29 PM
Fumigator assumed you are using PHP for the scripting language. If not, please say what you are using.

But you can *probably* do this all in the SQL query, actually.

Something like this, perhaps:


SELECT question, answerA, answerB, answerC, answerD, answerE, UUID_SHORT() AS unique
FROM questions
ORDER BY unique
LIMIT 10

The UUID_SHORT() function essentially assigns a random number to each of your returned records. You then ORDER BY those random numbers and LIMIT the selection to only 10 questions. Presto.

Untested, but it should work.

Now, that doesn't help with the rest of your problem (that is, grade the answers and show correct answers), but exactly how to do that will depend somewhat on what server-side language/framework you are using.

Fumigator
02-19-2009, 11:57 PM
In your Google search replace "PHP" with whatever scripting language you use for similar results. Pretty self-explanatory. :thumbsup:

colby2152
02-20-2009, 12:03 AM
In your Google search replace "PHP" with whatever scripting language you use for similar results. Pretty self-explanatory. :thumbsup:

Thanks Fumigator... my google search was "random question script (php)" where php would be replaced by cgi or java. Your search sure does a better job!:thumbsup: I'll be tuning back here next week with questions. I like this forum already.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum