install.sql 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_cate` (
  2. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  3. `kind` enum('QUESTION','PAPER','ROOM','COURSE') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'QUESTION' COMMENT '种类',
  4. `level` enum('1','2','3') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1' COMMENT '类型',
  5. `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '名称',
  6. -- `icon` VARCHAR(200) NULL DEFAULT '' COMMENT '图标' COLLATE 'utf8mb4_unicode_ci',
  7. `parent_id` int(11) NOT NULL DEFAULT '0' COMMENT '父级',
  8. `sort` int(11) NOT NULL DEFAULT '1' COMMENT '排序',
  9. `remark` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '简介',
  10. `deletetime` bigint(16) DEFAULT NULL COMMENT '删除时间',
  11. `status` ENUM('0','1') NOT NULL DEFAULT '1' COMMENT '状态:0=禁用,1=启用' COLLATE 'utf8_general_ci',
  12. PRIMARY KEY (`id`),
  13. KEY `parent_id` (`parent_id`),
  14. KEY `kind` (`kind`)
  15. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='试题分类';
  16. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_config_info` (
  17. `id` int(11) NOT NULL AUTO_INCREMENT,
  18. `ad_config` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '广告位配置',
  19. `system_config` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '系统配置',
  20. `wx_config` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '微信配置',
  21. `page_config` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '页面配置',
  22. PRIMARY KEY (`id`) USING BTREE
  23. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='参数配置';
  24. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_grade` (
  25. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  26. `cate_id` int(11) unsigned NOT NULL COMMENT '所属分类',
  27. `user_id` int(11) unsigned NOT NULL COMMENT '考试用户',
  28. `paper_id` int(11) unsigned NOT NULL COMMENT '所属试卷',
  29. `mode` ENUM('RANDOM','FIX') NOT NULL DEFAULT 'RANDOM' COMMENT '选题模式' COLLATE 'utf8mb4_unicode_ci',
  30. `score` tinyint(3) unsigned NOT NULL COMMENT '考试分数',
  31. `system_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '系统得分',
  32. `manual_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '人工判分',
  33. `is_pass` tinyint(3) unsigned NOT NULL COMMENT '是否及格',
  34. `total_score` tinyint(3) unsigned NOT NULL COMMENT '总分数',
  35. `total_count` tinyint(3) unsigned NOT NULL COMMENT '总题数',
  36. `right_count` tinyint(3) unsigned NOT NULL COMMENT '答对数',
  37. `error_count` tinyint(3) unsigned NOT NULL COMMENT '答错数',
  38. `grade_time` int(10) unsigned NOT NULL COMMENT '考试用时',
  39. `date` CHAR(10) NOT NULL DEFAULT '' COMMENT '考试日期',
  40. `question_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '试卷ID集合' COLLATE 'utf8mb4_unicode_ci',
  41. `error_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '错题ID集合' COLLATE 'utf8mb4_unicode_ci',
  42. `user_answers` TEXT NULL DEFAULT NULL COMMENT '用户答案集合' COLLATE 'utf8mb4_unicode_ci',
  43. `configs` TEXT NULL DEFAULT NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci',
  44. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  45. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  46. PRIMARY KEY (`id`) USING BTREE,
  47. KEY `user_id` (`user_id`),
  48. KEY `paper_id` (`paper_id`),
  49. KEY `work_type_id` (`cate_id`) USING BTREE
  50. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='考试成绩';
  51. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_notice` (
  52. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  53. `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '标题',
  54. `contents` varchar(2000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '内容',
  55. `weigh` int(11) NOT NULL DEFAULT '1' COMMENT '排序',
  56. `status` enum('NORMAL','HIDDEN') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NORMAL' COMMENT '状态',
  57. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  58. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  59. PRIMARY KEY (`id`) USING BTREE
  60. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统公告';
  61. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_paper` (
  62. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  63. `cate_id` int(11) unsigned NOT NULL COMMENT '试卷分类',
  64. `mode` enum('RANDOM','FIX') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'RANDOM' COMMENT '选题模式',
  65. `title` varchar(3000) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '试卷名称',
  66. `configs` varchar(3000) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '选题配置',
  67. `quantity` int(10) unsigned NOT NULL COMMENT '题目数量',
  68. `total_score` tinyint(3) unsigned NOT NULL COMMENT '试卷总分',
  69. `pass_score` tinyint(3) unsigned NOT NULL COMMENT '及格线',
  70. `limit_time` int(10) unsigned NOT NULL COMMENT '考试限时',
  71. `join_count` int(10) NOT NULL DEFAULT '0' COMMENT '参与人次',
  72. `day_limit_count` INT(10) NOT NULL DEFAULT '0' COMMENT '每日限制考试次数',
  73. `start_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '开始时间',
  74. `end_time` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '过期时间',
  75. `is_only_room` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '仅用于考场',
  76. `status` enum('NORMAL','HIDDEN') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NORMAL' COMMENT '状态',
  77. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  78. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  79. `deletetime` bigint(16) DEFAULT NULL COMMENT '删除时间',
  80. PRIMARY KEY (`id`) USING BTREE,
  81. KEY `cate_id` (`cate_id`,`status`) USING BTREE
  82. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='试卷';
  83. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_paper_question` (
  84. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  85. `paper_id` int(11) unsigned NOT NULL COMMENT '所属试卷',
  86. `question_id` int(11) unsigned NOT NULL COMMENT '试题',
  87. `score` int(10) unsigned NOT NULL COMMENT '分数',
  88. `sort` int(10) unsigned NOT NULL DEFAULT '1' COMMENT '排序',
  89. `answer_config` TEXT NULL DEFAULT NULL COMMENT '正确答案配置' COLLATE 'utf8mb4_unicode_ci',
  90. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  91. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  92. `deletetime` bigint(16) DEFAULT NULL COMMENT '删除时间',
  93. PRIMARY KEY (`id`) USING BTREE,
  94. KEY `paper_id` (`paper_id`),
  95. KEY `question_id` (`question_id`)
  96. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='试卷试题';
  97. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_question` (
  98. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  99. `cate_id` int(11) unsigned NOT NULL COMMENT '分类',
  100. `kind` enum('JUDGE','SINGLE','MULTI','FILL','SHORT','MATERIAL') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'JUDGE' COMMENT '试题类型',
  101. `title` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '题目',
  102. `explain` varchar(2000) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '解析',
  103. `difficulty` enum('EASY','GENERAL','HARD') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'GENERAL' COMMENT '难度',
  104. `options_json` text COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '选项',
  105. `options_img` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '选项图片',
  106. `options_extend` TEXT NULL DEFAULT NULL COMMENT '选项扩展' COLLATE 'utf8mb4_unicode_ci',
  107. `answer` TEXT NOT NULL COMMENT '正确答案' COLLATE 'utf8mb4_unicode_ci',
  108. `status` enum('NORMAL','HIDDEN') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NORMAL' COMMENT '状态',
  109. `is_material_child` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '属于材料题子题:0=否,1=是',
  110. `material_question_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '所属材料题',
  111. `material_score` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '材料子题分数',
  112. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  113. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  114. `deletetime` bigint(16) DEFAULT NULL COMMENT '删除时间',
  115. PRIMARY KEY (`id`),
  116. KEY `kind` (`kind`,`status`) USING BTREE,
  117. KEY `cate_id` (`cate_id`,`kind`,`status`) USING BTREE
  118. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='试题';
  119. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_question_collect` (
  120. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  121. `user_id` int(11) unsigned NOT NULL COMMENT '用户',
  122. `question_id` int(11) unsigned NOT NULL COMMENT '试题',
  123. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  124. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  125. PRIMARY KEY (`id`) USING BTREE,
  126. KEY `question_id` (`question_id`) USING BTREE,
  127. KEY `user_id` (`user_id`) USING BTREE
  128. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='题目收藏';
  129. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_question_wrong` (
  130. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  131. `user_id` INT(11) UNSIGNED NOT NULL COMMENT '用户',
  132. `question_id` INT(11) UNSIGNED NOT NULL COMMENT '试题',
  133. `user_answer` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '用户答案' COLLATE 'utf8mb4_unicode_ci',
  134. `kind` ENUM('PAPER','ROOM','TRAINING') NULL DEFAULT 'PAPER' COMMENT '来源:PAPER=试卷,ROOM=考场,TRAINING=练题' COLLATE 'utf8mb4_unicode_ci',
  135. `createtime` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
  136. `updatetime` BIGINT(16) UNSIGNED NULL DEFAULT NULL COMMENT '修改时间',
  137. PRIMARY KEY (`id`) USING BTREE,
  138. INDEX `question_id` (`question_id`) USING BTREE,
  139. INDEX `kind` (`kind`) USING BTREE,
  140. INDEX `user_id` (`user_id`, `kind`) USING BTREE
  141. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='错题记录';
  142. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_room` (
  143. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  144. `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '考场标题',
  145. `contents` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '考场说明',
  146. `cate_id` int(11) NOT NULL COMMENT '考场分类',
  147. `paper_id` int(11) NOT NULL COMMENT '考试试卷',
  148. `people_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '限制考场人数',
  149. `start_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '考试开始时间',
  150. `end_time` bigint(16) NOT NULL DEFAULT '0' COMMENT '考试结束时间',
  151. `weigh` int(11) NOT NULL DEFAULT '1' COMMENT '排序',
  152. `status` enum('NORMAL','HIDDEN') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NORMAL' COMMENT '状态',
  153. `signup_mode` enum('NORMAL','PASSWORD','AUDIT') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'NORMAL' COMMENT '报名方式:NORMAL=普通模式,PASSWORD=密码模式,AUDIT=审核模式',
  154. `password` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '考场密码',
  155. `is_makeup` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否允许补考:0=关闭,1=开启',
  156. `makeup_count` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '补考次数',
  157. `is_rank` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否已排名',
  158. `signup_count` tinyint(4) NOT NULL DEFAULT '0' COMMENT '报考人数',
  159. `grade_count` tinyint(4) NOT NULL DEFAULT '0' COMMENT '考试人数',
  160. `pass_count` tinyint(4) NOT NULL DEFAULT '0' COMMENT '及格人数',
  161. `pass_rate` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '及格率',
  162. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  163. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  164. `deletetime` bigint(16) DEFAULT NULL COMMENT '删除时间',
  165. PRIMARY KEY (`id`) USING BTREE,
  166. KEY `paper_id` (`paper_id`),
  167. KEY `status` (`status`) USING BTREE,
  168. KEY `cate_id` (`status`,`cate_id`)
  169. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='考试考场';
  170. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_room_grade` (
  171. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  172. `user_id` int(11) NOT NULL COMMENT '考试用户',
  173. `cate_id` int(11) unsigned NOT NULL COMMENT '所属分类',
  174. `room_id` int(11) unsigned NOT NULL COMMENT '所属考场',
  175. `paper_id` int(11) unsigned NOT NULL COMMENT '所属试卷',
  176. `mode` ENUM('RANDOM','FIX') NOT NULL DEFAULT 'RANDOM' COMMENT '选题模式' COLLATE 'utf8mb4_unicode_ci',
  177. `score` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '考试分数',
  178. `system_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '系统得分',
  179. `manual_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '人工判分',
  180. `is_pass` tinyint(3) NOT NULL DEFAULT '0' COMMENT '是否及格:0=不及格,1=及格',
  181. `is_makeup` tinyint(3) NOT NULL DEFAULT '0' COMMENT '是否是补考:0=否,1=是',
  182. `total_score` tinyint(3) NOT NULL DEFAULT '0' COMMENT '总分数',
  183. `total_count` tinyint(3) NOT NULL DEFAULT '0' COMMENT '总题数',
  184. `right_count` tinyint(3) NOT NULL DEFAULT '0' COMMENT '答对数',
  185. `error_count` tinyint(3) NOT NULL DEFAULT '0' COMMENT '答错数',
  186. `rank` tinyint(3) NOT NULL DEFAULT '0' COMMENT '本次考试排名',
  187. `is_pre` tinyint(3) NOT NULL DEFAULT '0' COMMENT '是否为预载入数据',
  188. `grade_time` int(10) unsigned NOT NULL COMMENT '考试用时',
  189. `question_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '试卷ID集合' COLLATE 'utf8mb4_unicode_ci',
  190. `error_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '错题ID集合' COLLATE 'utf8mb4_unicode_ci',
  191. `user_answers` TEXT NULL DEFAULT NULL COMMENT '用户答案集合' COLLATE 'utf8mb4_unicode_ci',
  192. `configs` TEXT NULL DEFAULT NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci',
  193. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  194. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  195. PRIMARY KEY (`id`) USING BTREE,
  196. KEY `user_id` (`user_id`) USING BTREE,
  197. KEY `paper_id` (`paper_id`) USING BTREE,
  198. KEY `cate_id` (`cate_id`) USING BTREE,
  199. KEY `FK2_exam_room_grade_with_exam_room` (`room_id`)
  200. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='考场考试成绩';
  201. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_room_signup` (
  202. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  203. `room_id` int(11) unsigned NOT NULL COMMENT '所属考场',
  204. `user_id` int(11) unsigned NOT NULL COMMENT '报名用户',
  205. `real_name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '真实姓名',
  206. `phone` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '手机号码',
  207. `message` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '审核说明',
  208. `status` enum('0','1','2') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '状态:0=未审核,1=报名成功,2=报名被拒绝',
  209. `createtime` bigint(16) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  210. `updatetime` bigint(16) unsigned DEFAULT NULL COMMENT '修改时间',
  211. PRIMARY KEY (`id`) USING BTREE,
  212. KEY `room_id` (`room_id`,`status`),
  213. KEY `user_id` (`user_id`,`status`)
  214. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='考场报名';
  215. -- 1.0.2版本,新增考卷每日限制考试次数
  216. ALTER TABLE `__PREFIX__exam_paper` ADD COLUMN `day_limit_count` INT(10) NOT NULL DEFAULT '0' COMMENT '每日限制考试次数' AFTER `join_count`;
  217. ALTER TABLE `__PREFIX__exam_grade` ADD COLUMN `date` CHAR(10) NOT NULL DEFAULT '' COMMENT '考试日期' AFTER `grade_time`;
  218. -- 1.0.4版本,新增系统配置 - 页面配置
  219. ALTER TABLE `__PREFIX__exam_config_info` ADD COLUMN `page_config` MEDIUMTEXT NULL DEFAULT NULL COMMENT '页面配置' COLLATE 'utf8mb4_unicode_ci' AFTER `wx_config`;
  220. -- 1.0.6版本
  221. -- 加大选项图片字段长度
  222. ALTER TABLE `__PREFIX__exam_question` CHANGE COLUMN `options_img` `options_img` VARCHAR(1000) NULL DEFAULT NULL COMMENT '选项图片' COLLATE 'utf8mb4_unicode_ci' AFTER `options_json`;
  223. -- 1.0.9版本
  224. -- 题库新增图标
  225. -- ALTER TABLE `__PREFIX__exam_cate` ADD COLUMN `icon` VARCHAR(200) NULL DEFAULT '' COMMENT '图标' AFTER `name`;
  226. -- 用户信息
  227. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_user_info` (
  228. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  229. `type` ENUM('NORMAL','VIP_MONTH','VIP_YEAR','VIP_LIFE') NOT NULL DEFAULT 'NORMAL' COMMENT '用户类型:NORMAL=普通用户,VIP_MONTH=月卡会员,VIP_YEAR=年卡会员,VIP_LIFE=终身会员' COLLATE 'utf8mb4_unicode_ci',
  230. `member_config_id` INT(10) NOT NULL COMMENT '开通会员类型',
  231. `user_id` INT(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
  232. `score` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '积分',
  233. `score_inc` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '累计获得积分',
  234. `score_dec` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '累计支出积分',
  235. `expire_time` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '过期时间',
  236. `createtime` BIGINT(16) NULL DEFAULT NULL COMMENT '创建时间',
  237. `updatetime` BIGINT(16) NULL DEFAULT NULL COMMENT '修改时间',
  238. PRIMARY KEY (`id`) USING BTREE,
  239. INDEX `user_id` (`user_id`) USING BTREE,
  240. INDEX `type` (`type`) USING BTREE,
  241. INDEX `member_config_id` (`member_config_id`, `expire_time`) USING BTREE
  242. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户信息';
  243. -- 1.0.11
  244. -- 试卷加开始、过期时间,仅用于考场字段
  245. ALTER TABLE `__PREFIX__exam_paper` ADD COLUMN `end_time` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '过期时间' AFTER `member_price`;
  246. ALTER TABLE `__PREFIX__exam_paper`
  247. ADD COLUMN `start_time` BIGINT(16) NOT NULL DEFAULT '0' COMMENT '开始时间' AFTER `member_price`,
  248. ADD COLUMN `is_only_room` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '仅用于考场' AFTER `end_time`,
  249. ADD INDEX `is_only_room` (`is_only_room`),
  250. ADD INDEX `start_time` (`start_time`);
  251. -- 试题新增【填空题】类型
  252. ALTER TABLE `__PREFIX__exam_question` ADD COLUMN `options_extend` VARCHAR(1000) NULL DEFAULT NULL COMMENT '选项扩展' COLLATE 'utf8mb4_unicode_ci' AFTER `options_img`;
  253. ALTER TABLE `__PREFIX__exam_question` CHANGE COLUMN `kind` `kind` ENUM('JUDGE','SINGLE','MULTI','FILL') NOT NULL DEFAULT 'JUDGE' COMMENT '试题类型' COLLATE 'utf8mb4_unicode_ci';
  254. ALTER TABLE `__PREFIX__exam_question` CHANGE COLUMN `answer` `answer` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '正确答案' COLLATE 'utf8mb4_unicode_ci';
  255. -- 1.0.12
  256. -- 考卷成绩新增答题信息
  257. ALTER TABLE `__PREFIX__exam_grade`
  258. ADD COLUMN `question_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '试卷ID集合' COLLATE 'utf8mb4_unicode_ci' AFTER `date`,
  259. ADD COLUMN `error_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '错题ID集合' COLLATE 'utf8mb4_unicode_ci' AFTER `question_ids`,
  260. ADD COLUMN `user_answers` TEXT NULL DEFAULT NULL COMMENT '用户答案集合' COLLATE 'utf8mb4_unicode_ci' AFTER `error_ids`;
  261. -- 考场成绩新增答题信息
  262. ALTER TABLE `__PREFIX__exam_room_grade`
  263. ADD COLUMN `question_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '试卷ID集合' COLLATE 'utf8mb4_unicode_ci' AFTER `grade_time`,
  264. ADD COLUMN `error_ids` VARCHAR(2000) NULL DEFAULT '' COMMENT '错题ID集合' COLLATE 'utf8mb4_unicode_ci' AFTER `question_ids`,
  265. ADD COLUMN `user_answers` TEXT NULL DEFAULT NULL COMMENT '用户答案集合' COLLATE 'utf8mb4_unicode_ci' AFTER `error_ids`;
  266. -- 1.0.13
  267. -- 考卷成绩新增考卷选题配置
  268. ALTER TABLE `__PREFIX__exam_grade`
  269. ADD COLUMN `configs` VARCHAR(1000) NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci' AFTER `user_answers`;
  270. -- 考场成绩新增考卷选题配置
  271. ALTER TABLE `__PREFIX__exam_room_grade`
  272. ADD COLUMN `configs` VARCHAR(1000) NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci' AFTER `user_answers`;
  273. -- 1.1.0
  274. -- 错题新增用户答案
  275. ALTER TABLE `__PREFIX__exam_question_wrong`
  276. ADD COLUMN `user_answer` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '用户答案' COLLATE 'utf8mb4_unicode_ci' AFTER `question_id`;
  277. ALTER TABLE `__PREFIX__exam_grade`
  278. ADD COLUMN `mode` ENUM('RANDOM','FIX') NOT NULL DEFAULT 'RANDOM' COMMENT '选题模式' COLLATE 'utf8mb4_unicode_ci' AFTER `paper_id`;
  279. ALTER TABLE `__PREFIX__exam_room_grade`
  280. ADD COLUMN `mode` ENUM('RANDOM','FIX') NOT NULL DEFAULT 'RANDOM' COMMENT '选题模式' COLLATE 'utf8mb4_unicode_ci' AFTER `paper_id`;
  281. -- 1.2.1
  282. -- 新增公告前端跳转信息
  283. ALTER TABLE `__PREFIX__exam_notice`
  284. ADD COLUMN `front_info` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '前端跳转信息' AFTER `status`;
  285. -- 1.3.0
  286. -- 新增试题类型【简答题】、【材料题】
  287. ALTER TABLE `__PREFIX__exam_question`
  288. CHANGE COLUMN `kind` `kind` ENUM('JUDGE','SINGLE','MULTI','FILL','SHORT','MATERIAL') NOT NULL DEFAULT 'JUDGE' COMMENT '试题类型' COLLATE 'utf8mb4_unicode_ci' AFTER `cate_id`;
  289. ALTER TABLE `__PREFIX__exam_question`
  290. CHANGE COLUMN `title` `title` VARCHAR(2000) NOT NULL COMMENT '题目' COLLATE 'utf8mb4_unicode_ci' AFTER `kind`;
  291. ALTER TABLE `__PREFIX__exam_question`
  292. CHANGE COLUMN `answer` `answer` TEXT NOT NULL COMMENT '正确答案' COLLATE 'utf8mb4_unicode_ci' AFTER `options_extend`;
  293. ALTER TABLE `__PREFIX__exam_question`
  294. CHANGE COLUMN `options_extend` `options_extend` TEXT NULL COMMENT '选项扩展' COLLATE 'utf8mb4_unicode_ci' AFTER `options_img`;
  295. -- 试卷标题、配置字段扩展长度
  296. ALTER TABLE `__PREFIX__exam_paper`
  297. CHANGE COLUMN `title` `title` VARCHAR(3000) NOT NULL COMMENT '试卷名称' COLLATE 'utf8mb4_unicode_ci' AFTER `mode`,
  298. CHANGE COLUMN `configs` `configs` VARCHAR(3000) NOT NULL COMMENT '选题配置' COLLATE 'utf8mb4_unicode_ci' AFTER `title`;
  299. -- 试卷固定选题新增试题答案
  300. ALTER TABLE `__PREFIX__exam_paper_question`
  301. ADD COLUMN `answer_config` TEXT NULL COMMENT '正确答案配置' COLLATE 'utf8mb4_unicode_ci' AFTER `sort`;
  302. -- 考试成绩新增系统得分、人工判分
  303. ALTER TABLE `__PREFIX__exam_grade`
  304. ADD COLUMN `system_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '系统得分' AFTER `score`,
  305. ADD COLUMN `manual_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '人工判分' AFTER `system_score`;
  306. -- 考场成绩新增系统得分、人工判分
  307. ALTER TABLE `__PREFIX__exam_room_grade`
  308. ADD COLUMN `system_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '系统得分' AFTER `score`,
  309. ADD COLUMN `manual_score` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '人工判分' AFTER `system_score`;
  310. -- 错题记录新增来源
  311. ALTER TABLE `__PREFIX__exam_question_wrong`
  312. ADD COLUMN `kind` ENUM('PAPER','ROOM','TRAINING') NULL DEFAULT 'PAPER' COMMENT '来源:PAPER=试卷,ROOM=考场,TRAINING=练题' AFTER `user_answer`,
  313. DROP INDEX `user_id`,
  314. ADD INDEX `user_id` (`user_id`, `kind`) USING BTREE;
  315. -- 新增材料题关联表
  316. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_material_question` (
  317. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  318. `parent_question_id` INT(11) UNSIGNED NOT NULL COMMENT '材料题主题目',
  319. `question_id` INT(11) UNSIGNED NOT NULL COMMENT '材料题子题目',
  320. `score` INT(11) UNSIGNED NOT NULL COMMENT '分数',
  321. `weigh` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '排序',
  322. `answer` TEXT NULL DEFAULT NULL COMMENT '正确答案配置' COLLATE 'utf8mb4_unicode_ci',
  323. `createtime` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
  324. `updatetime` BIGINT(16) UNSIGNED NULL DEFAULT NULL COMMENT '修改时间',
  325. PRIMARY KEY (`id`) USING BTREE,
  326. UNIQUE INDEX `from_question_id` (`parent_question_id`, `question_id`) USING BTREE
  327. ) COMMENT='材料题关联表'
  328. COLLATE='utf8mb4_unicode_ci'
  329. ENGINE=InnoDB
  330. ROW_FORMAT=DYNAMIC;
  331. -- 试卷成绩手动判题记录表
  332. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_manual_grade_log` (
  333. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  334. `admin_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '操作管理员',
  335. `user_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '考试用户',
  336. `paper_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '试卷ID',
  337. `grade_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '考试成绩ID',
  338. `question_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '试题ID',
  339. `before_score` INT(11) UNSIGNED NOT NULL COMMENT '修改前分数',
  340. `after_score` INT(11) UNSIGNED NOT NULL COMMENT '修改后分数',
  341. `status` ENUM('0','1') NOT NULL DEFAULT '0' COMMENT '状态:0=未生效,1=已生效' COLLATE 'utf8mb4_unicode_ci',
  342. `createtime` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
  343. `updatetime` BIGINT(16) UNSIGNED NULL DEFAULT NULL COMMENT '修改时间',
  344. PRIMARY KEY (`id`) USING BTREE,
  345. INDEX `admin_id` (`admin_id`) USING BTREE,
  346. INDEX `user_id` (`user_id`) USING BTREE,
  347. INDEX `status` (`status`) USING BTREE,
  348. INDEX `grade_id` (`grade_id`, `status`) USING BTREE,
  349. INDEX `paper_id` (`paper_id`, `status`) USING BTREE,
  350. INDEX `question_id` (`question_id`) USING BTREE
  351. ) COMMENT='试卷成绩手动判题记录表'
  352. COLLATE='utf8mb4_unicode_ci'
  353. ENGINE=InnoDB
  354. ROW_FORMAT=DYNAMIC
  355. ;
  356. -- 考场成绩手动判题记录表
  357. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_manual_room_grade_log` (
  358. `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  359. `admin_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '操作管理员',
  360. `user_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '考试用户',
  361. `paper_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '试卷ID',
  362. `room_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '考场ID',
  363. `grade_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '考试成绩ID',
  364. `question_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '试题ID',
  365. `before_score` INT(11) UNSIGNED NOT NULL COMMENT '修改前分数',
  366. `after_score` INT(11) UNSIGNED NOT NULL COMMENT '修改后分数',
  367. `status` ENUM('0','1') NOT NULL DEFAULT '0' COMMENT '状态:0=未生效,1=已生效' COLLATE 'utf8mb4_unicode_ci',
  368. `createtime` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
  369. `updatetime` BIGINT(16) UNSIGNED NULL DEFAULT NULL COMMENT '修改时间',
  370. PRIMARY KEY (`id`) USING BTREE,
  371. INDEX `admin_id` (`admin_id`) USING BTREE,
  372. INDEX `user_id` (`user_id`) USING BTREE,
  373. INDEX `status` (`status`) USING BTREE,
  374. INDEX `grade_id` (`grade_id`, `status`) USING BTREE,
  375. INDEX `paper_id` (`paper_id`, `status`) USING BTREE,
  376. INDEX `question_id` (`question_id`) USING BTREE,
  377. INDEX `room_id` (`room_id`) USING BTREE
  378. ) COMMENT='考场成绩手动判题记录表'
  379. COLLATE='utf8mb4_unicode_ci'
  380. ENGINE=InnoDB
  381. ROW_FORMAT=DYNAMIC
  382. ;
  383. -- 1.4.0
  384. -- 成绩记录表扩展配置长度
  385. ALTER TABLE `__PREFIX__exam_grade`
  386. CHANGE COLUMN `configs` `configs` TEXT NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci' AFTER `user_answers`;
  387. ALTER TABLE `__PREFIX__exam_room_grade`
  388. CHANGE COLUMN `configs` `configs` TEXT NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci' AFTER `user_answers`;
  389. -- 材料题关联表新增分数字段
  390. ALTER TABLE `__PREFIX__exam_material_question`
  391. ADD COLUMN `score` INT(11) UNSIGNED NOT NULL COMMENT '分数' AFTER `question_id`,
  392. ADD COLUMN `weigh` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '排序' AFTER `score`,
  393. ADD COLUMN `answer` TEXT NULL DEFAULT NULL COMMENT '正确答案配置' COLLATE 'utf8mb4_unicode_ci' AFTER `weigh`;
  394. -- 题目新增材料题子题字段
  395. ALTER TABLE `__PREFIX__exam_question`
  396. ADD COLUMN `is_material_child` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '属于材料题子题:0=否,1=是' AFTER `status`,
  397. DROP INDEX `kind`,
  398. ADD INDEX `kind` (`kind`, `status`, `is_material_child`) USING BTREE,
  399. DROP INDEX `cate_id`,
  400. ADD INDEX `cate_id` (`cate_id`, `kind`, `status`, `is_material_child`) USING BTREE,
  401. ADD INDEX `is_material_child` (`is_material_child`),
  402. ADD COLUMN `material_question_id` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '所属材料题' AFTER `is_material_child`,
  403. ADD INDEX `material_question_id` (`material_question_id`),
  404. ADD COLUMN `material_score` BIGINT(16) UNSIGNED NOT NULL DEFAULT '0' COMMENT '材料子题分数' AFTER `material_question_id`;
  405. -- 1.4.5
  406. -- 试题新增题目视频字段
  407. ALTER TABLE `__PREFIX__exam_question`
  408. ADD COLUMN `title_video` VARCHAR(200) NULL COMMENT '题目视频' AFTER `title`,
  409. ADD COLUMN `explain_video` VARCHAR(200) NULL COMMENT '解析视频' AFTER `explain`;
  410. -- 错题记录用户答案字段扩展长度(某些旧版本没有更新表结构)
  411. ALTER TABLE `__PREFIX__exam_question_wrong`
  412. CHANGE COLUMN `user_answer` `user_answer` TEXT NOT NULL COMMENT '用户答案' COLLATE 'utf8mb4_unicode_ci' AFTER `cate_id`;
  413. ALTER TABLE `__PREFIX__exam_room_grade`
  414. CHANGE COLUMN `configs` `configs` TEXT NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci' AFTER `user_answers`,
  415. CHANGE COLUMN `user_answers` `user_answers` TEXT NULL COMMENT '用户答案集合' COLLATE 'utf8mb4_unicode_ci' AFTER `error_ids`;
  416. ALTER TABLE `__PREFIX__exam_grade`
  417. CHANGE COLUMN `configs` `configs` TEXT NULL COMMENT '试卷选题配置' COLLATE 'utf8mb4_unicode_ci' AFTER `user_answers`,
  418. CHANGE COLUMN `user_answers` `user_answers` TEXT NULL COMMENT '用户答案集合' COLLATE 'utf8mb4_unicode_ci' AFTER `error_ids`;
  419. -- 1.5.2
  420. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_correction_type` (
  421. `id` INT(11) NOT NULL AUTO_INCREMENT,
  422. `name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '类型名称' COLLATE 'utf8_general_ci',
  423. `createtime` BIGINT(20) NULL DEFAULT NULL COMMENT '创建时间',
  424. `updatetime` BIGINT(20) NULL DEFAULT NULL COMMENT '修改时间',
  425. PRIMARY KEY (`id`) USING BTREE
  426. ) COMMENT='纠错反馈类型' COLLATE='utf8_general_ci' ENGINE=InnoDB;
  427. CREATE TABLE IF NOT EXISTS `__PREFIX__exam_correction_question` (
  428. `id` INT(11) NOT NULL AUTO_INCREMENT,
  429. `user_id` INT(11) NOT NULL DEFAULT '0' COMMENT '反馈人',
  430. `question_id` INT(11) NOT NULL DEFAULT '0' COMMENT '反馈题目',
  431. `type_ids` INT(11) NOT NULL DEFAULT '0' COMMENT '纠错类型',
  432. `type_names` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '类型名称' COLLATE 'utf8_general_ci',
  433. `remark` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '其他说明' COLLATE 'utf8_general_ci',
  434. `status` ENUM('0','1','2') NOT NULL DEFAULT '0' COMMENT '状态:0=未处理,1=已处理,2=忽略' COLLATE 'utf8_general_ci',
  435. `message` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '处理说明' COLLATE 'utf8_general_ci',
  436. `createtime` BIGINT(20) NULL DEFAULT NULL COMMENT '创建时间',
  437. `updatetime` BIGINT(20) NULL DEFAULT NULL COMMENT '修改时间',
  438. PRIMARY KEY (`id`) USING BTREE,
  439. INDEX `question_id` (`question_id`) USING BTREE,
  440. INDEX `user_id` (`user_id`) USING BTREE
  441. ) COMMENT='纠错反馈试题' COLLATE='utf8_general_ci' ENGINE=InnoDB;
  442. ALTER TABLE `__PREFIX__exam_cate`
  443. ADD COLUMN `status` ENUM('0','1') NOT NULL DEFAULT '1' COMMENT '状态:0=禁用,1=启用' COLLATE 'utf8_general_ci';
  444. -- 1.5.8
  445. ALTER TABLE `__PREFIX__exam_paper`
  446. CHANGE COLUMN `quantity` `quantity` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '题目数量' AFTER `configs`;