请问段落填空题如何设计数据库?
如下面的一道 段落填空 ,横线处需要写入具体的单词(或者选择选项:完型填空)
Scientists want to know whether global warming is caused by ____1_____ . Insulation may cause the Earth to ____2_____ . There are many ____3_____ on the global climate. The ____4_____ does not remain static. We cannot understand the global climate without understanding ____5_____ .
这道大题包含 5 个小题,请问如何在 MySQL 中储存这道大题和小题已实现下面的功能:
- 管理员可以比较方便地编辑这个题目(最好使用富文本编辑器编辑)
- 考生完成后,可以由程序得出分数(答案已知且固定)
- 需要把考生的错误的小题记录下来
现在的设计:
题目 tests
表
字段 | 类型 | 说明 |
---|---|---|
id | 自增 int | 主键 |
question | longText | 由富文本编辑得到的题目内容 |
管理员在编辑题目时需要使用特殊的字符(例如[:question]
),例如:上面的题目在编辑时,管理员在富文本框内输入的内容是:
Scientists want to know whether global warming is caused by [:question] . Insulation may cause the Earth to [:question]. There are many [:question] on the global climate. The [:question] does not remain static. We cannot understand the global climate without understanding [:question].
得到的内容是
<p>Scientists want to know whether global warming is caused by [:question] . Insulation may cause the Earth to [:question]. There are many [:question] on the global climate. The [:question] does not remain static. We cannot understand the global climate without understanding [:question].<p>
然后前端或后端遍历这个内容,找出所有的 [:question]
,每一个小题生成小题表(questions
表)里面的一行记录:
小题 questions
表
字段 | 类型 | 说明 |
---|---|---|
id | 自增 int | 主键 |
test_id | unsignedBigInteger | 外键 |
serial_number | unsignedInteger | 该 test 中的第几个 question |
type | char | 填空、单选、多选 |
options | json (nullable) | 题目的选项 |
answer | json | 题目的答案 |
请问这样的设计是否合理?或者各位有什么好的建议吗?
谢谢!
可以先创建答案,然后在需要答案的地方插入答案
这样可以避免题目变化带来的
serial_number
变化