请问段落填空题如何设计数据库?

如下面的一道 段落填空 ,横线处需要写入具体的单词(或者选择选项:完型填空)

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 中储存这道大题和小题已实现下面的功能:

  1. 管理员可以比较方便地编辑这个题目(最好使用富文本编辑器编辑)
  2. 考生完成后,可以由程序得出分数(答案已知且固定)
  3. 需要把考生的错误的小题记录下来

现在的设计:

题目 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 题目的答案

请问这样的设计是否合理?或者各位有什么好的建议吗?
谢谢!

stackoverflow.com 相同问题

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
最佳答案

可以先创建答案,然后在需要答案的地方插入答案

<p>Scientists want to know whether global warming is caused by [:answer-1] . Insulation may cause the Earth to [:answer-2]. There are many [:answer-3] on the global climate. The [:answer-4]  does not remain static. We cannot understand the global climate without understanding [:answer-5].<p>

这样可以避免题目变化带来的serial_number变化

2年前 评论
讨论数量: 3

可以先创建答案,然后在需要答案的地方插入答案

<p>Scientists want to know whether global warming is caused by [:answer-1] . Insulation may cause the Earth to [:answer-2]. There are many [:answer-3] on the global climate. The [:answer-4]  does not remain static. We cannot understand the global climate without understanding [:answer-5].<p>

这样可以避免题目变化带来的serial_number变化

2年前 评论

小题表的作用是啥

2年前 评论
家猪配种专家 (楼主) 2年前

编辑和存储可以分开处理。每种题型用 type 字段区分,这里以段落填空为例。
管理员在后台输入:

Scientists want to know whether global warming is caused by <u>balabal1</u> . Insulation may cause the Earth to <u>balabal2</u>. There are many <u>balabal1</u> on the global climate.

这里使用下划线(<u>)是为了保持大家的习惯。当然也可以用 [:question],只要是一个特殊标记即可。如果使用下划线,可能要在后台提供一个富文本编辑器,以方便管理员操作。

解析文本:
后台提交之后,我们可以把文本按照一定的规则进行存储,例如:

  1. 第一种:把下划线标注的文本提取出来作为答案,单独存在一个表中,剩余的文本存储文题目,空出来的地方用下划线代替。
  2. 第二种:把文本按照下划线打散,标注序号,存在 json 中。甚至于我们可以做一个 term 表,这些表的每一行存储的可能是类似于
id type content sort topic_id(题目ID)
1 sentence Scientists want to know whether global warming is caused by 1 1
2 answer balabal1 2 1
3 sentence . Insulation may cause the Earth to 3 1
4 answer balabal2 4 1
5 sentence . There are many 5 1

总之来说可以把文本拆分的很细,也可以一股脑的存在 json 中,拆分的很细,即意味着我们设计的数据库很精细,也就需要付出更多地精力,但是换来的就是可操作性,例如可以把一个空或者一个句子当成一个 model。

不要局限在 一个题目 = 一个model 的层面,题目还可以再往下拆分,可以设计出更合理的数据库结构。

2年前 评论
家猪配种专家 (楼主) 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!