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
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { api } from "@/lib/api-client";
|
|
|
|
export interface AiCourseCreateEnglishRequest {
|
|
cefr_level: string;
|
|
gap_profile_id?: number;
|
|
}
|
|
|
|
export interface AiCourseCreateIeltsRequest {
|
|
skill: "listening" | "reading" | "writing" | "speaking";
|
|
target_band: number;
|
|
brief?: string;
|
|
}
|
|
|
|
export interface AiCourseCreateResponse {
|
|
log_id: number;
|
|
status: string;
|
|
brief?: Record<string, unknown>;
|
|
skill?: string;
|
|
}
|
|
|
|
export interface QualityGateResult {
|
|
status: string;
|
|
readability_score: number;
|
|
cefr_alignment: boolean;
|
|
grammar_issues: string[];
|
|
attempts: number;
|
|
}
|
|
|
|
export interface IELTSValidationResult {
|
|
type: string;
|
|
validation_results: Record<string, unknown>;
|
|
overall_passed: boolean;
|
|
}
|
|
|
|
export const aiCourseService = {
|
|
createEnglish: (data: AiCourseCreateEnglishRequest) =>
|
|
api.post<AiCourseCreateResponse>("/ai-course/english/create", data),
|
|
|
|
createIelts: (data: AiCourseCreateIeltsRequest) =>
|
|
api.post<AiCourseCreateResponse>("/ai-course/ielts/create", data),
|
|
|
|
getCourse: (courseId: number) =>
|
|
api.get<Record<string, unknown>>(`/ai-course/${courseId}`),
|
|
|
|
getTracks: (courseId: number) =>
|
|
api.get<unknown[]>(`/ai-course/${courseId}/tracks`),
|
|
|
|
getQualityGate: (courseId: number) =>
|
|
api.get<QualityGateResult>(`/ai-course/${courseId}/quality`),
|
|
|
|
approveQuality: (courseId: number) =>
|
|
api.post<{ approved: boolean }>(`/ai-course/${courseId}/approve`),
|
|
|
|
rejectQuality: (courseId: number, reason: string) =>
|
|
api.post<{ rejected: boolean; can_retry: boolean }>(`/ai-course/${courseId}/reject`, { reason }),
|
|
|
|
getIeltsValidation: (courseId: number) =>
|
|
api.get<IELTSValidationResult>(`/ai-course/${courseId}/validation`),
|
|
|
|
submitExaminerReview: (logId: number, data: { action: string; examiner_notes?: string }) =>
|
|
api.post<{ status: string; log_id: number }>(`/ai-course/ielts-review/${logId}`, data),
|
|
|
|
getEnglishTaxonomy: () =>
|
|
api.get<Record<string, unknown>>("/ai-course/english/taxonomy"),
|
|
|
|
getReviewQueue: (page = 1, size = 20) =>
|
|
api.get<{ total: number; page: number; size: number; items: unknown[] }>("/ai-course/review-queue", { page, size }),
|
|
|
|
getIeltsReviewQueue: (page = 1, size = 20) =>
|
|
api.get<{ total: number; page: number; size: number; items: unknown[] }>("/ai-course/ielts-review-queue", { page, size }),
|
|
};
|