/**
 * Types for the human-in-the-loop exam review workflow.
 *
 * Wire format mirrors `encoach_exam_template.controllers.review_workflow`.
 */

export interface ExamReviewSummary {
  question_count: number;
  avg_quality_score: number;
  min_quality_score: number;
  failing_count: number;
  ai_generated_count: number;
}

export interface ExamReviewListItem {
  id: number;
  title: string;
  status: "draft" | "pending_review" | "published" | "archived";
  subject_id: number | null;
  subject_name: string;
  entity_id: number | null;
  teacher_id: number | null;
  teacher_name: string;
  grading_system: string;
  total_time_min: number;
  total_marks: number;
  reviewed_by_id: number | null;
  reviewed_by_name: string;
  reviewed_at: string | null;
  review_notes: string;
  summary: ExamReviewSummary;
}

export interface ExamReviewQuestion {
  id: number;
  skill: string;
  question_type: string;
  difficulty: string;
  stem: string;
  marks: number;
  ai_generated: boolean;
  ielts_certified: boolean;
  format_validated: boolean;
  ai_model_used: string;
  ai_prompt_hash: string;
  quality_score: number;
  /**
   * Raw quality report from QualityChecker + IeltsValidator. Shape is loose on
   * purpose — the review UI renders it as pretty-printed JSON for operators.
   */
  quality_report: Record<string, unknown> | null;
}

export interface ExamReviewSection {
  id: number;
  title: string;
  skill: string;
  sequence: number;
  questions: ExamReviewQuestion[];
}

export interface ExamReviewDetail extends ExamReviewListItem {
  sections: ExamReviewSection[];
}
