EasyCFM.COM ColdFusion Forums / Tutorial Requests! / ColdFusion Multiple Choice Quiz

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: ColdFusion Multiple Choice Quiz

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

DuvalFan22
01-21-2008 @ 7:42 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 59
Joined: Oct 2007

I am trying to make a quiz like application for Air Force personnel that would draw questions from a database and have multiple choice answers. I would have a form so that they could insert new questions. On this form, I would have 3 drop-down boxes to choose which career field, which set of tests, and then which exact test the question pertains to. I want the quiz to display one question per page, have a 'Next' button that will store that question in a temporary list or database table. At the end of the quiz, I want to be able to display the number right out of how many questions they had, and also display their percentage score. After they see thier score and hit the 'Finish' button, I want to empty the list or table so that it doesnt build up for nothing.

This quiz is just for practice for them before they take the real exams, thats why I dont need the data stored from the quiz for good. How would I go about doing this as I am stuck on getting the questions stored in a temp database or list, and I cannot figure out the related drop-down boxes to save my life even though Ive read the tutorials on here realting to that 3-4 times each. Any advice and/or tutorialsfor this application?

"Don't Let Life Take Over You! You Need to Take Over Life!!" ~~~Corey

Visit my new website and let me know what you think! Give me some ideas on making it better!! http://www.codingpalace.net

megan
01-21-2008 @ 11:02 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

you said, "Ive read the tutorials " by that do you mean you literally have only "read" the tutorials? or have you actually written out and tested the code 3 or 4 times each and still can't get it??? Also did you see Louis's new tutorial on that topic http://tutorial517.easycfm.com/ ?

thanks, Megan

We have art so that we shall not die of reality ~ Nietzsche

DuvalFan22
01-22-2008 @ 10:30 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 59
Joined: Oct 2007

Well I can get the three boxes on the page and get the first 2 to work, but I cannot get the third box to work. Whenever I get all three boxes on the page, the first select box doesnt have all the values it should have. But if I use just the code in this tutorial: http://tutorial95.easycfm.com/  it works fine after i customize it for my data. But as soon as I add one more box, they dont have all the info i need. I know it has to do with the SQL Im pretty sure but somehow, I cannot get it to work. Ive looked up SQL tutorials on the JOIN part but cant seem to get it working. I need to Join 3 tables. Heres what I got:


<cfquery name="getLocal" datasource="#CDCs#">
    SELECT AFSC.AFSC_ID,AFSC.AFSC,CDCSets.SetsID,CDCSets.Sets,Volumes.VolID,Volumes.Volumes
    FROM AFSC INNER JOIN CDCSets
  ON AFSC.AFSC_ID = CDCSets.AFSC_ID INNER JOIN Volumes
  ON CDCSets.SetsID = Volumes.SetsID
    ORDER BY AFSC, Sets, Volumes
</cfquery>

<html>
  <head>
    <title>Dynamic JS Dropdowns</title>
    <cfset idx = -1>
    <cfset idx1 = -1>
    <cfset mycase = 0>
    <!---
       The JavaScript is adapted from Mike Corbridge's Multiple dynamic drop-down selection boxes example http://tutorial11.easycfm.com/
    --->

    <script language="JavaScript1.2">
        function whichLocal(obj){
                    switch (obj.selectBorder.selectedIndex){
                    <!--- use the group attribute to group output by category --->
                    <cfoutput query="getLocal" group="AFSC">
                    <cfset mycase = mycase + 1>case #mycase#:
                    <cfset myList = ValueList(getLocal.AFSC_ID)>
                    <cfset numberInCountry = ListValueCount(myList, AFSC_ID)>
                         obj.selectLocal.length=#numberInCountry#<cfoutput><cfset idx = idx + 1>
                         obj.selectLocal.options[#idx#].value="#getLocal.SetsID#"
                         obj.selectLocal.options[#idx#].text="#getLocal.Sets#"</cfoutput>

                    <cfset myList1 = ValueList(getLocal.SetsID)>
                    <cfset numberInCountry1 = ListValueCount(myList, SetsID)>
                         obj.selectLocal1.length=#numberInCountry1#<cfoutput><cfset idx1 = idx1 + 1>
                         obj.selectLocal1.options[#idx1#].value="#getLocal.VolID#"
                         obj.selectLocal1.options[#idx1#].text="#getLocal.Volumes#"</cfoutput>
                         break;

                    <cfset idx = -1>
                    </cfoutput>
                    }
       }
    </script>
</head>

<body>
<form name="myform" action="myactionpage.cfm" method="post">
  <table>
    <tr>
       <td>OPTIONS<br>

       <select name="selectBorder" onchange="whichLocal(this.form)">
         <option>- Select AFSC-</option>
         <!--- again, use the group attribute to group output by category --->
         <cfoutput query="getLocal" group="AFSC">
         <option value="#AFSC_ID#">#AFSC#</option>
         </cfoutput>
       </select>

       <select name="selectLocal" onchange="whichLocal(this.form)">
          <option>      </option>
          <option></option>
          <option></option>
          <option></option>
          <option></option>
          <option></option>
          <option> --------------------------------- </option>
      </select>

      <select name="selectLocal1" onchange="whichLocal(this.form)">
          <option>      </option>
          <option></option>
          <option></option>
          <option></option>
          <option></option>
          <option></option>
          <option> --------------------------------- </option>
      </select>
      <input type="submit" name="Submit" value="Submit">
      </td>
   </tr>
</table>
</form>
</body>
</html>


"Don't Let Life Take Over You! You Need to Take Over Life!!" ~~~Corey

Visit my new website and let me know what you think! Give me some ideas on making it better!! http://www.codingpalace.net

This message was edited by DuvalFan22 on 1-22-08 @ 10:32 AM


Website Designed and Developed by Pablo Varando.