feat(rapport): Sprint 3.6b — RapportPage enrichie, exercices dynamiques, production modèle, sélecteur NCLC
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8390e8b873
commit
f51caa1b75
22 changed files with 1357 additions and 297 deletions
|
|
@ -46,7 +46,7 @@ interface FlowValue {
|
|||
createError: ApiError | null
|
||||
correctError: ApiError | null
|
||||
selectTask: (payload: CreateSimulationPayload) => void
|
||||
submitText: (texte: string) => void
|
||||
submitText: (texte: string, nclcCible?: 9 | 10) => void
|
||||
changeSubject: (sujet: SujetData) => void
|
||||
setStep: (step: SimulationStep) => void
|
||||
reset: () => void
|
||||
|
|
@ -101,16 +101,27 @@ export function SimulationFlowProvider({ children }: { children: ReactNode }) {
|
|||
mutationFn: createSimulation,
|
||||
onSuccess: (data) => {
|
||||
setProduction(data)
|
||||
setStep(TACHES_SANS_CATALOGUE.includes(data.tache) ? 'task-selected' : 'choosing-subject')
|
||||
const hasCatalogue = !TACHES_SANS_CATALOGUE.includes(data.tache)
|
||||
setStep(hasCatalogue ? 'choosing-subject' : 'task-selected')
|
||||
// Navigation initiale vers /sujets pour les tâches avec catalogue —
|
||||
// gérée ici (et non dans un useEffect sticky côté SimulationPage) pour
|
||||
// éviter la boucle infinie quand l'utilisateur revient depuis /sujets.
|
||||
if (hasCatalogue) {
|
||||
navigate('/sujets')
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const correctMutation = useMutation({
|
||||
mutationFn: correctEe,
|
||||
onMutate: () => setStep('correcting'),
|
||||
onSuccess: () => {
|
||||
onSuccess: (_data, variables) => {
|
||||
setStep('done')
|
||||
localStorage.removeItem(LS_SIMULATION_ID_KEY)
|
||||
// Navigation vers le rapport déclenchée ici (plutôt que depuis un
|
||||
// useEffect sticky côté SimulationPage) — une seule fois par correction,
|
||||
// pas de redirection en boucle si l'utilisateur revient sur /simulation/ee.
|
||||
navigate(`/rapport/${variables.simulationId}`)
|
||||
},
|
||||
onError: () => setStep('task-selected'),
|
||||
})
|
||||
|
|
@ -119,9 +130,14 @@ export function SimulationFlowProvider({ children }: { children: ReactNode }) {
|
|||
createMutation.mutate(payload)
|
||||
}
|
||||
|
||||
function submitText(texte: string): void {
|
||||
function submitText(texte: string, nclcCible: 9 | 10 = 9): void {
|
||||
if (!production) return
|
||||
correctMutation.mutate({ simulationId: production.id, contenu: texte, tache: production.tache })
|
||||
correctMutation.mutate({
|
||||
simulationId: production.id,
|
||||
contenu: texte,
|
||||
tache: production.tache,
|
||||
nclc_cible: nclcCible,
|
||||
})
|
||||
}
|
||||
|
||||
function changeSubject(sujet: SujetData): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue