CREATE TABLE IF NOT EXISTS ai_training_evaluation (
  id varchar(64) NOT NULL,
  student_user_id varchar(64) NOT NULL,
  teaching_class_id varchar(64) NOT NULL,
  task_id varchar(64) NOT NULL,
  task_key varchar(128) NOT NULL,
  help_status varchar(16) NOT NULL DEFAULT 'NOT_STARTED',
  help_task_snapshot longtext NULL,
  help_answer_snapshot longtext NULL,
  help_report_json longtext NULL,
  help_raw_response longtext NULL,
  help_model varchar(128) NULL,
  help_completed_at datetime NULL,
  help_error_message varchar(1000) NULL,
  assessment_status varchar(16) NOT NULL DEFAULT 'NOT_STARTED',
  assessment_task_snapshot longtext NULL,
  assessment_answer_snapshot longtext NULL,
  assessment_score int NULL,
  assessment_report_json longtext NULL,
  assessment_raw_response longtext NULL,
  assessment_model varchar(128) NULL,
  assessment_completed_at datetime NULL,
  assessment_error_message varchar(1000) NULL,
  create_time datetime NOT NULL,
  update_time datetime NOT NULL,
  PRIMARY KEY (id),
  UNIQUE KEY uk_ai_training_evaluation (student_user_id, teaching_class_id, task_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE student_training_answer
  ADD COLUMN IF NOT EXISTS ai_assessment_score int NULL;
