mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 02:11:58 +02:00
Add pure correction and pedagogy logic with full test coverage
scripts/correction/: AnswerValidator (multiple choice, sentence correction via tap-the-faulty-word + retype) and DictationAnalyzer build the CorrectionResult structure from cahier des charges §6. Dictation analysis aligns words with WordAligner (Wagner-Fischer edit distance) before any character comparison, so an omitted or added word doesn't cascade into false errors on every following word. TextNormalizer handles non-breaking spaces, typographic apostrophes, and decomposed-vs-composed French accented characters via an explicit table (GDScript has no built-in NFC/NFD normalization). Error classification follows the data annotations only (rule_id present -> grammatical, absent -> unclassified), never a runtime linguistic guess. scripts/pedagogy/: DifficultyManager (per-skill difficulty from recent results), AttemptFlow (3-attempt graduated aid: hint, then explanation, then reveal, matching exercise-lifecycle.md's second gap), and ReviewScheduler (the five mastery states from §9, with session-counted spaced review intervals [1, 3, 6, 12] rather than wall-clock dates, since a family device's clock isn't trustworthy). All of it is pure: no scene tree, no clock or RNG read directly, every effectful input (session number, attempt outcome) is a parameter. 65 headless tests across both layers, including the word-omission-doesn't-cascade regression and the full decouverte -> acquise -> a_reviser -> acquise path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
class_name DifficultyManager
|
||||
extends RefCounted
|
||||
## Suggere le niveau de difficulte (1 a 3) du prochain exercice pour une
|
||||
## competence, a partir de l'historique recent de reussites. Code pur : ne lit
|
||||
## ni horloge ni hasard, ne modifie aucun etat (ProgressManager est responsable
|
||||
## du stockage).
|
||||
|
||||
const MIN_DIFFICULTY := 1
|
||||
const MAX_DIFFICULTY := 3
|
||||
const WINDOW := 3
|
||||
|
||||
|
||||
## recent_results : resultats des tentatives les plus recentes, la derniere en
|
||||
## dernier. Monte d'un niveau apres WINDOW reussites consecutives ; descend
|
||||
## d'un niveau apres WINDOW echecs consecutifs ; ne bouge pas sinon. Jamais en
|
||||
## dehors de [MIN_DIFFICULTY, MAX_DIFFICULTY] : la difficulte evolue sans
|
||||
## jamais bloquer durablement l'enfant (cahier des charges §2).
|
||||
static func next_difficulty(current_difficulty: int, recent_results: Array[bool]) -> int:
|
||||
if recent_results.size() < WINDOW:
|
||||
return clampi(current_difficulty, MIN_DIFFICULTY, MAX_DIFFICULTY)
|
||||
|
||||
var last_window: Array[bool] = recent_results.slice(recent_results.size() - WINDOW)
|
||||
var all_success := true
|
||||
var all_failure := true
|
||||
for result in last_window:
|
||||
if result:
|
||||
all_failure = false
|
||||
else:
|
||||
all_success = false
|
||||
|
||||
if all_success:
|
||||
return clampi(current_difficulty + 1, MIN_DIFFICULTY, MAX_DIFFICULTY)
|
||||
if all_failure:
|
||||
return clampi(current_difficulty - 1, MIN_DIFFICULTY, MAX_DIFFICULTY)
|
||||
return clampi(current_difficulty, MIN_DIFFICULTY, MAX_DIFFICULTY)
|
||||
Reference in New Issue
Block a user