Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project,(e-learning tool) I stored questions and correct answers in SQL data base table(More than one word separate in space). Questions are lorded in a text box once at a time.If i want go for next question need click next button. then the next question is lord the same text box .Then student can type relevant answer in another text box. Then I have to match that given answer with the correct answer in data base.could you please give me a sample code for that in ASP.net C#
Posted
Comments
Kuthuparakkal 19-Aug-12 5:17am    
What have you tried so far ? Is this an homework ?
ridoy 19-Aug-12 6:27am    
There will be several string patterns that you will need to match user's answer with your database data..now question is which pattern would you follow?show some code of you..then we will understand

This is not a question we can answer: it gets horribly complicated, depending on what you personally consider to be a "right" answer.

Suppose the question and answer in your DB are:
"What car is that?"
"Mercedes CLK550"

What do you allow as a "correct" answer?
"mercedes clk550"
"Mercedes CLK 550"
"clk550"
"MERCEDES"
"CLK 550 mercedes"
All five of them are technically correct answers.
How about:
"Mmercedes clk550"
"Merkedes CLK 550"
"clk-550"
"MERC 550"
"CLK%%) mercedes"
Which are pretty close?
And that is only with a simple, direct question with a fact as an answer.

As soon as you start allowing text based answers, you open up a world where the user is going to get frustrated because either your definition of "correct" is too narrow, and requires him to enter exactly what you have in the database, although he doesn't know what you have in the database and must guess, or you software has to be extremely clever and work out what he meant by his answer rather than exactly what he wrote.

It's possible - google does it all the time - but it is far, far too big a question for a simple answer here!
 
Share this answer
 
Open ended questions are really hard to evaluate automatically. First of all because in most cases there are several correct answers - in rare cases is the test writer able to think of all possible formulations, that could be acceptable at that point. Of course, there are cases, where only one exact answer is good, like with some grammatical assessments. But in general these kind of test items are evaluated by the instructor or, if there is no such possibility, other kind of tests are used.
But if you stick to what's in the question you posted:
C#
string CorrectAnswers=...; // load the spcae separated list
string AnswerGiven =...; // the answer you got

if(CorrectAnswers.Split(' ').Any(x => x == AnswerGiven))
{
  // the answer given is one of the acceptable answers
}
 
Share this answer
 
v2
Make multiple-choice for questions with fuzzy answers.
Open questions in e-learning tools is a pain: either you expect literally exact answers (like giving a number = no problem to exactly match) or you need to invent some kind of heuristics to "interprete" the entered phrase.

Text correlation algorithms do not work since you first had to filter out "filler" words and compare the rest by *correlation* to the correct answer. If you want to cover typos that have no semantic relevance, you must be very smart (BTW: which typos are semantically relevant and which are not?).

So, why all that pain that may even lead to wrong rating due to the inherent character of heuristics (they work most of the time but not not always...)?

Summary:
- Allow only textual user entry if it is an exact answer (e.g. exact number).
- Go for multiple-choice if you aske questions that may lead to fuzzy answers.

Cheers
Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900