简体   繁体   中英

Best approach to create randomized test questions for every user

What is the best approach to solve this problem?

If I have a questions bank that contains a lot of questions, and I need to make a test that takes a specific number of questions from that bank and randomize the questions for each user.

The way that I am gonna do it is by creating the following tables

banks (where the bank name and description will be stored) questions ( where the questions for banks will be stored, and each question is related to a bank with a foreign key bank_id) answers (where answers are related to each of the questions with question_id and there is a column to know if the answer is correct or not)

I though of making new tables and call them assigned_questions and assigned_answers where they have the same content of questions and answers tables however they are randomized and specified for each of the users. Then deleting the questions and answers after recording the score the user or student got in the test.

No don't duplicate your questions into a new table. Duplication is bad

You could just randomly select questions from the table of questions

eg:

SELECT question FROM questions
INNER JOIN answers ON answers.question_id = questions.answer_id
ORDER BY RAND()
LIMIT 10

More on random selecting here: https://stackoverflow.com/a/12870681/3093731

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM