Files
competition-website/app/model/choiceQuestion.js
WorkBuddy a303cf2d53 chore: 后端首次基线提交
运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。
已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
2026-08-17 12:25:42 +08:00

67 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict';
/**
* 选择题模型 - ChoiceQuestion
*
* 对应 choice_questions 表,存储所有组别的选择题(单选 + 多选)。
* 通过 group 字段区分中职组(zhongzhi)和高职组(gaozhi)。
*/
module.exports = app => {
const { STRING, INTEGER, DATE, JSON: JSON_TYPE, TEXT } = app.Sequelize;
return app.model.define('ChoiceQuestion', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '主键ID',
},
group: {
type: STRING(20),
allowNull: false,
comment: '组别:zhongzhi/gaozhi',
},
question: {
type: TEXT,
allowNull: false,
comment: '题目内容',
},
options: {
type: JSON_TYPE,
allowNull: false,
comment: '选项列表 [{ key: "A", text: "..." }, ...]',
},
answer: {
type: STRING(10),
allowNull: false,
comment: '正确答案(如 A / AB / ABCD)',
},
score: {
type: INTEGER,
allowNull: false,
defaultValue: 5,
comment: '分值',
},
sort_order: {
type: INTEGER,
allowNull: false,
defaultValue: 0,
comment: '排序',
},
created_at: {
type: DATE,
defaultValue: app.Sequelize.NOW,
comment: '创建时间',
},
updated_at: {
type: DATE,
defaultValue: app.Sequelize.NOW,
comment: '更新时间',
},
}, {
tableName: 'choice_questions',
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
});
};