1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Is there any test generator PHP script there?

Discussion in 'PHP' started by Fracisc, Jun 5, 2009.

  1. #1
    I need a script that will help me generate a test.
    I have a few questions and I must be able to add a few answers. People will choose their answer and after submit the script should send the report (correct vs wrong).
    Is there a script like this?
    Or do you know a place where I can get an idea on how to start coding it?
    SEMrush
     
    Fracisc, Jun 5, 2009 IP
    SEMrush
  2. TecBrat

    TecBrat Member

    Messages:
    31
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    You could go as simple as a form and handler, or you could go as complex as an interactive database that lets you add new questions and answers as an administrator, remembers who gave what answers and does ranking or whatever you want.

    Sounds like you want the simpler solution. The first step is to make an HTML form that asks the questions. Use something like name=answer[] to put the answers in an array. The action of your Test form would be the handler (Use Post method).

    In the handler you would have an array of answers and access the visitors answers like:
    <?php
    $answer_key=array('a','c','a','b','d','c','b','a','c','a','d','d','c','b');
    $answer=$_POST['answer'];
    ?>
    PHP:
    (Or replace the letters with whatever the correct answer would be.)

    Then you'd compare $answer[x] and $answer_key[x] to see if they match.
    Then you could echo the results or use the php mail() function to send yourself a report.
     
    TecBrat, Jun 5, 2009 IP
  3. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,671
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #3
    I need to generate a random list of 10 questions, from a database. Those questions can have one or more correct answers. After they submit the form I want to return the number of the correct answers and highlight the errors.
    It is a bit more complex then what you have suggested.
    Do you have any idea how can I start coding what I need?
     
    Fracisc, Jun 5, 2009 IP
  4. Social.Network

    Social.Network Member

    Messages:
    519
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #4
    Social.Network, Jun 5, 2009 IP