39 lines
1.4 KiB
GDScript
39 lines
1.4 KiB
GDScript
extends SceneTree
|
|
|
|
var failures := 0
|
|
|
|
|
|
func _initialize() -> void:
|
|
var service = load("res://scripts/autoload/block_session_service.gd").new()
|
|
var question := {
|
|
"id": "bookmark-test-question",
|
|
"system": "Test System",
|
|
"choices": [
|
|
{"id": "A", "text": "Correct"},
|
|
{"id": "B", "text": "Wrong"},
|
|
{"id": "C", "text": "Wrong"},
|
|
{"id": "D", "text": "Wrong"},
|
|
{"id": "E", "text": "Wrong"}
|
|
],
|
|
"correct_choice_id": "A"
|
|
}
|
|
_assert(service.start_bookmark_question(question), "bookmark session should start")
|
|
_assert(service.session_kind == "bookmark", "bookmark session should have its own kind")
|
|
var wrong: Dictionary = service.submit_bookmark_attempt("B", [], false)
|
|
_assert(not bool(wrong.get("is_correct", true)), "wrong bookmark attempts should remain retryable")
|
|
_assert(service.get_answer_for_index(0) == null, "wrong bookmark attempts should not finalize the question")
|
|
var correct: Dictionary = service.submit_bookmark_attempt("A", [], false)
|
|
_assert(bool(correct.get("is_correct", false)), "correct bookmark attempt should resolve")
|
|
_assert(service.get_answer_for_index(0) != null, "correct bookmark attempt should be retained for review")
|
|
var result: Dictionary = service.finish_block()
|
|
_assert(result.is_empty(), "bookmark sessions should not calculate progression rewards")
|
|
service.free()
|
|
quit(1 if failures > 0 else 0)
|
|
|
|
|
|
func _assert(condition: bool, message: String) -> void:
|
|
if condition:
|
|
return
|
|
failures += 1
|
|
push_error(message)
|