Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
hello,
i have two tables one is quiz in which questions and the correct answer is stored
another table is result in which the answer given by user is stored.
there are total of 10 questions.
how to compare the correct answer and answer given by user and give 0.2 marks for every correct answer .
 
how can i do this in vb.net.
code plz
Posted 25-Sep-12 3:07am
Edited 25-Sep-12 3:10am
CPallini319.6K
v2
Comments
Zoltán Zörgő at 25-Sep-12 9:10am
   
What exactly is a table in your case? What is it's digital representation?
Jasbeer Singh at 25-Sep-12 9:14am
   
database table.. two tables stored in database. one is quiz where the admin stores questions and correctanswer and other table is result where the answers from user gets stored as he performs the quiz.
i want to declare the result that how many are correct and for every correct answer, i have to give 0.2 marks to user.
Zoltán Zörgő at 25-Sep-12 9:23am
   
Could you give us the ddl (schema) of these two tables.
Jasbeer Singh at 25-Sep-12 9:31am
   
table1: quiz (in this table admin stores questions, options, and correct option)
Columns: Qno,Que,Opt1,opt2,opt3,opt4,sCorrectans
Table2: result (the answers given by user is stored in this table)
columns: Qno,Que,ans
 
now i want to match sCorrectans from table1 quiz and ans from table2: result to check how many answers given by user are correct, anf for every correct answer, user gets 0.2 marks
Zoltán Zörgő at 25-Sep-12 9:36am
   
Is sCorrectans and ans a string or the index of the correct and the given option (1,2,3,4)?
Jasbeer Singh at 25-Sep-12 9:51am
   
sCorectans contains the correct option given by admin.. it is the column name.
and ans contains the answers given by user, this is also a column name , both from different tables.
Zoltán Zörgő at 25-Sep-12 12:32pm
   
OK. Qno is the question number I suppose, but what is Que? It should be the user id (or that like) in the result table, but what is it's meaning in the quiz table?
Jasbeer Singh at 26-Sep-12 0:58am
   
Qno is the question no.
Zoltán Zörgő at 26-Sep-12 2:10am
   
Yes, I have noticed that. I asked about Que.
Jasbeer Singh at 26-Sep-12 2:15am
   
que is the question
Zoltán Zörgő at 26-Sep-12 2:24am
   
Ok - even if I can't see it's purpose in the result table.
And how you bind the answers in the result table to the respondent?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It looks as if you are creating four multiple choice answers. Then, the user has to select one of the answers and when they are done, they submit them? I mean, I am only guessing because you say you have two tables, but you want this done in Visual Basic, wouldn't the tables be in a database?
 
As an example, create a 'RadioButtonList' and put four 'RadioButtons' in there. If you really want to do all of this in visual basic, you would have to dynamically create a RadioButtonList and the four radio buttons, then add the radiobuttons to the list.
 
As far as validating the proper answer, set three of the buttons to some value such as "No" or -1. The right answer would be...the actual answer. Then, I don't know how you are storing the answers...you say a table. Just compare the value of the radiobutton that was selected with the answer.
 
The user will start off with a score of zero, and if the question is answered right, add .02 to the score.
 
If you want to be a little more specific as to how you are doing this (post your code here), I will fix it for you, or if you have no code and need somewhere to start, just ask and I will help you.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
In your case you have two table.
I have done this using single table.
When user start Test that time one table contain Question,Ans1,Ans2,Ans3,Ans4,CorrectAns and SelectedAns.
When user press next button that time update SelectedAns field. Every time next button update that particular Row. When Press Finish or End Button that time calculate result using SelectedAns Field.
 

Try this. It's simple and Also easy to calculate result.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,725
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,589
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100