0

I'm doing a personal project where I have a quiz with a number of boolean questions. Each question will have a two answer choices "true" and "false". Based on the selected answer, a new question will be asked with the similar pattern and based on that an another question. Any question may have any or no number of sub-questions.

The last questions in the tree (E, D) and questions with no sub-questions (F) will also store the correct answer from either "true" or "false".

The alphabets A,B,C,D,E,F are questions. A quiz can have any number of master questions (like A), sub-questions like (like B,C,D,E) and individual questions (like F).

Kindly help me design a simple database schema for for this kind of quiz. I'm open to both relational (mysql) and document (mongodb) databases.

concept diagram

asked Jan 14, 2015 at 12:23
2
  • this doesn't help you writing the code, but tools such as Survey Gizmo and Survey Monkey can do this for you, if that's an option. Commented Jan 15, 2015 at 22:09
  • what doesn't help? Survey Monkey or any other quiz platform outside is not an option. Commented Jan 20, 2015 at 8:31

3 Answers 3

1

In relational database, you should create a table called Questions which should contain following fields:

  1. ID
  2. QuestionString
  3. QuestionType (Master, Individual, sub-question)
  4. TrueCase (here you should store the ID of the next question. Since we'll store all questions in this table, therefore each questions shall have unique ID)
  5. FalseCase (ID of the question to ask if answer is not correct. If ID is null, then you should exit)

Hope it helps.

ypercubeTM
99.7k13 gold badges217 silver badges306 bronze badges
answered Jan 14, 2015 at 13:00
1
 * User
 - user_id auto integer
 - regtime datetime
 - username varchar
 - useremail varchar
 - userpass varchar
* Question
 - question_id auto integer
 - question varchar
 - is_active enum(0,1)
* Question_choices
 - choice_id auto integer
 - question_id integer
 - is_right_choice enum(0,1)
 - choice varchar
* User_question_answer
 - user_id integer
 - question_id integer
 - choice_id integer
 - is_right enum(0,1)
 - answer_time datetime
answered Jun 25, 2015 at 16:15
1
  • Please explain it a bit and show the relations between the tables. Commented Jun 25, 2015 at 16:29
0

I have an idea about mongoDB.

You can pre-create the quiz by using as field names the correct answer (true or false). When the player gives an answer you will have to check if the field exists. An example document is the below one:

{Question:"":{true:{Question:{"text goes here",false:{}...}}}

So if he answer true the first in order to validate you have to check if the document Question.true exists. If is the correct answer was true and the next answer is false you have to check if Question.true.false exists...

answered Jan 15, 2015 at 19:34
3
  • Thanks Antonis, I didn't get what you said after reading for the first time. I'll spend some more time analyzing your suggestion. Commented Jan 16, 2015 at 11:20
  • No worries, i am much better with drawing than writing. In general the idea is nested documents and for field name of each nested document use the correct answer of the previous question. Its like following a hierarchical tree with two branches (true,false) but always only the "correct branch" is present. We can discuss this further on the chat if you like. Commented Jan 20, 2015 at 3:36
  • thats fine but it seems mongodb is not the right database to get 10 random quiz questions for a user without repetition till all options are exhausted Commented Feb 24, 2017 at 12:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.