// Learning Diagnostic Module Types

export type DiagnosticReportType = "individual" | "class" | "grade"
export type DiagnosticReportStatus = "draft" | "published" | "archived"

/** 知识点掌握度记录 */
export interface KnowledgePointMastery {
  id: string
  studentId: string
  knowledgePointId: string
  masteryLevel: number // 0-100
  totalQuestions: number
  correctQuestions: number
  lastAssessedAt: string
  createdAt: string
  updatedAt: string
}

/** 含知识点名称的掌握度（join knowledgePoints 后） */
export interface MasteryWithKnowledgePoint extends KnowledgePointMastery {
  knowledgePointName: string
  knowledgePointDescription: string | null
}

/** 学生掌握度摘要 */
export interface StudentMasterySummary {
  studentId: string
  studentName: string
  averageMastery: number
  totalKnowledgePoints: number
  strengths: MasteryWithKnowledgePoint[] // 掌握度 >= 80
  weaknesses: MasteryWithKnowledgePoint[] // 掌握度 < 60
  allMastery: MasteryWithKnowledgePoint[]
}

/** 诊断报告 */
export interface DiagnosticReport {
  id: string
  studentId: string | null
  generatedBy: string | null
  reportType: DiagnosticReportType
  period: string | null
  summary: string | null
  strengths: string[] | null
  weaknesses: string[] | null
  recommendations: string[] | null
  overallScore: number | null
  status: DiagnosticReportStatus
  createdAt: string
  updatedAt: string
}

/** 含学生名的诊断报告（join users 后） */
export interface DiagnosticReportWithDetails extends DiagnosticReport {
  studentName: string | null
  generatedByName: string | null
}

/** 班级掌握度摘要 */
export interface ClassMasterySummary {
  classId: string
  className: string
  studentCount: number
  averageMastery: number
  knowledgePointStats: KnowledgePointStat[]
  studentsNeedingAttention: Array<{
    studentId: string
    studentName: string
    averageMastery: number
    weakCount: number
  }>
}

/** 知识点统计 */
export interface KnowledgePointStat {
  knowledgePointId: string
  knowledgePointName: string
  averageMastery: number
  masteredCount: number // 掌握度 >= 80
  notMasteredCount: number // 掌握度 < 60
  totalStudents: number
}

/** 报告查询过滤参数 */
export interface DiagnosticReportQueryParams {
  studentId?: string
  reportType?: DiagnosticReportType
  status?: DiagnosticReportStatus
  period?: string
}

/** 雷达图数据点 */
export interface MasteryRadarPoint {
  knowledgePoint: string
  student: number // 0-100
  classAverage?: number // 0-100
}
