export type ExamStatus = "draft" | "published" | "archived"

export type ExamDifficulty = 1 | 2 | 3 | 4 | 5

export interface Exam {
  id: string
  title: string
  subject: string
  subjectId: string | null
  grade: string
  status: ExamStatus
  difficulty: ExamDifficulty
  totalScore: number
  durationMin: number
  questionCount: number
  scheduledAt?: string
  createdAt: string
  updatedAt?: string
  tags?: string[]
}

export type SubmissionStatus = "pending" | "graded"

export interface ExamSubmission {
  id: string
  examId: string
  examTitle: string
  studentName: string
  submittedAt: string
  score?: number
  status: SubmissionStatus
}

/**
 * 年级仪表盘 - 维度3：年级下考试列表项（含提交统计）。
 */
export interface GradeExamItem {
  id: string
  title: string
  status: ExamStatus
  subjectId: string | null
  subjectName: string | null
  scheduledAt: string | null
  createdAt: string
  /** 提交记录总数（started + submitted + graded） */
  submissionCount: number
  /** 已评分提交数 */
  gradedCount: number
  /** 已评分提交的平均分 */
  averageScore: number | null
}

export interface GradeExamsResult {
  gradeId: string
  exams: GradeExamItem[]
  totals: {
    examCount: number
    publishedCount: number
    draftCount: number
    archivedCount: number
    totalSubmissions: number
    totalGraded: number
  }
}

// --- 成绩录入用的试卷类型 ---

/** 试卷题目项（用于录入表格表头） */
export interface ExamQuestionItem {
  id: string
  order: number
  score: number
  type: string
}

/** 试卷信息（用于录入，含题目列表） */
export interface ExamForGradeEntry {
  id: string
  title: string
  subjectId: string | null
  gradeId: string | null
  totalScore: number
  questions: ExamQuestionItem[]
}

/** 试卷列表项（用于选择器） */
export interface ExamOptionForEntry {
  id: string
  title: string
  subjectName: string
  gradeName: string
  questionCount: number
  totalScore: number
}

