Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /** * Hook for fetching skill anomalies for teacher review * * Anomalies include: * - Skills that have been repeatedly skipped (student avoiding tutorials) * - Skills that are mastered but not being practiced (unusual state) */ import { useQuery } from '@tanstack/react-query' import type { SkillAnomaly } from '@/lib/curriculum/skill-unlock' interface AnomaliesResponse { anomalies: SkillAnomaly[] } export const skillAnomaliesKeys = { all: ['skillAnomalies'] as const, forPlayer: (playerId: string) => [...skillAnomaliesKeys.all, playerId] as const, } /** * Fetch skill anomalies for a student. * Returns anomalies that teachers may want to review. */ async function fetchSkillAnomalies(playerId: string): Promise<SkillAnomaly[]> { const response = await fetch(`/api/curriculum/${playerId}/anomalies`) if (!response.ok) { const error = await response.json() throw new Error(error.message || 'Failed to fetch skill anomalies') } const data: AnomaliesResponse = await response.json() return data.anomalies } /** * Hook to get skill anomalies for a student. * * @param playerId - The player ID * @param enabled - Whether to enable the query (default: true) * @returns Query result with anomalies array */ export function useSkillAnomalies(playerId: string, enabled = true) { return useQuery({ queryKey: skillAnomaliesKeys.forPlayer(playerId), queryFn: () => fetchSkillAnomalies(playerId), enabled: enabled && !!playerId, staleTime: 60_000, // 1 minute - anomalies don't change frequently refetchOnWindowFocus: false, }) } |