feat(corrections): Sprint 3.6a — nouveaux prompts + taxonomie erreurs + génération parallèle

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hermann_Kitio 2026-04-22 17:27:29 +03:00
parent df7ef2cc31
commit 63bc43ddcf
14 changed files with 2319 additions and 282 deletions

View file

@ -9,7 +9,12 @@ const VALID_TACHES_EO = ['EO_T1', 'EO_T3']
const corrections = new Hono<{ Variables: AppVariables }>()
corrections.post('/ee', authMiddleware, async (c) => {
let body: { simulationId?: unknown; contenu?: unknown; tache?: unknown }
let body: {
simulationId?: unknown
contenu?: unknown
tache?: unknown
nclc_cible?: unknown
}
try {
body = await c.req.json()
} catch {
@ -44,12 +49,31 @@ corrections.post('/ee', authMiddleware, async (c) => {
)
}
// Sprint 3.6a — nclc_cible optionnel (défaut 9). Seules les valeurs 9 et 10 sont acceptées.
let nclcCible: 9 | 10 = 9
if (body.nclc_cible !== undefined) {
if (body.nclc_cible !== 9 && body.nclc_cible !== 10) {
return c.json(
{
error: true,
code: 'VALIDATION_ERROR',
message: 'nclc_cible doit être 9 ou 10.',
},
400
)
}
nclcCible = body.nclc_cible
}
const profile = c.get('profile')
const result = await correctionController.correctEE(
body.simulationId as string,
body.contenu as string,
body.tache as string,
profile
{
simulationId: body.simulationId,
contenu: body.contenu,
tache: body.tache as 'EE_T1' | 'EE_T2' | 'EE_T3',
nclcCible,
},
profile,
)
if ('error' in result) {

View file

@ -78,21 +78,10 @@ simulations.post('/', authMiddleware, async (c) => {
return c.json(result.data, 201)
})
simulations.get('/:id', authMiddleware, async (c) => {
// `:id` est garanti présent par le pattern de route Hono
const id = c.req.param('id')!
const profile = c.get('profile')
const result = await simulationController.getById(id, profile)
if ('error' in result) {
return c.json(result, result.status as 401 | 404 | 500)
}
return c.json(result.data, 200)
})
// FTD-21 — autosave du contenu d'une simulation en cours.
// Déclaré AVANT `GET /:id` par convention défensive, bien que Hono distingue
// les routes par (méthode, chemin) via un trie : PATCH /:id/contenu ne peut
// pas être capturé par GET /:id. Même raison pour /:id/sujet ci-dessous.
simulations.patch('/:id/contenu', authMiddleware, async (c) => {
const id = c.req.param('id')!
@ -162,4 +151,19 @@ simulations.patch('/:id/sujet', authMiddleware, async (c) => {
return c.json(result.data, 200)
})
// GET /:id en dernier — route catch-all par id, ne doit pas masquer les routes plus spécifiques.
simulations.get('/:id', authMiddleware, async (c) => {
// `:id` est garanti présent par le pattern de route Hono
const id = c.req.param('id')!
const profile = c.get('profile')
const result = await simulationController.getById(id, profile)
if ('error' in result) {
return c.json(result, result.status as 401 | 404 | 500)
}
return c.json(result.data, 200)
})
export default simulations