Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP MySQL
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 1:03am
Comments
Sudhakar Shinde at 30-Apr-13 8:38am
   
Use google and you will find multiple options for this query.
Sandeep Mewara at 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
good
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..!!
 
Cheers,
Nayan
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 1 May 2013
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