D
D
Diamond2015-05-29 23:20:14
PHP
Diamond, 2015-05-29 23:20:14

How to store user responses and display questions in the testing system?

Hello! I am writing a testing system where I would like to store the user's answer to each question, but I don't know how to save the answers. It comes to mind, only: to create a column "user_answers" of type TEXT and write down the question ID in this way || Response ID, or responses separated by commas ||| Question ID || Response IDs and so on. Maybe there are other options?
How can I display questions for the user and how can I save the selected answer? Well, you can save the answer after clicking on the "answer" button, the selected answer will be recorded in the database as described above, but how to display answers to which the user has not yet answered? Check the user_answers column each time?
Ps sorry for this wording!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-05-29
@Arios

3 tables:

questions:
id | question

answers:
id | question_id | answer

answer_user
answer_id | user_id (или question_id | answer_id | user_id)

When the user replies, write the answer to answer_user .
The usual many to many relationship.
> how to display answers to which the user has not yet answered
We get all the answers by question_id from answers + join to the anwser_user table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question