Count up question bank answer timer

This commit is contained in:
hz
2026-07-18 15:14:48 -05:00
parent c8c877a3a5
commit 102933db44
4 changed files with 128 additions and 17 deletions
+29 -15
View File
@@ -986,8 +986,7 @@ func _load_question() -> void:
timer_footer.visible = show_timer
if show_timer:
if BlockSessionService.session_kind == "core":
var core_seconds := int(ceil(BlockSessionService.core_current_target_seconds - BlockSessionService.get_current_elapsed_seconds()))
_set_timer_display(maxi(0, core_seconds))
_set_timer_display(int(floor(BlockSessionService.get_core_question_total_elapsed_seconds())))
else:
_set_timer_display(int(ceil(BlockSessionService.seconds_remaining)))
_update_timer_bar()
@@ -1297,9 +1296,7 @@ func _show_answer_review() -> void:
_show_references(BlockSessionService.get_current_question().get("references", []))
_ensure_answer_review_followups()
_render_answer_review_sections()
timer_bar.visible = false
timer_label.visible = false
timer_footer.visible = false
_set_answer_review_timer_visibility()
next_button.text = "Next"
next_button.disabled = false
if skip_button != null:
@@ -1309,6 +1306,15 @@ func _show_answer_review() -> void:
question_scroll.call_deferred("ensure_control_visible", explanation_label)
func _set_answer_review_timer_visibility() -> void:
var keep_core_timer := BlockSessionService.session_kind == "core"
timer_bar.visible = keep_core_timer
timer_label.visible = keep_core_timer
timer_footer.visible = keep_core_timer
if keep_core_timer:
_update_timer_bar()
func _show_explanation() -> void:
var question := BlockSessionService.get_current_question()
for button in choice_buttons:
@@ -1619,19 +1625,27 @@ func _exit_run() -> void:
func _update_timer_bar() -> void:
if timer_bar == null:
return
var ratio := BlockSessionService.get_session_timer_ratio()
var is_core_timer := BlockSessionService.session_kind == "core"
var ratio := BlockSessionService.get_core_question_elapsed_ratio() if is_core_timer else BlockSessionService.get_session_timer_ratio()
timer_bar.value = ratio * 100.0
if BlockSessionService.session_kind == "core" and timer_label.visible:
var remaining := int(ceil(BlockSessionService.core_current_target_seconds - BlockSessionService.get_current_elapsed_seconds()))
_set_timer_display(maxi(0, remaining))
if is_core_timer and timer_label.visible:
_set_timer_display(int(floor(BlockSessionService.get_core_question_total_elapsed_seconds())))
var color_state := "blue"
var fill_color := Brand.ROYAL_BLUE
if ratio < 0.25:
color_state = "red"
fill_color = Style.RED
elif ratio <= 0.5:
color_state = "amber"
fill_color = Style.AMBER
if is_core_timer:
if ratio >= 1.0:
color_state = "red"
fill_color = Style.RED
elif ratio >= 0.75:
color_state = "amber"
fill_color = Style.AMBER
else:
if ratio < 0.25:
color_state = "red"
fill_color = Style.RED
elif ratio <= 0.5:
color_state = "amber"
fill_color = Style.AMBER
if color_state != timer_color_state:
timer_color_state = color_state
timer_bar.add_theme_stylebox_override("fill", Style.button_box(fill_color, fill_color))