Here is what I have. I've written a test that allows users to answer
questions, then go to the next question however as I wrote this,
I never really took into account that the questions would never really be in
order. I figured hey, they'll just be listed 1 after the
other, 1,2,3,4 etc...instead thats just not realistic and now it's more like
1,3,4,2. Bring in that each question has a chapterID and
well, now we're having fun
Here is the code I currently have and I can't figure out how to write a
query which goes to the next question in that chapter.
I plan to re-write the addition/calculation part of this to something
different.
Table Name: DriveQuestions
Fields: QuestionID(autonumber), ChapterID, Question
-------------divider------------
<!--- Check to see if the Session is started. --->
<CFIF IsDefined("Session.Start") is NOT TRUE>
<!--- If this is the users first time through, run this code --->
<CFPARAM name="CorrectAnswer" default="0">
<CFPARAM name="InCorrectAnswer" default="0">
<CFQUERY NAME="CheckAnswer" DATASOURCE="Stranger">
SELECT DriveQuestions.*, DriveApplicantAnswers.*
FROM DriveQuestions, DriveApplicantAnswers
WHERE AnswerValue = '#AnswerID#' AND DriveQuestions.QuestionID =
#QuestionID#
</cfquery>
<!--- If the user's answer matches the correct answer, it is correct. --->
<cfoutput query="CheckAnswer">
<CFIF Evaluate(AnswerID) IS AnswerValue>
<!--- <CFSET CorrectAnswer = 'Right'> --->
<CFSET CorrectAnswer = CorrectAnswer + 1>
</CFIF>
</cfoutput>
<CFIF CorrectAnswer Is '0'>
<!--- Don't Add Anything --->
</CFIF>
<!--- Insert Users Answer Result into the database --->
<CFQUERY DATASOURCE="Stranger">
UPDATE DriveApplicantAnswers
Set CorrectAnswer=#CorrectAnswer#,
QuestionID=#QuestionID#,
ChapterID=#ChapterID#
Where Number = #ApplicantID#
</CFQUERY>
<CFSET NextID = QuestionID + 1>
<CFSET Session.Start = "Yes">
<CFLOCATION
URL="test.cfm?QuestionID=#NextID#&ChapterID=#ChapterID#&ApplicantName=#ApplicantName#&ApplicantID=#ApplicantID#">
<CFELSE>
<!--- Session is True then put in next code --->
<CFPARAM name="CorrectAnswer" default="0">
<CFPARAM name="InCorrectAnswer" default="0">
<CFQUERY NAME="CheckAnswer" DATASOURCE="Stranger">
SELECT DriveQuestions.*, DriveApplicantAnswers.*
FROM DriveQuestions, DriveApplicantAnswers
WHERE AnswerValue = '#AnswerID#' AND DriveQuestions.QuestionID =
#QuestionID#
</cfquery>
<!--- If the user's answer matches the correct answer, it is correct. --->
<cfoutput query="CheckAnswer">
<CFIF Evaluate(AnswerID) IS AnswerValue>
<CFSET CorrectAnswer = CorrectAnswer + 1>
</CFIF>
</cfoutput>
<CFIF CorrectAnswer Is '0'>
</CFIF>
<!--- Update Results in Database --->
<CFQUERY DATASOURCE="Stranger">
UPDATE DriveApplicantAnswers
Set CorrectAnswer=#CorrectAnswer#
Where Number = #ApplicantID#
</CFQUERY>
<CFQUERY NAME="CountChapter" DATASOURCE="Stranger">
Select COUNT(*) AS CountMax
>From DriveQuestions
WHERE ChapterID LIKE #ChapterID#
</cfquery>
<!--- Now go to the next question --->
<CFSET NextID = QuestionID + 1>
<CFOUTPUT QUERY="CountChapter">
<CFIF NextID EQ CountMax + 1>
<CFSET Session.Start = "No">
<CFLOCATION
URL="test_results.cfm?ChapterID=#ChapterID#&ApplicantName=#ApplicantName#&ApplicantID=#ApplicantID#">
<CFABORT>
<CFELSE>
<CFLOCATION
URL="test.cfm?QuestionID=#NextID#&ChapterID=#ChapterID#&ApplicantName=#ApplicantName#&ApplicantID=#ApplicantID#">
</cfif>
</cfoutput>
</CFIF>
Mark Smeets/stranger0/ICQ #1062196
My new email: [EMAIL PROTECTED]
"Mr. West, not every situation requires your patented approach of shoot
first, shoot later, shoot some more and then when everybody's dead try to
ask a question or two" - Wild Wild West
A Stranger's Domain
http://24.113.34.178/stranger
Official Splitting Adam Homepage
http://www.splittingadam.com/
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists