You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.7 KiB
SQL
92 lines
3.7 KiB
SQL
-- Exam module schema. Execute explicitly as a database deployment step.
|
|
CREATE TABLE IF NOT EXISTS exam_question (
|
|
id bigint NOT NULL AUTO_INCREMENT,
|
|
school_id varchar(64) NOT NULL,
|
|
teacher_id varchar(64) NOT NULL,
|
|
question_type varchar(24) NOT NULL,
|
|
stem longtext NOT NULL,
|
|
options_json longtext NULL,
|
|
answer_json longtext NOT NULL,
|
|
answer_analysis longtext NULL,
|
|
attachment_name varchar(255) NULL,
|
|
attachment_url varchar(512) NULL,
|
|
create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
update_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (id),
|
|
KEY idx_exam_question_owner (teacher_id, question_type)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS exam_assessment (
|
|
id bigint NOT NULL AUTO_INCREMENT,
|
|
school_id varchar(64) NOT NULL,
|
|
teacher_id varchar(64) NOT NULL,
|
|
exam_name varchar(20) NOT NULL,
|
|
start_time datetime NOT NULL,
|
|
end_time datetime NOT NULL,
|
|
publication_status varchar(16) NOT NULL DEFAULT 'DRAFT',
|
|
allow_rollback bit NOT NULL DEFAULT 1,
|
|
exported_at datetime NULL,
|
|
create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
update_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uk_exam_school_name (school_id, exam_name),
|
|
KEY idx_exam_teacher (teacher_id, start_time)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS exam_assessment_class (
|
|
exam_id bigint NOT NULL,
|
|
teaching_class_id varchar(64) NOT NULL,
|
|
PRIMARY KEY (exam_id, teaching_class_id),
|
|
KEY idx_exam_class (teaching_class_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS exam_assessment_question (
|
|
exam_id bigint NOT NULL,
|
|
question_id bigint NOT NULL,
|
|
question_order int NOT NULL,
|
|
question_score decimal(7,2) NOT NULL,
|
|
question_type varchar(24) NOT NULL,
|
|
stem longtext NOT NULL,
|
|
options_json longtext NULL,
|
|
answer_json longtext NOT NULL,
|
|
answer_analysis longtext NULL,
|
|
attachment_name varchar(255) NULL,
|
|
attachment_url varchar(512) NULL,
|
|
create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
update_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (exam_id, question_id),
|
|
KEY idx_exam_question_order (exam_id, question_order)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS exam_attempt (
|
|
id bigint NOT NULL AUTO_INCREMENT,
|
|
exam_id bigint NOT NULL,
|
|
student_id varchar(64) NOT NULL,
|
|
teaching_class_id varchar(64) NOT NULL,
|
|
attempt_status varchar(16) NOT NULL DEFAULT 'IN_PROGRESS',
|
|
device_token varchar(128) NOT NULL,
|
|
started_at datetime NOT NULL,
|
|
submitted_at datetime NULL,
|
|
auto_submitted bit NOT NULL DEFAULT 0,
|
|
objective_score decimal(7,2) NOT NULL DEFAULT 0,
|
|
subjective_score decimal(7,2) NOT NULL DEFAULT 0,
|
|
total_score decimal(7,2) NOT NULL DEFAULT 0,
|
|
create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
update_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uk_exam_student (exam_id, student_id),
|
|
KEY idx_attempt_exam_status (exam_id, attempt_status)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS exam_attempt_answer (
|
|
attempt_id bigint NOT NULL,
|
|
question_id bigint NOT NULL,
|
|
answer_json longtext NULL,
|
|
answer_file_name varchar(255) NULL,
|
|
answer_file_url varchar(512) NULL,
|
|
is_correct bit NULL,
|
|
awarded_score decimal(7,2) NULL,
|
|
update_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (attempt_id, question_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|