backend_adaptive_learning/models/learningModels/stdExerciseModel.js
2024-11-06 13:05:04 +07:00

76 lines
1.6 KiB
JavaScript

import db from "../../database/db.js";
const StdExerciseModel = (DataTypes) => {
const StdExercise = db.define(
"student_exercise",
{
ID_STUDENT_EXERCISE: {
type: DataTypes.UUID,
primaryKey: true,
defaultValue: DataTypes.UUIDV4,
allowNull: false,
validate: {
notEmpty: true,
},
},
ID_ADMIN_EXERCISE: {
type: DataTypes.UUID,
allowNull: false,
validate: {
notEmpty: true,
},
references: {
model: "admin_exercise",
key: "ID_ADMIN_EXERCISE",
},
},
ID_STUDENT_LEARNING: {
type: DataTypes.UUID,
allowNull: false,
validate: {
notEmpty: true,
},
references: {
model: "student_learning",
key: "ID_STUDENT_LEARNING",
},
},
ANSWER_STUDENT: {
type: DataTypes.TEXT,
allowNull: false,
validate: {
notEmpty: true,
},
},
IS_CORRECT: {
type: DataTypes.TINYINT(1),
allowNull: false,
defaultValue: 0,
validate: {
min: 0,
max: 1,
},
},
RESULT_SCORE_STUDENT: {
type: DataTypes.FLOAT,
allowNull: true,
defaultValue: null,
},
TIME_STUDENT_EXC: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: DataTypes.NOW,
onUpdate: DataTypes.NOW,
},
},
{
timestamps: false,
tableName: "student_exercise",
}
);
return StdExercise;
};
export default StdExerciseModel;