import { EnumReviewMode, EnumSimulatedRecordStatus } from "@/common/enum";

export interface TeachClass {
  classId: number;
  schoolId: number;
  year: number;
  name: string;
}

export interface StudentStat {
  id: number;
  avatar?: string;
  name: string;
  questionNum: number;
  dateNum: number;
  rate: number;
}

export interface StudentExamRecord {
  id: number;
  name: string;
  score: number;
  status: number;
}

export interface StudentVideoRecord {
  id: number;
  name: string;
  date: string;
  duration: number;
}

export interface StudentVideoStat {
  id: number;
  avatar?: string;
  name: string;
  videoCount: number;
  duration: number;
}

/**
 * 学习计划
 */
export interface StudyPlan {
  id?: number;
  beginTime?: string;
  questionCnt: number;
  studentId?: number;
  videoTime: number;
  status?: number;
}

/**
 * 学习计划统计数据
 */
export interface StudyStats {
  questionCnt: number; // 答题数
  videoTime: number; // 课程学习数量
  videoTimes: number; // 学习时长
  rightRate: number; // 正确率
  questionPlan: number; // 计划答题数
  videoPlan: number; // 计划课程学习时长
}
export interface StudyStatsHistory {
  date: string; // 日期 2025-10-12
  data: StudyStats; // 数据
}
export interface StudyPlanStats {
  doneDay: number; // 本月完成
  undoneDay: number; // 本月未完成
  videoTimes: number; // 本月课程学习时长
  questionCnt: number; // 本月答题数
  studyList: StudyStatsHistory[]; // 历史数据（包含今天）
  today: StudyStats,
  plan: StudyPlan
}

export interface Subject {
  subjectId: number;
  subjectName: string;
}

export interface Knowledge {
  id: number;
  name: string;
  status: number;
  questionCount: number;
  children: Knowledge[];
  finishedCount: number;
  finishedRatio: number;
}

export type KnowledgeNode = Pick<Knowledge, 'id' | 'name' | 'status' | 'questionCount' | 'finishedCount' | 'finishedRatio'> & {
  isExpanded: boolean;
  isLeaf: boolean;
  actualHeight: number;
  children: KnowledgeNode[];
}

export interface QuestionState {
  isDone?: boolean;
  isMark?: boolean;
  isNotKnow?: boolean;
  isNotAnswer?: boolean;
  isFavorite?: boolean;
  isCorrect?: boolean;
  isLeaf?: boolean; // 是否是叶子节点
  progress?: number;
  //
  showParse?: boolean; // 是否显示解析
  hasParsed?: boolean; // 是否已经解析过，用于背题模式
}

/**
 * 开卷信息，包含上次做题历史数据
 */
export interface ExamineeQuestion {
  id: number;
  typeId: number;
  answer1: string;
  answer2: string;
  score: number;
  title?: string;
  options?: string[];
  isFavorite: boolean;
  isMark: boolean;
  isNotKnow: boolean;
  answers: string[];
  subQuestions: ExamineeQuestion[];
  parse?: string;
  totalScore: number;
}
export interface Examinee {
  examineeId: number;
  name: string;
  paperId: number;
  duration: number;
  knowledgeId: number;
  questions: ExamineeQuestion[];
  // 
  paperInfo: ExamineePaperInfo;
  collegeName: string;
  majorName: string;
  collegeId: number;
  majorId: number;
  subjectName: string;
  subjectId: number;
  totalCount: number;
  wrongCount: number;
  stats: ExamineeStats;
}
export interface ExamineePaperInfo {
  score: number;
  time: number;
  types: {
    type: string;
    count: number;
    score: number;
  }[]
}
export interface ExamineeStats {
  averageScore: number;
  hitRate: number;
  maxScore: number;
  rate: number;
  score: number;
}

/**
 * 试卷
 */
export interface ExamPaper {
  id: number;
  paperName: string;
  paperType: string;
  questions: ExamineeQuestion[];
  score?: number;
  subjectId: number;
  year: number;
}

export type ExamPaperQuestion = Pick<ExamineeQuestion, 'id' | 'title' | 'options' | 'subQuestions'>;

export interface ExamPaperSubmit {
  id: number;
  paperName: string;
  paperType: string;
  questions: Question[];
  score?: number;
  subjectId: number;
  year: number;
  duration?: number;
  examineeId?: number;
  isDone?: boolean;
}

export interface QuestionOptionState {
  isAnswer: boolean;
  isCorrect: boolean;
  isSelected: boolean;
  isMissed: boolean;
  isIncorrect: boolean;
}

export interface PracticeSettings {
  reviewMode: EnumReviewMode;
  autoNext: boolean;
}

export interface QuestionOption extends QuestionOptionState {
  id: number;
  no: string; // A, B, C, D
  name: string;
}

export interface Question extends QuestionState {
  id: number;
  title: string;
  typeId: number;
  options: QuestionOption[];
  answers: string[];
  answer1: string;
  answer2: string;
  parse?: string;
  subQuestions: Question[];
  totalScore: number;
  //
  index: number; // 索引
  offset: number; // 偏移量
  isSubQuestion?: boolean; // 是否是子题
  //
  parentIndex?: number; // 父题索引
  parentId?: number; // 父题ID
  parentTypeId?: number; // 父题类型
  subIndex?: number; // 子题索引
  //
  virtualIndex: number; // 虚拟索引
}

export interface SubjectListRequestDTO {
  directed: boolean;
}

export interface KnowledgeListRequestDTO {
  subjectId: number;
  directed: boolean;
}

export interface OpenExamineeRequestDTO {
  paperType: string,
  relateId?: number,
  directed: boolean,
  subjectId?: number,
  testType?: string
}

export interface GetExamPaperRequestDTO {
  type: string,
  id: number
}

export interface DirectedSchool extends SelectedUniversityMajor {
  code: string;
  notice: string;
}

export interface University {
  code: string;
  id: number;
  name: string;
  logo: string;
  type: string;
}

export interface UniversityMajor {
  ancestors: string;
  code: string;
  id: number;
  name: string;
  type: string
}

// 

export interface SelectedUniversityMajor {
  universityLogo: string;
  universityId: string;
  universityName: string;
  majorId: string;
  majorName: string;
  majorAncestors: string;
}

export interface SimulationTestOptions {
  universityId: string;
  universityName: string;
  majorId: string;
  majorName: string;
}

export interface SimulationTestInfo {
  evalCount: number;
  subjects: string[]
}


// 学习记录
export interface KnowledgeRecord {
  name: string;
  total: number;
  rate: number;
  directed: boolean; // 是否是定向
}

export interface SimulatedRecord {
  id: number;
  rate: number;
  name: string;
  score: number;
  total: number;
  date: string;
  // 
  subjectName: string;
  state: EnumSimulatedRecordStatus;
}

export interface VideoStudyRecord {
  study: number;
  total: number;
  list: {
    name: string;
    date: string;
    study: string;
  }[]
}

export interface PracticeRecord {
  rate: number;
  total: number;
  studyDays: number;
  list: {
    rate: number;
    date: string;
    study: number;
  }[]
}

/**
 * 模拟考试科目
 */
export interface SimulationExamSubject {
  subjectId: number;
  subject: string;
  examTime: number;
  icon: string;
}

export interface PracticeHistory {
  directed: number;
  endTime: string;
  examineeId: number;
  paperName: string;
}