// Mock data for CĐ Công Thương LMS

const PROGRAM = {
  id: 'cntt-k47',
  name: 'Công nghệ thông tin',
  code: 'CNTT-K47',
  term: 'Học kỳ 4 · 2025-2026',
  totalCredits: 32,
  earnedCredits: 18,
  requiredPassed: 4,
  requiredTotal: 6,
};

const STUDENT = {
  name: 'Nguyễn Minh Quân',
  id: '2251120143',
  class: 'CNTT-K47A',
  avatar: 'MQ',
  gpa: 3.42,
};

// Cây lộ trình học — có môn tiên quyết, bắt buộc, tự chọn
const CURRICULUM = [
  // Semester 1
  { id: 's1', title: 'Nhập môn Lập trình', code: 'IT101', credits: 3, required: true, status: 'done', grade: 8.5, semester: 1, col: 0, prereq: [] },
  { id: 's2', title: 'Toán rời rạc', code: 'MA102', credits: 3, required: true, status: 'done', grade: 7.8, semester: 1, col: 1, prereq: [] },
  { id: 's3', title: 'Tiếng Anh chuyên ngành 1', code: 'EN101', credits: 2, required: true, status: 'done', grade: 8.0, semester: 1, col: 2, prereq: [] },

  // Semester 2
  { id: 's4', title: 'Cấu trúc dữ liệu', code: 'IT201', credits: 4, required: true, status: 'done', grade: 8.2, semester: 2, col: 0, prereq: ['s1'] },
  { id: 's5', title: 'Cơ sở dữ liệu', code: 'IT202', credits: 3, required: true, status: 'active', progress: 64, semester: 2, col: 1, prereq: ['s1'] },
  { id: 's6', title: 'Kiến trúc máy tính', code: 'IT203', credits: 3, required: false, status: 'available', semester: 2, col: 2, prereq: ['s2'] },

  // Semester 3 (current)
  { id: 's7', title: 'Lập trình hướng đối tượng', code: 'IT301', credits: 4, required: true, status: 'active', progress: 28, semester: 3, col: 0, prereq: ['s4'] },
  { id: 's8', title: 'Phát triển Web', code: 'IT302', credits: 3, required: false, status: 'available', semester: 3, col: 1, prereq: ['s5'] },
  { id: 's9', title: 'Mạng máy tính', code: 'IT303', credits: 3, required: true, status: 'available', semester: 3, col: 2, prereq: ['s6'] },

  // Semester 4
  { id: 's10', title: 'Công nghệ phần mềm', code: 'IT401', credits: 3, required: true, status: 'locked', semester: 4, col: 0, prereq: ['s7'] },
  { id: 's11', title: 'Trí tuệ nhân tạo', code: 'IT402', credits: 3, required: false, status: 'locked', semester: 4, col: 1, prereq: ['s7', 's8'] },
  { id: 's12', title: 'An toàn thông tin', code: 'IT403', credits: 3, required: false, status: 'locked', semester: 4, col: 2, prereq: ['s9'] },
];

// Active subject detail (Cơ sở dữ liệu)
const ACTIVE_SUBJECT = {
  id: 's5',
  title: 'Cơ sở dữ liệu',
  code: 'IT202',
  credits: 3,
  instructor: 'TS. Lê Thu Hằng',
  description: 'Môn học cung cấp kiến thức nền tảng về hệ quản trị cơ sở dữ liệu quan hệ, ngôn ngữ SQL, thiết kế chuẩn hoá và các vấn đề giao tác, phục hồi.',
  progress: 64,
  chapters: [
    { id: 'c1', title: 'Tổng quan về cơ sở dữ liệu', lessons: 4, duration: '1h 20m', done: 4 },
    { id: 'c2', title: 'Mô hình dữ liệu quan hệ', lessons: 5, duration: '1h 50m', done: 5 },
    { id: 'c3', title: 'Ngôn ngữ SQL cơ bản', lessons: 6, duration: '2h 30m', done: 4, current: true },
    { id: 'c4', title: 'Thiết kế và chuẩn hoá', lessons: 5, duration: '2h 10m', done: 0 },
    { id: 'c5', title: 'Giao tác và phục hồi', lessons: 4, duration: '1h 40m', done: 0 },
  ],
  exam: { questions: 40, duration: 60, passScore: 5.0, attempts: 2, attemptsUsed: 0 }
};

const LESSONS = [
  { id: 'l1', title: 'Câu lệnh SELECT cơ bản', duration: '12:30', done: true },
  { id: 'l2', title: 'Mệnh đề WHERE và toán tử', duration: '15:20', done: true },
  { id: 'l3', title: 'GROUP BY và HAVING', duration: '18:45', done: true },
  { id: 'l4', title: 'JOIN nhiều bảng', duration: '22:10', done: true, current: true },
  { id: 'l5', title: 'Truy vấn lồng (subquery)', duration: '16:50', done: false },
  { id: 'l6', title: 'View và Index', duration: '14:30', done: false },
];

// In-video quiz
const VIDEO_QUIZ = {
  question: 'Trong SQL, khi bạn muốn kết hợp hai bảng và chỉ giữ những bản ghi có giá trị khớp ở cả hai bảng, bạn dùng loại JOIN nào?',
  options: [
    { id: 'a', text: 'LEFT JOIN' },
    { id: 'b', text: 'INNER JOIN', correct: true },
    { id: 'c', text: 'OUTER JOIN' },
    { id: 'd', text: 'CROSS JOIN' },
  ],
  explanation: 'INNER JOIN chỉ trả về các bản ghi có giá trị khoá khớp ở cả hai bảng. LEFT JOIN sẽ giữ lại toàn bộ bản ghi của bảng bên trái.'
};

// Exam questions
const EXAM_QUESTIONS = [
  {
    q: 'Trong mô hình quan hệ, khái niệm "khoá chính" (Primary Key) có đặc điểm nào sau đây?',
    opts: ['Có thể nhận giá trị NULL', 'Phải duy nhất và không NULL', 'Có thể trùng với khoá ngoại', 'Chỉ áp dụng cho trường kiểu số'],
  },
  {
    q: 'Câu lệnh SQL nào dùng để xoá toàn bộ bản ghi trong bảng nhưng giữ lại cấu trúc bảng?',
    opts: ['DROP TABLE', 'DELETE FROM', 'TRUNCATE TABLE', 'REMOVE TABLE'],
  },
  {
    q: 'Chuẩn hoá cơ sở dữ liệu ở dạng chuẩn 2 (2NF) yêu cầu điều gì?',
    opts: ['Loại bỏ nhóm lặp', 'Các thuộc tính không khoá phụ thuộc đầy đủ vào khoá chính', 'Không có phụ thuộc bắc cầu', 'Chỉ có duy nhất một khoá chính'],
  },
  {
    q: 'Giao tác (transaction) trong CSDL có 4 tính chất ACID. Chữ "C" viết tắt cho?',
    opts: ['Coherence', 'Concurrency', 'Consistency', 'Completeness'],
  },
  {
    q: 'Kết quả của câu truy vấn sau là gì: SELECT COUNT(*) FROM SinhVien WHERE Diem > 8?',
    opts: ['Tổng điểm các sinh viên có điểm > 8', 'Số sinh viên có điểm lớn hơn 8', 'Danh sách sinh viên có điểm > 8', 'Điểm cao nhất trong lớp'],
  },
];

// Question bank (teacher view)
const QUESTION_BANK = [
  { id: 'Q0142', topic: 'SQL cơ bản', diff: 'Dễ', type: 'Trắc nghiệm', used: 142, updated: '12/04/2026' },
  { id: 'Q0143', topic: 'JOIN', diff: 'Trung bình', type: 'Trắc nghiệm', used: 98, updated: '10/04/2026' },
  { id: 'Q0144', topic: 'Chuẩn hoá', diff: 'Khó', type: 'Trắc nghiệm', used: 76, updated: '08/04/2026' },
  { id: 'Q0145', topic: 'Transaction', diff: 'Khó', type: 'Trắc nghiệm', used: 54, updated: '06/04/2026' },
  { id: 'Q0146', topic: 'SQL cơ bản', diff: 'Dễ', type: 'Trắc nghiệm', used: 201, updated: '04/04/2026' },
  { id: 'Q0147', topic: 'View/Index', diff: 'Trung bình', type: 'Trắc nghiệm', used: 67, updated: '02/04/2026' },
  { id: 'Q0148', topic: 'Subquery', diff: 'Khó', type: 'Trắc nghiệm', used: 42, updated: '29/03/2026' },
];

// Admin stats
const ADMIN_STATS = {
  students: 3842,
  teachers: 128,
  programs: 14,
  subjects: 186,
  activeExams: 12,
  avgProgress: 68,
};

Object.assign(window, {
  PROGRAM, STUDENT, CURRICULUM, ACTIVE_SUBJECT, LESSONS, VIDEO_QUIZ, EXAM_QUESTIONS, QUESTION_BANK, ADMIN_STATS
});
