/**
 * Score analysis / prediction (legacy CI score_analysis/score_prediction).
 */
import { apiFetch } from './http'

export type ScorePredictionStudent = Record<string, unknown>

export type ScorePredictionResponse = {
  school_year?: string
  selectedClassSectionId?: string | number | null
  classSections?: Array<{ class_section_id?: number | string; class_section_name?: string }>
  students?: ScorePredictionStudent[]
}

export async function fetchScorePrediction(params?: {
  school_year?: string
  class_section_id?: string
}): Promise<ScorePredictionResponse> {
  const qs = new URLSearchParams()
  if (params?.school_year) qs.set('school_year', params.school_year)
  if (params?.class_section_id) qs.set('class_section_id', params.class_section_id)
  const suffix = qs.toString() ? `?${qs}` : ''
  return apiFetch(`/api/v1/administrator/score-analysis/score-prediction${suffix}`)
}
