// ═══════════════════════════════════════════════════════
// backend/models/training-enrollment.js — NEW FILE
// ═══════════════════════════════════════════════════════
const { DataTypes } = require("sequelize");
const sequelize = require("../db");

const TrainingEnrollment = sequelize.define("TrainingEnrollment", {
  status: {
    type: DataTypes.ENUM("not-started", "in-progress", "completed", "failed"),
    defaultValue: "not-started",
  },
  score:         { type: DataTypes.INTEGER },    // quiz score %
  completedAt:   { type: DataTypes.DATE },
  certificateId: { type: DataTypes.STRING },     // CERT-XXXXXXXX
  quizAnswers:   { type: DataTypes.JSON },       // user's answers array
  /** Last known watch progress 0–100 (HTML5 video timeupdate) */
  watchProgressPercent: {
    type: DataTypes.FLOAT,
    allowNull: false,
    defaultValue: 0,
  },
  // UserId and TrainingVideoId are added via associations in models/index.js
});

module.exports = TrainingEnrollment;
