Click here to Skip to main content
13,089,943 members (42,416 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to create online quiz having multiple options, questions will come from db.Question and coresponding options will show one page at a time ................
Posted 30-Apr-13 0:03am
Sudhakar Shinde 30-Apr-13 8:38am
Use google and you will find multiple options for this query.
Sandeep Mewara 30-Apr-13 16:17pm
It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi Rupal,

Create a database with following tables

Table1: dbo.Questions
QuestionID int (PK)
QuestionText nvarchar(max)
CorrectAnswerID int (FK)
Table2: dbo.Answers
AnswerID int (PK)
AnswerText nvarchar(max) 
QuestionID int (FK)

Table3: dbo.AnswerOptionType
OptionID int (PK)
AnswerID int (FK)
OptionType nvarchar(max) --TextBox, RadioButton, CheckBox, Multiline TextBox
Table4: dbo.UserAnswers
UserAnswerID int (PK)
QuestionID int (FK)
AnswerID int (FK)

I hope you would have understood the relationship between the above tables.

In your presentation layer (winforms or webforms), follow the following steps:

Step 1: Query the database to get all the questions and set of answers. The data query result would look like:
QuestionID, AnswerID, QuestionText, AnswerText, OptionType

Step2: Store the above data result (I suppose it would be datatable) as a session variable

Step 3: Loop through one question at a time when the user clicks start or next or previous

Step 4: Based on the option type in the result in step 1, generate dynamic controls and give the ID of those controls as Answer ID for the options

Step 5: When the user clicks next, save the selected answer to the database in Table4

I hope this would give you some direction in coding. Of course this isn't a perfect solution, but you an tweak around.

Hope it helps. Happy coding..!!


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 1 May 2013
Copyright © CodeProject, 1999-2017
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