const { DataTypes } = require("sequelize");
const sequelize = require("../db");

const TrainingModuleProgress = sequelize.define("TrainingModuleProgress", {
  status: {
    type: DataTypes.ENUM("not-started", "in-progress", "completed", "failed"),
    defaultValue: "not-started",
  },
  quizScore: {
    type: DataTypes.INTEGER,
    comment: "Quiz score percentage (0-100)",
  },
  quizAnswers: {
    type: DataTypes.JSON,
    comment: "User quiz answers",
  },
  completedAt: {
    type: DataTypes.DATE,
  },
  // UserId, TrainingModuleId, TrainingCourseEnrollmentId added via associations
}, {
  freezeTableName: true,
  tableName: 'TrainingModuleProgress'
});

module.exports = TrainingModuleProgress;
