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 14 of 14
  1. #1
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fill in the blank quiz for website

    Hi, I need to make a quiz with fill in's rather than multiple choice answers. I saw a nice one that would work at http://highered.mcgraw-hill.com/site...he_blanks.html

    but i dont know how that works. So, any help or scripts would be greatly appreciated......its gonna be 26 questions

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that is using javascript. the script would be quite long, but for like 2 questions it would look something like this
    Code:
    <script type="text/javascript">
    function valid() {
    cor = "0"
    incor = "0"
    test0 = document.myform.elements[0].value;
    test1 = document.myform.elements[1].value;
    if (test0.toLowerCase() == "codingforums.com") {
    ++cor; }
    else ++incor
    if (test1.toLowerCase() == "chrismiceli") {
    ++cor; }
    else ++incor
    alert("you got " + cor + " right\n And you got " + incor + " wrong. You got " + cor/2 * 100 + "% correct!");
    }
    </script>
    <body>
    <form name="myform">
    1. what is the name of this site?
    <input type="text" name="q1">
    2.what is my name?
    <input type="text/javascript">
    <br>
    <input type="button" onClick="valid()" value="check answers">
    Last edited by chrismiceli; 12-15-2002 at 02:20 AM.

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay thanks, i got that to work really well for what i need.

    But is there any way to make the results open in new page and display the results and giving the answers and what they answered? Thanks

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sure you can.
    Code:
    <script type="text/javascript">
    function valid() {
    cor = "0"
    incor = "0"
    test0 = document.myform.elements[0].value;
    test1 = document.myform.elements[1].value;
    if (test0.toLowerCase() == "codingforums.com") {
    ++cor; }
    else ++incor
    if (test1.toLowerCase() == "chrismiceli") {
    ++cor; {
    else ++incor
    document.cookie = escape(test0 + ";" + test1 + ";" + cor + ";" + incor)
    }
    </script>
    <body>
    <form name="myform">
    1. what is the name of this site?
    <input type="text" name="q1">
    2.what is my name?
    <input type="text/javascript">
    <br>
    <input type="button" onClick="valid()" value="check answers">
    and on the other page
    Code:
    <script type="text/javascript">
    cook = unescape(document.cookie)
    vals = cook.split(";")
    document.getElementById("spanname").innerHtml = "You answered " + vals[0] + " for number 1.<br>You answered " + vals[1] + " for number 2.<br>You got " + vals[2] + " correct and " + incor + " incorrect.<br>You got " + cor/2 * 100 + "% correct.");
    </script>
    <span id="spanname"></span>

  • #5
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what would i have to name the page with the results

  • #6
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    when the check answers button is clicked, nothing happens, so would this be because of the answer page not being named correctly or something else(i made the quiz page quiz.htm, and the answer page results.htm)
    Thanks

  • #7
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    syntax erros, here is a revised one
    the quiz page.
    Code:
    <html>
    <head>
    <title>test</title>
    <script type="text/javascript">
    function valid() {
    cor = "0"
    incor = "0"
    test0 = document.myform.elements[0].value;
    test1 = document.myform.elements[1].value;
    if (test0.toLowerCase() == "codingforums.com") {
    ++cor; }
    else {
    ++incor }
    if (test1.toLowerCase() == "chrismiceli") {
    ++cor; }
    else {
    ++incor }
    document.cookie = escape(test0 + ";" + test1 + ";" + cor + ";" + incor)
    document.location.href = "results.html" //the results page
    }
    </script>
    <body>
    <form name="myform">
    1. what is the name of this site?
    <input type="text" name="q1">
    2.what is my name?
    <input type="text/javascript">
    <br>
    <input type="button" onClick="valid()" value="check answers">
    </form>
    </body>
    </html>
    the results page
    Code:
    <html>
    <head>
    <title>test
    </title>
    <script type="text/javascript">
    function tst() {
    cook = unescape(document.cookie)
    vals = cook.split(";")
    document.write("You answered " + vals[0] + " for number 1.<br>You answered " + vals[1] + " for number 2.<br>You got " + vals[2] + " correct and " + vals[3] + "
    incorrect.<br>You got " + vals[2]/2 * 100 + "% correct.");
    }
    </script>
    </head>
    <body onLoad="tst()">
    <span id="spanname"></span>
    </body>
    </html>

  • #8
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok thats working

    sorry to be a pain, but
    1. how do i make the results page's , answers given, appear bold
    2. tell which numbers were missed.
    3. incorporate the total # correct into something appearing specifically for that amount (i.e. picture after the rest of all the results)

    once again, sorry for asking you all these questions.

  • #9
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the bold would be like this
    Code:
    document.write("You answered <b>" + vals[0] + "</b> for number 1.<br>You answered <b>" + vals[1] + "</b> for number 2.<br>You got <b>" + vals[2] + "</b> correct and <b>" + vals[3] + "
    </b>incorrect.<br>You got<b> " + vals[2]/2 * 100 + "%</b> correct.");
    }
    }
    and the rest would just take a lot more programming. you might want to try learning javascript sometime, it is a great language.

  • #10
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, thanks for all the help

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    a suggestion

    Put the validation in a seperate js file so the answers cannot be easliy found by viewing source
    Therapy is expensive, popping bubble wrap is cheap, you choose.

  • #12
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can you hide the answers if you are using an array, if so, how?

  • #13
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you put all your javascript in a file called whatever.js you can call it in your website like so.
    <script type="text/javascript" src="whatever.js"></script>
    that makes it "harder" to see the source, no where near full proof. but be sure to not include the <script> tags in the js file.

  • #14
    New Coder
    Join Date
    Oct 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, thanks


  •  

    Posting Permissions

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