Skip to main content
July 16, 2008
Question

Creating Questions & Tallying Scores

  • July 16, 2008
  • 1 reply
  • 619 views
Greetings

I am creating online tests in which the user score needs to be recorded.

I have them log in and go to the test, which creates a new record in the DB with the date and start time. After submitting the test, the number correct and finish time updates their record based on the session_ID variable.

The way I have set up the test form is attached. Each question has its own query (X50) and the correct answers are tallied with the action code.

My issues are:

1) Can this be accomplished without the necessity of a query for each question?
2) What's the safest way to keep their ID variable alive - session or application (some may have cookies disabled- they will be taking the test from multiple locations)?
3) Is there a more efficient way to tally the score?
3) I am using what they enter in as their employee number for the session_ID- could this be an issue?

Thanks in advance for any advice.

rinorman
This topic has been closed for replies.

1 reply

Inspiring
July 22, 2008
newportri,

I would say there is probably a much better way to do what you want to do, however before taking the time to write you some code I have a few questions.

First, do you have all the questions on one page or is it one question per page?
Second, do you need to tally the scores as you go or can you tally at the end of the test?

I also noticed you have an extra step in those code:

<cfif #form.ans_02# eq #ans_correct#>
<CFSET num_correct = num_correct +1>
<cfelse>
<CFSET num_correct = num_correct +0>
</cfif>

What's the point of adding zero? Why not just have...
<cfif #form.ans_02# eq #ans_correct#>
<CFSET num_correct = num_correct +1>
</cfif>

Answer the questions above and I'm sure we can come up with a better way. Off hand I would think you should only run one query to get the answers then loop through the query to tally scores. No sense having a query for each question.
July 22, 2008
mr. modus

Thanks for your response.

All questions are on one continuous page.

I think I got errors until I added the +0 thing

The code at the end of the tallying page is:

<cfoutput>

<cfquery datasource="some_db" name="correct_answers">
UPDATE testtaker
SET num_correct = ('#num_correct#')
WHERE test_taker_ID = #test_taker_ID#
</cfquery></cfoutput>

<cfoutput>

<cfquery datasource="some_db" name="end_tme">
UPDATE testtaker
SET test_taker_tm_end = ('#endtime#')
WHERE test_taker_ID = #test_taker_ID#
</cfquery></cfoutput>

The method of counting correct answers when there is more than one ("check all that apply") through me off as far as looping through questions/answers.

Thanks again for your help.

newportri