Count up question bank answer timer
This commit is contained in:
@@ -28,6 +28,29 @@ func _initialize() -> void:
|
||||
service.session_initial_seconds = 900.0
|
||||
service.seconds_remaining = 450.0
|
||||
_assert(is_equal_approx(service.get_session_timer_ratio(), 0.5), "timed block progress should use the full session duration")
|
||||
service.session_kind = "core"
|
||||
service.core_question_display_target_seconds = 100.0
|
||||
service.core_question_total_elapsed_seconds = 25.0
|
||||
service.core_question_total_active_since = 0.0
|
||||
_assert(is_equal_approx(service.get_core_question_total_elapsed_seconds(), 25.0), "core question timer should expose cumulative elapsed time")
|
||||
_assert(is_equal_approx(service.get_core_question_elapsed_ratio(), 0.25), "core question progress should fill toward its original target")
|
||||
service._start_core_retry_window()
|
||||
_assert(is_equal_approx(service.get_core_question_total_elapsed_seconds(), 25.0), "wrong-answer retry windows should not reset cumulative question time")
|
||||
service.core_question_total_active_since = 100.0
|
||||
service.core_question_total_elapsed_seconds = 4.0
|
||||
service._pause_core_question_total_timer(106.0)
|
||||
_assert(is_equal_approx(service.get_core_question_total_elapsed_seconds(), 10.0), "pausing should preserve accumulated question time")
|
||||
service.core_question_total_elapsed_seconds = 0.0
|
||||
service.core_question_total_active_since = 0.001
|
||||
service._freeze_core_question_total_timer()
|
||||
var frozen_elapsed: float = service.get_core_question_total_elapsed_seconds()
|
||||
OS.delay_msec(10)
|
||||
_assert(is_equal_approx(service.get_core_question_total_elapsed_seconds(), frozen_elapsed), "freezing should stop cumulative question time")
|
||||
var resume_now := Time.get_ticks_msec() / 1000.0
|
||||
service.current_question_started_at = maxf(0.001, resume_now - 5.0)
|
||||
service.current_question_pause_started_at = maxf(0.001, resume_now - 0.001)
|
||||
service.resume_current_question_timer()
|
||||
_assert(service.core_question_total_active_since == 0.0, "a completed core question timer should not restart")
|
||||
service.free()
|
||||
quit(1 if failures > 0 else 0)
|
||||
|
||||
|
||||
@@ -21,10 +21,39 @@ func _initialize() -> void:
|
||||
_test_feedback_form_validation()
|
||||
_test_revisitable_navigation_prefers_unanswered_questions()
|
||||
_test_submit_styles_keep_stable_geometry()
|
||||
_test_core_timer_counts_up_and_remains_visible()
|
||||
await _test_player_runtime_construction()
|
||||
quit(1 if failures > 0 else 0)
|
||||
|
||||
|
||||
func _test_core_timer_counts_up_and_remains_visible() -> void:
|
||||
var player = load("res://scripts/ui/question_player.gd").new()
|
||||
var block_service = root.get_node("BlockSessionService")
|
||||
player.timer_bar = ProgressBar.new()
|
||||
player.timer_label = Label.new()
|
||||
player.timer_footer = HBoxContainer.new()
|
||||
player.timer_color_state = ""
|
||||
block_service.session_kind = "core"
|
||||
block_service.core_question_display_target_seconds = 100.0
|
||||
block_service.core_question_total_elapsed_seconds = 75.0
|
||||
block_service.core_question_total_active_since = 0.0
|
||||
player._set_answer_review_timer_visibility()
|
||||
_assert(player.timer_footer.visible and player.timer_bar.visible and player.timer_label.visible, "core timer should remain visible during correct-answer review")
|
||||
_assert(is_equal_approx(player.timer_bar.value, 75.0), "core timer bar should fill with elapsed progress")
|
||||
_assert(player.timer_label.text == "01:15", "core timer should display cumulative elapsed time")
|
||||
_assert(player.timer_color_state == "amber", "core timer should warn when approaching its target")
|
||||
block_service.core_question_total_elapsed_seconds = 110.0
|
||||
player._update_timer_bar()
|
||||
_assert(is_equal_approx(player.timer_bar.value, 100.0) and player.timer_color_state == "red", "core timer should remain full and red after exceeding its target")
|
||||
block_service.session_kind = "block"
|
||||
player._set_answer_review_timer_visibility()
|
||||
_assert(not player.timer_footer.visible, "non-core answer review should retain its existing hidden timer")
|
||||
player.timer_bar.free()
|
||||
player.timer_label.free()
|
||||
player.timer_footer.free()
|
||||
player.free()
|
||||
|
||||
|
||||
func _test_reference_normalization() -> void:
|
||||
var service = load("res://scripts/autoload/question_bank_service.gd").new()
|
||||
var references: Array = service._normalize_references([{
|
||||
|
||||
Reference in New Issue
Block a user