简体   繁体   English

为每个用户创建随机测试题的最佳方法

[英]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) 银行(将存储银行名称和描述的位置)的问题(将存储银行的问题的位置,每个问题与具有外键bank_id的银行相关)答案(其中答案与每个具有Question_id的问题相关)并且有一列要知道答案是否正确)

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. 我虽然制作了新表,并在它们具有相同的问题和答案表内容的情况下将它们称为assigned_questions和assigned_answers,但是它们是为每个用户随机分配的。 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 有关在此处随机选择的更多信息: https : //stackoverflow.com/a/12870681/3093731

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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