I say keep it simple.... I do something like this for a dating site
where I ask icebreaker questions
Set up a table with questions and answers like this:
QuestionID, QuestionText , QuestionIndex (for sorting, if you want)
AnswerID, QuestionID, AnswerText, isCorrect , AnswerIndex (for sorting,
if you want)
Then you output your questions with select pulldowns as answers
<cfquery name="x">
select * from questions,answers where
answers.questionid=questions.questionid
Order by questionIndex,answerIndex
</cfquery>
<cfoutput query="x" group="QuestionID">
<p>
#questionText#
<select name="AnswerID">
<Cfoutput group="AnswerID">
<option value="#answerID#">#AnswerText#</option>
</cfoutput>
</select>
</p>
</cfoutput>
Then you can do this to get the answers
Select questionID from answers where answerid in
(#valuelist(form.answerid)#) and isCorrect<>0
This will give you the list of correctly answered questions...
-----Original Message-----
From: Saturday (Stuart Kidd) [mailto:[EMAIL PROTECTED]
Sent: Monday, October 03, 2005 12:44 PM
To: CF-Talk
Subject: Online quiz
Hi guys,
I have 5 questions in my MS-SQL database and when i want to display them
in an online quiz I loop them through like so:
<cfform>
<cfoutput query="blah">
<cfinput name="#questionID# value="answerID">
</cfoutput>
</cfform>
When these get submitted i look through my DB again to pull the answers.
And do something like:
<cfoutput query="GetQuizQuestions">
<cfif answerID eq #form.questionID#><cfset score = score
+ 1></cfif>
</cfoutput>
The problem i'm having is somehow looping through the
#form.questionID#'s as I don't want to hard-code each one like below as
in some quizzes they'll be less than 5 questions and some more:
<cfif GetQuizQuestions .answerID eq #form.1#><cfset score = score +
1></cfif>
<cfif GetQuizQuestions .answerID eq #form.2#><cfset score = score +
1></cfif>
<cfif GetQuizQuestions .answerID eq #form.3#><cfset score = score +
1></cfif>
<cfif GetQuizQuestions .answerID eq #form.4#><cfset score = score +
1></cfif>
<cfif GetQuizQuestions .answerID eq #form.5#><cfset score = score +
1></cfif>
Also, will it be a problem that my form names which are ID's will be
numbers, ie 1 or 2 or 3 etc?
Any help on this would be great,
Thanks,
Saturday
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:219952
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54