feat: Generation Page AI workflows + AI/Vector modules + exam session fixes

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
This commit is contained in:
Yamen Ahmad
2026-04-11 14:27:03 +04:00
parent 140ca7408d
commit b02ee8b6b7
64 changed files with 2639 additions and 264 deletions

View File

@@ -1,28 +1,55 @@
import { api } from "@/lib/api-client";
import type { AiChatRequest, AiChatResponse, AiTip } from "@/types";
interface CoachChatRequest {
message: string;
history?: { role: string; content: string }[];
context?: unknown;
}
interface CoachChatResponse {
reply: string;
}
interface CoachTipResponse {
tip: string;
category: string;
}
interface CoachSuggestResponse {
suggestion: string;
focus_areas: string[];
daily_plan: { activity: string; duration_min: number; skill: string }[];
motivation: string;
}
interface CoachWritingResponse {
improved_text: string;
changes: { original: string; revised: string; reason: string }[];
tips: string[];
}
export const coachingService = {
async chat(data: AiChatRequest): Promise<AiChatResponse> {
return api.post<AiChatResponse>("/coach/chat", data);
async chat(data: CoachChatRequest): Promise<CoachChatResponse> {
return api.post<CoachChatResponse>("/coach/chat", data);
},
async getHint(data: { topic_id: number; question_id: string }): Promise<{ hint: string }> {
async getHint(data: { topic_id: number; question_id: string }): Promise<{ hint: string; strategy: string }> {
return api.post("/coach/hint", data);
},
async explain(data: { context: string; scores?: Record<string, number> }): Promise<{ explanation: string }> {
async explain(data: { score_data: Record<string, unknown>; student_context?: string }): Promise<{ explanation: string }> {
return api.post("/coach/explain", data);
},
async suggest(data?: { subject_id?: number }): Promise<{ suggestions: string[]; study_plan_tips: string[] }> {
async suggest(data?: Record<string, unknown>): Promise<CoachSuggestResponse> {
return api.post("/coach/suggest", data);
},
async writingHelp(data: { text: string; task_type: string }): Promise<{ feedback: string; improved: string; grammar_notes: string[] }> {
async writingHelp(data: { task: string; draft: string; help_type: string }): Promise<CoachWritingResponse> {
return api.post("/coach/writing-help", data);
},
async getTip(context: string): Promise<AiTip> {
return api.get<AiTip>("/coach/tip", { context });
async getTip(context: string): Promise<CoachTipResponse> {
return api.get<CoachTipResponse>("/coach/tip", { context });
},
};