Add the playable scene loop: boot through mission to reward

Wires every autoload up to a real UI: boot -> profile select/create
-> world map (three mission markers, positioned from data, not
hardcoded pixels) -> mission intro (narrative from data/missions/,
a new data type with its own schema) -> rule panel -> exercise host
-> one of the three exercise type scenes -> feedback panel -> reward
screen -> back to the map.

exercise_host is the only piece with real orchestration logic: picks
exercises via ExerciseEngine (now fully implemented, validating at
load like make validate-data does), validates answers through the
pure AnswerValidator/DictationAnalyzer, escalates aid over 3 attempts
via AttemptFlow, feeds DifficultyManager so adaptive difficulty is
actually wired in rather than dead code, and records every attempt
through ProgressManager. Every exercise-type scene (multiple_choice,
sentence_correction, dictation) only emits its answer by signal, per
the architecture invariant.

All child-facing text now comes from data/localization/fr.json via
UIText, not hardcoded in scripts or scenes. Getting that right
required extending SchemaValidator to support "additionalProperties"
as a schema (dynamic keys), which also closed a real gap: save.skills
was previously unvalidated against SkillState's actual shape.

16 new headless tests, including two integration tests that instance
exercise_host.tscn directly and drive it by emitting child-scene
signals, stopping short of the final scene transition (which would
tear down the test runner's own tree). Everything that needs a
screen -- layout at different sizes, touch, virtual keyboard, actual
audio playback (no .ogg files exist yet) -- is listed in the new
docs/testing/manual-checklist.md instead of claimed as verified.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Denis Defolie
2026-10-11 17:37:37 +02:00
parent ebabe91821
commit 493a8617d7
71 changed files with 1986 additions and 8 deletions
+41
View File
@@ -0,0 +1,41 @@
extends Control
## Exercice de dictee : ecoute puis ecrit. Scene autonome : emet la reponse
## par signal, ne touche ni a la sauvegarde ni a la progression. L'audio est
## provisoire (voir docs/specs/decisions.md, point 8) ; le badge l'indique a
## l'enfant tant qu'aucune voix definitive n'a remplace le fichier.
signal answer_submitted(submitted_text: String)
var _dictation: Dictionary = {}
@onready var _instruction_label: Label = %InstructionLabel
@onready var _replay_button: Button = %ReplayButton
@onready var _provisional_badge: Label = %ProvisionalBadge
@onready var _text_edit: LineEdit = %TextEdit
@onready var _validate_button: Button = %ValidateButton
func _ready() -> void:
_instruction_label.text = UIText.get_text("dictation.instruction_label")
_replay_button.text = UIText.get_text("dictation.replay_button")
_text_edit.placeholder_text = UIText.get_text("dictation.input_placeholder")
_provisional_badge.text = UIText.get_text("dictation.provisional_audio_badge")
_validate_button.text = UIText.get_text("exercise_host.validate_button")
_replay_button.pressed.connect(_on_replay_pressed)
_validate_button.pressed.connect(_on_validate_pressed)
func load_exercise(dictation: Dictionary) -> void:
_dictation = dictation
_text_edit.text = ""
_provisional_badge.visible = dictation.get("audio_provisional", false)
_on_replay_pressed()
func _on_replay_pressed() -> void:
AudioManager.play_dictation(_dictation.get("audio_id", ""))
func _on_validate_pressed() -> void:
answer_submitted.emit(_text_edit.text)
+1
View File
@@ -0,0 +1 @@
uid://dacf070bahaho
+53
View File
@@ -0,0 +1,53 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/exercises/dictation.gd" id="1"]
[node name="Dictation" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1")
[node name="Margin" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 24
theme_override_constants/margin_top = 24
theme_override_constants/margin_right = 24
theme_override_constants/margin_bottom = 24
[node name="VBox" type="VBoxContainer" parent="Margin"]
layout_mode = 2
theme_override_constants/separation = 16
[node name="InstructionLabel" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
autowrap_mode = 2
[node name="ProvisionalBadge" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0.6, 0.45, 0.1, 1)
[node name="ReplayButton" type="Button" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 56)
[node name="TextEdit" type="LineEdit" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 56)
[node name="ValidateButton" type="Button" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 56)
+150
View File
@@ -0,0 +1,150 @@
extends Control
## Hote d'exercice : charge la regle, enchaine les exercices d'une mission,
## valide chaque reponse via les validateurs purs (AnswerValidator /
## DictationAnalyzer), applique l'aide graduee (AttemptFlow) et enregistre
## chaque tentative dans ProgressManager (docs/specs/decisions.md, point 7).
## Ne charge et ne sauvegarde rien lui-meme sur disque : ProgressManager et
## SaveManager restent seuls responsables de la persistance.
const MISSION_LENGTH := 3
const TYPE_SCENES := {
"multiple_choice": "res://scenes/exercises/multiple_choice.tscn",
"sentence_correction": "res://scenes/exercises/sentence_correction.tscn",
"dictation": "res://scenes/exercises/dictation.tscn",
}
var _mission: Dictionary = {}
var _rule: Dictionary = {}
var _skill_id: String = ""
var _current_exercise: Dictionary = {}
var _current_exercise_scene: Control = null
var _current_difficulty := 1
var _attempt_number := 1
var _completed_count := 0
var _last_exercise_id := ""
@onready var _exercise_container: Control = %ExerciseContainer
@onready var _overlay_container: Control = %OverlayContainer
## Accesseurs reserves aux tests d'integration (scenes/exercises/
## exercise_host.tscn n'expose pas de script "ami" en GDScript).
func get_current_exercise() -> Dictionary:
return _current_exercise
func get_attempt_number() -> int:
return _attempt_number
func get_completed_count() -> int:
return _completed_count
func _ready() -> void:
_mission = ExerciseEngine.get_mission(GameManager.pending_mission_id)
_rule = ExerciseEngine.get_rule(_mission["rule_id"])
_skill_id = _rule.get("skill", "")
_current_difficulty = ProgressManager.next_difficulty_for_skill(_skill_id, 1)
_show_rule_panel()
func _show_rule_panel() -> void:
var rule_panel: Control = preload("res://scenes/ui/rule_panel.tscn").instantiate()
_overlay_container.add_child(rule_panel)
rule_panel.show_rule(_rule)
rule_panel.continued.connect(_on_rule_panel_continued.bind(rule_panel))
func _on_rule_panel_continued(rule_panel: Control) -> void:
rule_panel.queue_free()
_load_next_exercise()
func _load_next_exercise() -> void:
_current_exercise = ExerciseEngine.pick_exercise_for_mission(
_mission, _last_exercise_id, _current_difficulty
)
_attempt_number = 1
if _current_exercise_scene != null:
_current_exercise_scene.queue_free()
var scene_path: String = TYPE_SCENES[_mission["exercise_type"]]
_current_exercise_scene = load(scene_path).instantiate()
_exercise_container.add_child(_current_exercise_scene)
_current_exercise_scene.load_exercise(_current_exercise)
_connect_answer_signal()
func _connect_answer_signal() -> void:
match _mission["exercise_type"]:
"multiple_choice":
_current_exercise_scene.answer_submitted.connect(_on_multiple_choice_submitted)
"sentence_correction":
_current_exercise_scene.answer_submitted.connect(_on_sentence_correction_submitted)
"dictation":
_current_exercise_scene.answer_submitted.connect(_on_dictation_submitted)
func _on_multiple_choice_submitted(selected_index: int) -> void:
_handle_result(AnswerValidator.validate_multiple_choice(_current_exercise, selected_index))
func _on_sentence_correction_submitted(selected_indices: Array, corrections: Dictionary) -> void:
var typed_indices: Array[int] = []
for index: int in selected_indices:
typed_indices.append(index)
_handle_result(
AnswerValidator.validate_sentence_correction(
_current_exercise, typed_indices, corrections
)
)
func _on_dictation_submitted(submitted_text: String) -> void:
_handle_result(DictationAnalyzer.analyze(_current_exercise, submitted_text))
func _handle_result(result: CorrectionResult) -> void:
var support_level := AttemptFlow.SupportLevel.EXPLANATION
var is_terminal := result.is_correct
if not result.is_correct:
support_level = AttemptFlow.support_level_for_attempt(_attempt_number)
is_terminal = AttemptFlow.should_end_exercise(_attempt_number)
ProgressManager.record_attempt(
_skill_id, result.is_correct, _attempt_number > 1, _mission["exercise_type"]
)
_show_feedback(result, support_level, is_terminal)
func _show_feedback(
result: CorrectionResult, support_level: AttemptFlow.SupportLevel, is_terminal: bool
) -> void:
var feedback: Control = preload("res://scenes/ui/feedback_panel.tscn").instantiate()
_overlay_container.add_child(feedback)
feedback.show_result(result, support_level)
feedback.continue_pressed.connect(_on_feedback_continued.bind(feedback, is_terminal))
func _on_feedback_continued(feedback: Control, is_terminal: bool) -> void:
feedback.queue_free()
if not is_terminal:
_attempt_number += 1
return
_current_difficulty = ProgressManager.next_difficulty_for_skill(
_skill_id, _current_difficulty
)
_last_exercise_id = _current_exercise.get("id", "")
_completed_count += 1
if _completed_count >= MISSION_LENGTH:
GameManager.goto(GameManager.SCENE_REWARD)
else:
_load_next_exercise()
+1
View File
@@ -0,0 +1 @@
uid://co82y6w81weqr
+31
View File
@@ -0,0 +1,31 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/exercises/exercise_host.gd" id="1"]
[node name="ExerciseHost" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1")
[node name="ExerciseContainer" type="Control" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="OverlayContainer" type="Control" parent="."]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
+30
View File
@@ -0,0 +1,30 @@
extends Control
## Exercice a choix multiple. Scene autonome : emet la reponse par signal,
## ne touche ni a la sauvegarde ni a la progression (invariant d'architecture,
## CLAUDE.md).
signal answer_submitted(selected_index: int)
@onready var _instruction_label: Label = %InstructionLabel
@onready var _question_label: Label = %QuestionLabel
@onready var _answers_box: VBoxContainer = %AnswersBox
func load_exercise(exercise: Dictionary) -> void:
_instruction_label.text = exercise["instruction"]
_question_label.text = exercise["question"]
for child in _answers_box.get_children():
child.queue_free()
var answers: Array = exercise["answers"]
for i in answers.size():
var button := Button.new()
button.text = answers[i]
button.custom_minimum_size = Vector2(0, 56)
button.pressed.connect(_on_answer_pressed.bind(i))
_answers_box.add_child(button)
func _on_answer_pressed(index: int) -> void:
answer_submitted.emit(index)
+1
View File
@@ -0,0 +1 @@
uid://5sbuvx3101u0
+44
View File
@@ -0,0 +1,44 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/exercises/multiple_choice.gd" id="1"]
[node name="MultipleChoice" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1")
[node name="Margin" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 24
theme_override_constants/margin_top = 24
theme_override_constants/margin_right = 24
theme_override_constants/margin_bottom = 24
[node name="VBox" type="VBoxContainer" parent="Margin"]
layout_mode = 2
theme_override_constants/separation = 16
[node name="InstructionLabel" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
autowrap_mode = 2
[node name="QuestionLabel" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
autowrap_mode = 2
theme_override_font_sizes/font_size = 24
[node name="AnswersBox" type="VBoxContainer" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 12
+59
View File
@@ -0,0 +1,59 @@
extends Control
## Exercice de correction de phrase : toucher le mot fautif puis le corriger
## (interaction decidee dans docs/specs/decisions.md, point 3). Scene
## autonome : emet la reponse par signal, ne touche ni a la sauvegarde ni a
## la progression.
signal answer_submitted(selected_indices: Array, corrections: Dictionary)
var _correction_edits: Dictionary = {}
@onready var _instruction_label: Label = %InstructionLabel
@onready var _tokens_box: HFlowContainer = %TokensBox
@onready var _corrections_box: VBoxContainer = %CorrectionsBox
@onready var _validate_button: Button = %ValidateButton
func _ready() -> void:
_validate_button.text = UIText.get_text("exercise_host.validate_button")
_validate_button.pressed.connect(_on_validate_pressed)
func load_exercise(exercise: Dictionary) -> void:
_instruction_label.text = exercise["instruction"]
for child in _tokens_box.get_children():
child.queue_free()
for child in _corrections_box.get_children():
child.queue_free()
_correction_edits.clear()
var tokens: Array = exercise["tokens"]
for i in tokens.size():
var button := Button.new()
button.text = tokens[i]["text"]
button.toggle_mode = true
button.toggled.connect(_on_token_toggled.bind(i))
_tokens_box.add_child(button)
func _on_token_toggled(pressed: bool, index: int) -> void:
if pressed:
if not _correction_edits.has(index):
var edit := LineEdit.new()
edit.placeholder_text = UIText.get_text("sentence_correction.correction_placeholder")
_corrections_box.add_child(edit)
_correction_edits[index] = edit
elif _correction_edits.has(index):
var edit: LineEdit = _correction_edits[index]
edit.queue_free()
_correction_edits.erase(index)
func _on_validate_pressed() -> void:
var selected_indices: Array = []
var corrections: Dictionary = {}
for index: int in _correction_edits.keys():
selected_indices.append(index)
corrections[index] = (_correction_edits[index] as LineEdit).text.strip_edges()
answer_submitted.emit(selected_indices, corrections)
@@ -0,0 +1 @@
uid://cdn2shqmift8j
+50
View File
@@ -0,0 +1,50 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://scenes/exercises/sentence_correction.gd" id="1"]
[node name="SentenceCorrection" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1")
[node name="Margin" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 24
theme_override_constants/margin_top = 24
theme_override_constants/margin_right = 24
theme_override_constants/margin_bottom = 24
[node name="VBox" type="VBoxContainer" parent="Margin"]
layout_mode = 2
theme_override_constants/separation = 16
[node name="InstructionLabel" type="Label" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
autowrap_mode = 2
[node name="TokensBox" type="HFlowContainer" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/h_separation = 8
theme_override_constants/v_separation = 8
[node name="CorrectionsBox" type="VBoxContainer" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 8
[node name="ValidateButton" type="Button" parent="Margin/VBox"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(0, 56)