export interface ExamSession {
  exam_id: number;
  title: string;
  sections: ExamSessionSection[];
  results_release_mode: "auto" | "manual_approval";
  total_time_min: number;
}

export interface ExamSessionSection {
  id: number;
  title: string;
  skill: string;
  difficulty?: string;
  time_limit_sec: number;
  time_limit_min?: number;
  total_marks?: number;
  scoring_method?: string;
  sequence?: number;
  passage_text?: string;
  instructions_text?: string;
  questions: ExamQuestion[];
}

export type ExamOptionItem = { label: string; text: string } | string;

export interface ExamQuestion {
  id: number;
  type: string;
  question_type?: string;
  stem: string;
  options?: ExamOptionItem[];
  passage_text?: string;
  audio_url?: string;
  audio_base64?: string;
  visual_url?: string;
  min_words?: number;
  marks: number;
  difficulty?: string;
  source_type?: string;
}

export interface ExamAnswer {
  question_id: number;
  answer: string | string[] | null;
  flagged: boolean;
  time_spent_ms: number;
}

export interface ExamAutoSave {
  attempt_id?: number;
  section_id: number;
  answers: ExamAnswer[];
}

export interface SubmissionSummary {
  total_questions: number;
  answered: number;
  unanswered: number;
  flagged: number;
  sections: {
    id: number;
    title: string;
    answered: number;
    total: number;
    flagged: number;
  }[];
}

export interface ExamSubmitResponse {
  attempt_id: number;
  status: "submitted" | "scoring" | "scored";
  results_available: boolean;
}
