Add functional simulation question review
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
extends SceneTree
|
||||
|
||||
var failures := 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var review_script = load("res://scripts/ui/simulation_review.gd")
|
||||
_assert(review_script._matches_filter("all", "A", "B", false), "all should include every response")
|
||||
_assert(review_script._matches_filter("incorrect", "A", "B", false), "incorrect should include wrong answers")
|
||||
_assert(not review_script._matches_filter("incorrect", "", "B", false), "incorrect should exclude unanswered questions")
|
||||
_assert(review_script._matches_filter("unanswered", "", "B", false), "unanswered should include blank responses")
|
||||
_assert(review_script._matches_filter("flagged", "B", "B", true), "flagged should include flagged correct responses")
|
||||
_assert(not review_script._matches_filter("flagged", "A", "B", false), "flagged should exclude unflagged responses")
|
||||
var review = review_script.new()
|
||||
get_root().add_child(review)
|
||||
await process_frame
|
||||
review.on_show({
|
||||
"reviewQuestions": [
|
||||
{"externalId": "q1", "stem": "Stem one", "leadIn": "Lead one", "choices": [{"id": "A", "text": "One"}, {"id": "B", "text": "Two"}], "correctChoiceId": "A", "choiceExplanations": {"A": "Correct", "B": "Wrong"}, "explanation": "Overall", "labs": [], "media": [], "references": []},
|
||||
{"externalId": "q2", "stem": "Stem two", "leadIn": "Lead two", "choices": [{"id": "A", "text": "One"}, {"id": "B", "text": "Two"}], "correctChoiceId": "B", "choiceExplanations": {}, "explanation": "Overall", "labs": [], "media": [], "references": []}
|
||||
],
|
||||
"responses": [{"questionExternalId": "q1", "choiceId": "B", "flagged": true}]
|
||||
})
|
||||
_assert(review.filtered_indices.size() == 2, "all filter should build a complete review set")
|
||||
review._set_filter("incorrect")
|
||||
_assert(review.filtered_indices == [0], "incorrect filter should retain only answered misses")
|
||||
review._set_filter("unanswered")
|
||||
_assert(review.filtered_indices == [1], "unanswered filter should retain blank responses")
|
||||
await process_frame
|
||||
review.queue_free()
|
||||
await process_frame
|
||||
quit(1 if failures > 0 else 0)
|
||||
|
||||
|
||||
func _assert(condition: bool, message: String) -> void:
|
||||
if condition:
|
||||
return
|
||||
failures += 1
|
||||
push_error(message)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dn2mvv1kmhup3
|
||||
Reference in New Issue
Block a user