Solved

Should I put questions and answers in the same database?

Posted on 2002-07-23
7
122 Views
Last Modified: 2013-12-24
Hi...

If I create a website with questions and let user answers my questions, should those questions and answers be in one database (different table, of course) or should it be in 2 separate databases? I am just thinking will this have any effect from security point of view? I would like those "answers" to be very secure and wonder how should I go about it.

Then, from programming point of view, how should I write a program to check for correct answers and reply the user?

Hope I can get some help on this and I only have 100 points left, if you don't mind...

Thanks a lot.
JH Lai
0
Comment
Question by:buybuy
  • 3
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
CFXPERT earned 100 total points
ID: 7172405
The questions and answers can be in two tables under one database.  Having them in two seperate databases would not increase any kind of security that I can see.

Question Table:
questID  auto increment number
question varchar (whatever length will be enough)

Answer Table:
questID  (ID of question from question table)
answerID (auto incement number)
answerCode (a,b,c,d, etc)
answerDesc  varchar (actual text for the answer)

As far as the programming goes.  I would ask a question then give the user some multiple choice answers.  If the user checks "A" then hits submit you would then pass both the questionID and the answerCOde that the user chose and query your answer table like so:

<cfquery name="getAnswer" datasource="whatever">
select answerCode
from answer
where questID = #form.questID#
and answerCode = '#form.answerCode#'
</cfquery>

Then check to see if the user was correct.

<cfif getAnswer.recordcount EQ 1>
***Correct Answer***
<cfelse>
***Wrong Answer***
</cfif>

This methodology can be easily enhanced and improved on but this should give you some basic understanding and fundementals to get you going in the right direction.

Hope this helps you out.

KWK
0
 
LVL 5

Expert Comment

by:Yog
ID: 7172845
yeah in addition, if you dont want other admins to read question you can encrypt the text when saving to DB and decrypt when displaying..
0
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7173033
Any luck yet buybuy?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:buybuy
ID: 7176757
It works great! Thanks.

If I have 10 questions, would it be easier to store those answers in a temporary table and check for correct answer later on?

I am not sure how after

<cfif getAnswer.recordcount EQ 1>
***Correct Answer***
<cfelse>
***Wrong Answer***
</cfif>

that I can go to next question. Any suggestions? Which one of the above is preferred? Thanks again.
0
 

Author Comment

by:buybuy
ID: 7176829
And... How to write a program to limit each question to 1 minit? After that, it will automatically goes to next question.
0
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7177778
There are a few ways to accomplish this task.  One way would be to simply give the user one page with all the questions and multiple choice answers.  Once the user has answered all 10 questions he or she will press a submit button called "Grade Test".

You simply post all of the fields (checkboxes) to your grading script.

Grading Script will take all of these answers and check them one at a time against the answer table.

Then you can output the results to the user.

If you need some actual code written I'll be happy to write some stuff for ya for some extra points of course.

As far as limiting them to 1 minute, well that just depends how you want the test set up.  If you want 1 question per page then just add a javascript timer when the page laods  something like setTimeout(next,1000) then then function next() goes to the next question but this kind of defeats the form submittal method.  You could use cold fusion sessions or cookies to carry over the answers to the next page and then finally the grading page.  Kinda like a shopping cart methodology.
0
 

Author Comment

by:buybuy
ID: 7181463
Yes. CFXPERT. I need some actual code, but later. Right now, I need to do something else (Coldfusion too). How can I contact you? I will need your assistance in that area and I will send you e-mail regarding that. And find out from you how many points it will take to do it if you can help.

Then, I will post the question here and wait for you comment so I can transfer the point to you. I think this is how it should be done, right? I am very new to this site and used up 300 points already, for 2 questions. :) But no regret, I love this site. I will buy more points (not too expensive) but don't like the 3.8 foreign exchange rate.

You can send me e-mail to: laijh@hotmail.com
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now