mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
22 lines
1.2 KiB
JavaScript
22 lines
1.2 KiB
JavaScript
const { DataTypes } = require("sequelize");
|
|
const sequelize = require("../../config/db.config");
|
|
|
|
const AssessmentSession = sequelize.define("AssessmentSession", {
|
|
session_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
|
|
uuid: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, unique: true },
|
|
user_id: { type: DataTypes.BIGINT, allowNull: false },
|
|
assessment_id: { type: DataTypes.BIGINT, allowNull: false },
|
|
course_id: { type: DataTypes.BIGINT, allowNull: true },
|
|
started_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
|
expires_at: { type: DataTypes.DATE, allowNull: true }, // null = no time limit
|
|
status: { type: DataTypes.STRING(20), allowNull: false, defaultValue: 'in_progress' }, // 'in_progress' | 'completed' | 'expired'
|
|
attempt_id: { type: DataTypes.BIGINT, allowNull: true }, // FK → quiz_attempts once graded/expired
|
|
draft_answers: { type: DataTypes.JSONB, allowNull: true, defaultValue: null },
|
|
last_heartbeat_at: { type: DataTypes.DATE, allowNull: true, defaultValue: null },
|
|
}, {
|
|
tableName: "assessment_sessions",
|
|
timestamps: true,
|
|
});
|
|
|
|
module.exports = AssessmentSession;
|