fix(qa): approval queue, rubric UX, structure enforcement, upload/publish limits
Addresses the QA notes on the end-to-end approval flow. Highlights:
Backend
- encoach_ai/generation_submit: create encoach.approval.request on submit so
submitted exams actually reach the approver queue (previously only the
workflow id was stored on the exam, leaving approvers with an empty inbox).
Initial exam status flips to pending_approval instead of draft.
- encoach_exam_template/approval_workflows:
* /api/approval-users filters out students (user_type='student',
op_student_id set, share=True) so the approver dropdown only lists staff.
* _ser_request enriches requests with target_name / target_status and the
current stage approver for UI badges.
* list_requests supports mine=1 / requester=1 so approvers only see queue
items awaiting their action.
* approve_request / reject_request now transition the underlying
encoach.exam.custom to published / rejected on final approval.
- encoach.exam.custom.status: add pending_approval and rejected states to
match the approval workflow transitions.
Frontend UX
- GenerationPage: rubric field shows "Auto-graded — no rubric" for Listening
and Reading (rubrics only apply to Writing / Speaking). Divider dropdowns
now carry explicit help text explaining None / Line / Space / Page Break
and where to write prompts. Selecting an official exam structure
auto-populates the required tasks/sections/parts, the delete button is
hidden for essential tasks, and submit is blocked if the user dropped
below the structure's required count.
- RubricsPage: "Add Criterion" is now a dropdown with IELTS-specific
presets (Task Achievement, Coherence & Cohesion, Fluency & Coherence, …)
keyed off the selected skill, plus a "Custom (blank row)" fallback.
- AdminCourses: added tooltips and helper copy clarifying Difficulty vs
CEFR Level in the Create Course dialog.
- CustomExamCreate: validate the whole form before Save/Publish, surface
backend error messages (413/504/401) instead of a generic toast, read the
exam id from the correct response field, and avoid marking Publish as
failed when only the optional Save-as-Template step errors.
- ResourceManager / TeacherLibrary: upload toast now shows a concrete
reason (HTTP 413 / 504 / 401) instead of a generic "Upload failed".
Config (504 / 413 / resource upload fixes)
- odoo.conf + odoo-docker.conf: raise limit_time_cpu to 600s,
limit_time_real to 900s, limit_request to 128 MB, and memory caps so
/api/exam/generation/submit and multipart resource uploads stop hitting
504 / 413 during QA.
- frontend/Dockerfile (nginx): add client_max_body_size 128m, bump
proxy_read_timeout / proxy_send_timeout to 900s, and disable request
buffering so large AI/resource payloads stream through the proxy.
Made-with: Cursor
This commit is contained in:
@@ -1372,7 +1372,7 @@ class AIController(http.Controller):
|
||||
except KeyError:
|
||||
return _json_response({"error": "encoach.exam.custom model not available"}, 500)
|
||||
|
||||
initial_status = "published" if skip_approval else "draft"
|
||||
initial_status = "published" if skip_approval else "pending_approval"
|
||||
exam_vals = {
|
||||
"title": title,
|
||||
"label": label,
|
||||
@@ -1558,11 +1558,46 @@ class AIController(http.Controller):
|
||||
quality_summary["failed"], quality_summary["warned"],
|
||||
)
|
||||
|
||||
# ── Route through the approval workflow ────────────────────────
|
||||
# If the admin selected an approval workflow AND did not click
|
||||
# "skip approval", create a real ``encoach.approval.request`` that
|
||||
# lands in the first stage approver's queue. QA flagged that
|
||||
# submitted modules were invisible to the assigned approver —
|
||||
# before this block the exam was just left in ``draft`` with
|
||||
# ``approval_workflow_id`` set but no request record routing it.
|
||||
approval_request_id = False
|
||||
if not skip_approval and workflow_id:
|
||||
try:
|
||||
Workflow = request.env["encoach.approval.workflow"].sudo()
|
||||
workflow = Workflow.browse(workflow_id)
|
||||
if workflow.exists() and workflow.stage_ids:
|
||||
first_stage = workflow.stage_ids.sorted("sequence")[:1]
|
||||
approval_req = request.env["encoach.approval.request"].sudo().create({
|
||||
"workflow_id": workflow.id,
|
||||
"res_model": "encoach.exam.custom",
|
||||
"res_id": exam.id,
|
||||
"state": "in_progress" if first_stage else "draft",
|
||||
"requester_id": request.env.user.id,
|
||||
"current_stage_id": first_stage.id if first_stage else False,
|
||||
})
|
||||
approval_request_id = approval_req.id
|
||||
_logger.info(
|
||||
"created approval.request %s for exam %s (workflow %s, stage %s)",
|
||||
approval_req.id, exam.id, workflow.id,
|
||||
first_stage.id if first_stage else None,
|
||||
)
|
||||
except Exception:
|
||||
_logger.exception(
|
||||
"failed to create approval request for exam %s workflow %s",
|
||||
exam.id, workflow_id,
|
||||
)
|
||||
|
||||
return _json_response({
|
||||
"exam_id": exam.id,
|
||||
"status": exam.status,
|
||||
"template_id": template_id,
|
||||
"total_questions": total_questions,
|
||||
"approval_request_id": approval_request_id,
|
||||
"quality": quality_summary,
|
||||
"schema_validation": {
|
||||
"verdict": schema_report["verdict"],
|
||||
|
||||
Reference in New Issue
Block a user