export type ExamSessionState = "draft" | "schedule" | "held" | "cancel" | "done";
export type InstitutionalExamState = "draft" | "schedule" | "held" | "result_updated" | "cancel" | "done";
export type MarksheetState = "draft" | "validated" | "cancelled";
export type SubmissionState = "draft" | "submit" | "accept" | "reject" | "change_req";

export interface ExamType {
  id: number;
  name: string;
}

export interface ExamRoom {
  id: number;
  name: string;
  classroom_id?: number;
  classroom_name?: string;
  capacity: number;
}

export interface InstitutionalExamSession {
  id: number;
  name: string;
  course_id: number;
  course_name: string;
  batch_id: number;
  batch_name: string;
  exam_code: string;
  start_date: string;
  end_date: string;
  exam_type_id: number;
  exam_type_name: string;
  evaluation_type: "normal" | "grade";
  venue?: string;
  state: ExamSessionState;
  exam_count: number;
}

export interface InstitutionalExam {
  id: number;
  name: string;
  session_id: number;
  subject_id: number;
  subject_name: string;
  exam_code: string;
  start_time: string;
  end_time: string;
  total_marks: number;
  min_marks: number;
  state: InstitutionalExamState;
  responsible_names: string[];
  attendee_count: number;
}

export interface ExamAttendee {
  id: number;
  exam_id: number;
  student_id: number;
  student_name: string;
  room_id?: number;
  room_name?: string;
  marks: number;
  status: "pass" | "fail";
}

export interface GradeConfig {
  id: number;
  min_per: number;
  max_per: number;
  result: string;
}

export interface ResultTemplate {
  id: number;
  name: string;
  exam_session_id: number;
  exam_session_name: string;
  evaluation_type: "normal" | "grade";
  result_date: string;
  grade_ids: number[];
  state: "draft" | "result_generated";
}

export interface Marksheet {
  id: number;
  name: string;
  exam_session_id: number;
  exam_session_name: string;
  result_template_id: number;
  generated_date: string;
  generated_by_name: string;
  state: MarksheetState;
  total_pass: number;
  total_failed: number;
  lines: MarksheetLine[];
}

export interface MarksheetLine {
  id: number;
  student_id: number;
  student_name: string;
  total_marks: number;
  percentage: number;
  grade?: string;
  status: "pass" | "fail";
  results: ResultLine[];
}

export interface ResultLine {
  id: number;
  exam_id: number;
  exam_name: string;
  subject_name: string;
  marks: number;
  grade?: string;
  status: "pass" | "fail";
}

export interface CourseAssignmentType {
  id: number;
  name: string;
}

export interface CourseAssignment {
  id: number;
  name: string;
  course_id: number;
  course_name: string;
  subject_id?: number;
  subject_name?: string;
  batch_id: number;
  batch_name: string;
  faculty_id: number;
  faculty_name: string;
  description: string;
  marks: number;
  point: number;
  assignment_type_id: number;
  assignment_type_name: string;
  issued_date: string;
  submission_date: string;
  state: "draft" | "publish" | "finish" | "cancel";
  allocation_count: number;
  submission_count: number;
  reviewer_id?: number;
  reviewer_name?: string;
}

export interface AssignmentSubmission {
  id: number;
  assignment_id: number;
  student_id: number;
  student_name: string;
  description?: string;
  submission_date?: string;
  attachment_ids: number[];
  attachment_names: string[];
  marks: number;
  state: SubmissionState;
  faculty_id?: number;
  faculty_name?: string;
  note?: string;
}

export interface SubjectRegistration {
  id: number;
  student_id: number;
  student_name: string;
  course_id: number;
  course_name: string;
  batch_id: number;
  batch_name: string;
  subject_ids: number[];
  subject_names: string[];
  min_unit_load: number;
  max_unit_load: number;
  state: "draft" | "confirm" | "reject" | "done";
}

export type InstExamSession = InstitutionalExamSession;
export type InstExam = InstitutionalExam;
export type AssignmentType = CourseAssignmentType;

export type InstExamSessionCreateRequest = Omit<InstitutionalExamSession, "id" | "state" | "exam_count" | "course_name" | "batch_name" | "exam_type_name">;
export type InstExamCreateRequest = Omit<InstitutionalExam, "id" | "state" | "responsible_names" | "attendee_count" | "subject_name">;
export type ExamTypeCreateRequest = Omit<ExamType, "id">;
export type GradeConfigCreateRequest = Omit<GradeConfig, "id">;
export type ResultTemplateCreateRequest = Omit<ResultTemplate, "id" | "state">;
export type CourseAssignmentCreateRequest = Omit<CourseAssignment, "id" | "state" | "course_name" | "batch_name" | "faculty_name" | "assignment_type_name" | "reviewer_name" | "allocation_count" | "submission_count" | "subject_name">;
export type AssignmentTypeCreateRequest = Omit<CourseAssignmentType, "id">;
export type SubjectRegistrationCreateRequest = Omit<SubjectRegistration, "id" | "state" | "student_name" | "course_name" | "batch_name" | "subject_names">;
