mirror of
https://github.com/deunix-educ/aventuriers-des-mots.git
synced 2026-10-13 02:11:58 +02:00
Add JSON schemas, data validator, and first CE1 content
Introduces a generic JSON-Schema-subset validator in GDScript (scripts/data/schema_validator.gd) used both by `make validate-data` and, later, by ExerciseEngine at load time, plus semantic_checks.gd for cross-field constraints a schema can't express (answer index bounds, at least one faulty token in sentence correction, word count matching between a dictation's target_text and its annotations). Schemas cover rule, exercise (dispatched per type: multiple_choice, sentence_correction), dictation, curriculum, and save (save.schema.json is not yet wired into validate-data; saves live in user://, handled at the Profiles/Saves step). First draft content for the CE1 "accord_adjectif" rule (one rule, two multiple-choice exercises, one sentence correction, one dictation, one curriculum entry) exercises the full pipeline end to end and seeds docs/review/content-review.md, regenerated by the new tools/generate_content_review.py (`make content-review`). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
extends GutTest
|
||||
## Tests des contraintes croisees (scripts/data/semantic_checks.gd).
|
||||
|
||||
|
||||
func test_multiple_choice_rejects_out_of_bounds_correct_answer() -> void:
|
||||
var data := { "answers": ["a", "b"], "correct_answer": 5 }
|
||||
var errors := SemanticChecks.check_multiple_choice(data, "test")
|
||||
assert_eq(errors.size(), 1)
|
||||
|
||||
|
||||
func test_multiple_choice_accepts_valid_index() -> void:
|
||||
var data := { "answers": ["a", "b"], "correct_answer": 1 }
|
||||
assert_eq(SemanticChecks.check_multiple_choice(data, "test"), [])
|
||||
|
||||
|
||||
func test_sentence_correction_requires_at_least_one_error_token() -> void:
|
||||
var data := { "tokens": [{ "text": "Les", "correct": true }] }
|
||||
var errors := SemanticChecks.check_sentence_correction(data, "test")
|
||||
assert_eq(errors.size(), 1)
|
||||
|
||||
|
||||
func test_sentence_correction_requires_expected_on_error_tokens() -> void:
|
||||
var data := { "tokens": [{ "text": "petit", "correct": false }] }
|
||||
var errors := SemanticChecks.check_sentence_correction(data, "test")
|
||||
assert_eq(errors.size(), 1)
|
||||
assert_string_contains(errors[0], "expected")
|
||||
|
||||
|
||||
func test_dictation_word_count_must_match_target_text() -> void:
|
||||
var data := {
|
||||
"target_text": "Les petits chats dorment.",
|
||||
"words": [{ "text": "Les" }, { "text": "petits" }],
|
||||
}
|
||||
var errors := SemanticChecks.check_dictation(data, "test")
|
||||
assert_eq(errors.size(), 1)
|
||||
|
||||
|
||||
func test_dictation_accepts_matching_word_count() -> void:
|
||||
var data := {
|
||||
"target_text": "Les petits chats dorment.",
|
||||
"words": [
|
||||
{ "text": "Les" }, { "text": "petits" }, { "text": "chats" }, { "text": "dorment." }
|
||||
],
|
||||
}
|
||||
assert_eq(SemanticChecks.check_dictation(data, "test"), [])
|
||||
Reference in New Issue
Block a user