Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2009
    Location
    Alexandria, VA
    Posts
    21
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Random Question Producer

    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.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    It's a very popular application and you can find plenty of pre-built quizes via google. Try the keywords +php +quiz +script.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    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:
    Code:
    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.

  • Users who have thanked Old Pedant for this post:

    colby2152 (02-19-2009)

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    In your Google search replace "PHP" with whatever scripting language you use for similar results. Pretty self-explanatory.

  • #5
    New Coder
    Join Date
    Feb 2009
    Location
    Alexandria, VA
    Posts
    21
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    In your Google search replace "PHP" with whatever scripting language you use for similar results. Pretty self-explanatory.
    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! I'll be tuning back here next week with questions. I like this forum already.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •