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,5 +1,6 @@
import json
import logging
import math
from odoo import http
from odoo.http import request
from odoo.addons.encoach_api.controllers.base import (
@@ -164,6 +165,44 @@ class EncoachAdaptiveController(http.Controller):
_logger.exception('student signals failed')
return _error_response(str(e), 500)
# ------------------------------------------------------------------
# GET /api/adaptive/student/<int:student_id>/ability
# ------------------------------------------------------------------
@http.route('/api/adaptive/student/<int:student_id>/ability', type='http',
auth='none', methods=['GET'], csrf=False)
@jwt_required
def student_ability(self, student_id, **kw):
try:
Event = request.env['encoach.adaptive.event'].sudo()
signals = Event.search([
('student_id', '=', student_id),
('event_type', '=', 'signal'),
], order='created_at asc')
trajectory = []
for s in signals:
trajectory.append({
'signal_name': s.signal_name or '',
'value': s.signal_value,
'timestamp': s.created_at,
})
values = [s.signal_value for s in signals if s.signal_value]
theta = sum(values) / len(values) if values else 0.0
sem = math.sqrt(sum((v - theta) ** 2 for v in values) / len(values)) if len(values) > 1 else 1.0
return _json_response({
'student_id': student_id,
'theta': round(theta, 3),
'sem': round(sem, 3),
'trajectory': trajectory,
'n_signals': len(trajectory),
})
except Exception as e:
_logger.exception('student ability failed')
return _error_response(str(e), 500)
# ------------------------------------------------------------------
# GET /api/adaptive/student/<int:student_id>/recommended-resources
# ------------------------------------------------------------------