Generation Page (complete rebuild): - Full production-parity exam generation wizard with 4 IELTS modules - Reading: AI passage gen, 5 exercise types (MCQ, Fill, Write, T/F, Match) - Listening: 4 section types, AI context gen, TTS audio gen (ElevenLabs) - Writing: Task 1/2, AI instruction gen, word limits, marks - Speaking: 3 parts, AI script gen, avatar video gen (7 avatars) - Per-module config: timer, CEFR difficulty, access, approval, rubrics - Exam submission workflow (draft/published) Exam Structures: - New encoach.exam.structure model + CRUD controller - ExamStructuresPage wired to real API AI Module (encoach_ai): - OpenAI service, ElevenLabs TTS, AWS Polly, ELAI avatars - AI settings model with Odoo config parameters - 7 generation endpoints (passage, exercises, instructions, scripts, context) Vector Module (encoach_vector): - pgvector integration for RAG-based content search - Embedding service with sentence-transformers Exam Session Fixes: - Fixed ExamSession.tsx field mapping (question_type→type, exam_title→title) - Fixed submit payload to include attempt_id and answers - Fixed normalizeType to handle null/undefined Tested: 12/12 API tests passed, browser-verified with real OpenAI calls Made-with: Cursor
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { useQuery, useMutation } from "@tanstack/react-query";
|
|
import { queryKeys } from "./keys";
|
|
import { examSessionService } from "@/services/exam-session.service";
|
|
import type { ExamAutoSave } from "@/types";
|
|
|
|
export function useExamSession(examId: number) {
|
|
return useQuery({
|
|
queryKey: queryKeys.examSession.session(examId),
|
|
queryFn: () => examSessionService.getSession(examId),
|
|
enabled: !!examId,
|
|
});
|
|
}
|
|
|
|
export function useExamStatus(examId: number, enabled: boolean) {
|
|
return useQuery({
|
|
queryKey: queryKeys.examSession.status(examId),
|
|
queryFn: () => examSessionService.getStatus(examId),
|
|
enabled: !!examId && enabled,
|
|
refetchInterval: 10000,
|
|
});
|
|
}
|
|
|
|
export function useExamAutoSave() {
|
|
return useMutation({
|
|
mutationFn: (data: { examId: number; payload: ExamAutoSave }) =>
|
|
examSessionService.autoSave(data.examId, data.payload),
|
|
});
|
|
}
|
|
|
|
export function useExamSubmit() {
|
|
return useMutation({
|
|
mutationFn: (data: { examId: number; attempt_id: number; answers: { question_id: number; answer: unknown }[] }) =>
|
|
examSessionService.submit(data.examId, { attempt_id: data.attempt_id, answers: data.answers }),
|
|
});
|
|
}
|