-- 创建课程考试设置表
CREATE TABLE IF NOT EXISTS course_exam_settings (
    id INT AUTO_INCREMENT PRIMARY KEY,
    course_id INT NOT NULL UNIQUE COMMENT '课程ID',
    single_choice_count INT NOT NULL DEFAULT 10 COMMENT '单选题数量',
    multiple_choice_count INT NOT NULL DEFAULT 5 COMMENT '多选题数量',
    true_false_count INT NOT NULL DEFAULT 5 COMMENT '判断题数量',
    fill_blank_count INT NOT NULL DEFAULT 0 COMMENT '填空题数量',
    duration_minutes INT NOT NULL DEFAULT 60 COMMENT '考试时长(分钟)',
    difficulty_level INT NOT NULL DEFAULT 3 COMMENT '难度系数(1-5)',
    passing_score INT NOT NULL DEFAULT 60 COMMENT '及格分数',
    is_enabled BOOLEAN NOT NULL DEFAULT TRUE COMMENT '是否启用',
    show_answer_immediately BOOLEAN NOT NULL DEFAULT FALSE COMMENT '是否立即显示答案',
    allow_retake BOOLEAN NOT NULL DEFAULT TRUE COMMENT '是否允许重考',
    max_retake_times INT COMMENT '最大重考次数',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    created_by INT COMMENT '创建人ID',
    updated_by INT COMMENT '更新人ID',
    is_deleted BOOLEAN NOT NULL DEFAULT FALSE,
    deleted_at DATETIME,
    deleted_by INT COMMENT '删除人ID',
    FOREIGN KEY (course_id) REFERENCES courses(id),
    INDEX ix_course_exam_settings_id (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='课程考试设置表';

-- 插入示例课程考试设置
INSERT INTO course_exam_settings (course_id, single_choice_count, multiple_choice_count, true_false_count, duration_minutes)
VALUES 
(1, 15, 8, 5, 60),
(2, 20, 10, 10, 90),
(3, 10, 5, 5, 45),
(4, 12, 6, 8, 60);

SELECT 'Course exam settings table created successfully!' as message;
