Author SHA1 Message Date
hz 6b2d8b6f81 Reduce answer review scroll redraws 2026-07-30 05:01:18 -05:00
2 changed files with 26 additions and 1 deletions
+11 -1
View File
@@ -60,6 +60,8 @@ var stem_plain_text := ""
var explanation_plain_text := ""
var highlight_drag_source := ""
var timer_color_state := ""
var last_timer_bar_value := -1.0
var last_timer_display_seconds := -1
var pending_correct_advance := false
var question_text_scale := 1.0
var presented_choices: Array = []
@@ -1268,6 +1270,8 @@ func _load_question() -> void:
flagged = false
selected_choice = ""
current_answer = {}
last_timer_bar_value = -1.0
last_timer_display_seconds = -1
flag_button.button_pressed = false
_refresh_toolbar_state()
_clear_answer_review()
@@ -2094,7 +2098,10 @@ func _update_timer_bar() -> void:
return
var is_core_timer := BlockSessionService.session_kind == "core"
var ratio := BlockSessionService.get_session_timer_ratio()
timer_bar.value = ratio * 100.0
var next_value := ratio * 100.0
if last_timer_bar_value < 0.0 or absf(next_value - last_timer_bar_value) >= 0.1:
last_timer_bar_value = next_value
timer_bar.value = next_value
if is_core_timer and timer_label.visible:
_set_timer_display(int(floor(BlockSessionService.get_core_question_total_elapsed_seconds())))
var color_state := "blue"
@@ -2114,6 +2121,9 @@ func _set_timer_display(total_seconds: int) -> void:
if timer_label == null:
return
var safe_seconds := maxi(0, total_seconds)
if safe_seconds == last_timer_display_seconds:
return
last_timer_display_seconds = safe_seconds
timer_label.text = "%02d:%02d" % [int(floor(float(safe_seconds) / 60.0)), safe_seconds % 60]
+15
View File
@@ -22,6 +22,7 @@ func _initialize() -> void:
_test_feedback_context_excludes_study_content()
_test_feedback_form_validation()
_test_revisitable_navigation_prefers_unanswered_questions()
_test_timer_text_avoids_redundant_frame_updates()
_test_submit_styles_keep_stable_geometry()
_test_core_timer_counts_up_and_remains_visible()
await _test_player_runtime_construction()
@@ -355,6 +356,20 @@ func _test_revisitable_navigation_prefers_unanswered_questions() -> void:
session.current_index = prior_index
func _test_timer_text_avoids_redundant_frame_updates() -> void:
var player = load("res://scripts/ui/question_player.gd").new()
player.timer_label = Label.new()
player._set_timer_display(65)
_assert(player.timer_label.text == "01:05", "timer should render a changed second")
player.timer_label.text = "unchanged"
player._set_timer_display(65)
_assert(player.timer_label.text == "unchanged", "timer should not rewrite its label every frame")
player._set_timer_display(66)
_assert(player.timer_label.text == "01:06", "timer should render the next changed second")
player.timer_label.free()
player.free()
func _test_player_runtime_construction() -> void:
var host := Control.new()
root.add_child(host)