Implement persistent review queue

This commit is contained in:
hz
2026-07-19 12:51:24 -05:00
parent 1bfb3f5347
commit 7508d4fe1d
20 changed files with 1155 additions and 20 deletions
+68 -7
View File
@@ -168,6 +168,12 @@ func _ready() -> void:
BookmarkService.question_loaded.connect(_on_bookmark_question_loaded)
if not BookmarkService.question_failed.is_connected(_on_bookmark_question_failed):
BookmarkService.question_failed.connect(_on_bookmark_question_failed)
if not ReviewQueueService.question_loaded.is_connected(_on_review_question_loaded):
ReviewQueueService.question_loaded.connect(_on_review_question_loaded)
if not ReviewQueueService.question_failed.is_connected(_on_review_question_failed):
ReviewQueueService.question_failed.connect(_on_review_question_failed)
if not ReviewQueueService.pass_completed.is_connected(_on_review_pass_completed):
ReviewQueueService.pass_completed.connect(_on_review_pass_completed)
question_card = PanelContainer.new()
question_card.size_flags_horizontal = Control.SIZE_EXPAND_FILL
@@ -1036,18 +1042,21 @@ func _load_question() -> void:
next_button.text = "Submit"
next_button.disabled = true
skip_button.disabled = false
skip_button.visible = true
skip_button.visible = BlockSessionService.session_kind != "review"
skip_button.text = "Skip"
report_button.visible = BlockSessionService.session_kind != "simulation"
var question := BlockSessionService.get_current_question()
if question.is_empty():
main.show_screen("bookmarks" if BlockSessionService.session_kind == "bookmark" else "selection", "exam" if BlockSessionService.session_kind == "core" else "step3")
if BlockSessionService.session_kind == "review":
main.show_screen("dashboard")
else:
main.show_screen("bookmarks" if BlockSessionService.session_kind == "bookmark" else "selection", "exam" if BlockSessionService.session_kind == "core" else "step3")
return
BookmarkService.observe_question(question)
progress_button.text = _question_progress_text()
progress_button.disabled = BlockSessionService.session_kind in ["core", "bookmark"]
progress_button.tooltip_text = "" if BlockSessionService.session_kind in ["core", "bookmark"] else "Open question navigator"
progress_button.disabled = BlockSessionService.session_kind in ["core", "bookmark", "review"]
progress_button.tooltip_text = "" if BlockSessionService.session_kind in ["core", "bookmark", "review"] else "Open question navigator"
var show_timer := _is_session_timer_visible()
timer_label.visible = show_timer
timer_bar.visible = show_timer
@@ -1291,7 +1300,7 @@ func _submit_or_next() -> void:
if selected_choice == "":
return
var question_id_for_attempt := str(BlockSessionService.get_current_question().get("id", ""))
if BlockSessionService.session_kind in ["core", "bookmark"]:
if BlockSessionService.session_kind in ["core", "bookmark", "review"]:
_collapse_resolved_followups()
var attempted_choice := selected_choice
if BlockSessionService.session_kind == "core":
@@ -1301,10 +1310,22 @@ func _submit_or_next() -> void:
_presented_choice_ids(),
int(floor(BlockSessionService.get_core_question_total_elapsed_seconds()))
)
var result := BlockSessionService.submit_core_attempt(selected_choice, eliminated, flagged) if BlockSessionService.session_kind == "core" else BlockSessionService.submit_bookmark_attempt(selected_choice, eliminated, flagged)
var result: Dictionary
if BlockSessionService.session_kind == "core":
result = BlockSessionService.submit_core_attempt(selected_choice, eliminated, flagged)
elif BlockSessionService.session_kind == "bookmark":
result = BlockSessionService.submit_bookmark_attempt(selected_choice, eliminated, flagged)
else:
result = BlockSessionService.submit_review_attempt(selected_choice, eliminated, flagged)
if result.is_empty():
return
var answer: Dictionary = result.get("answer", {})
if BlockSessionService.session_kind == "review" and bool(result.get("first_submission", false)):
ReviewQueueService.record_first_submission(
BlockSessionService.get_current_question(),
attempted_choice,
_presented_choice_ids(),
int(floor(float(answer.get("elapsed_seconds", 0.0)))))
if bool(result.get("is_correct", false)):
current_answer = answer
_update_question_elo_label(true)
@@ -1339,6 +1360,11 @@ func _submit_or_next() -> void:
BookmarkService.next_practice()
else:
_finish()
elif BlockSessionService.session_kind == "review":
awaiting_next_question = true
next_button.text = "Loading..."
next_button.disabled = true
ReviewQueueService.load_next()
else:
_advance_or_finish()
@@ -1708,6 +1734,10 @@ func _finish() -> void:
BlockSessionService.finish_block()
main.show_screen("selection", "exam")
return
if BlockSessionService.session_kind == "review":
BlockSessionService.finish_block()
main.show_screen("review_queue_results", ReviewQueueService.get_summary())
return
var results := BlockSessionService.finish_block()
main.show_screen("review", results)
@@ -1717,6 +1747,11 @@ func _exit_run() -> void:
BlockSessionService.finish_block()
main.show_screen("bookmarks")
return
if BlockSessionService.session_kind == "review":
BlockSessionService.finish_block()
DashboardService.refresh()
main.show_screen("dashboard")
return
var was_core_run := BlockSessionService.session_kind == "core"
BlockSessionService.resume_current_question_timer()
BlockSessionService.finish_block()
@@ -1973,6 +2008,32 @@ func _on_bookmark_question_failed(message: String) -> void:
next_button.tooltip_text = message
func _on_review_question_loaded(question: Dictionary) -> void:
if not visible or BlockSessionService.session_kind != "review" or not awaiting_next_question:
return
awaiting_next_question = false
if BlockSessionService.replace_review_question(question):
_load_question()
UISoundService.play_sound("question")
func _on_review_question_failed(message: String) -> void:
if not visible or BlockSessionService.session_kind != "review":
return
awaiting_next_question = false
next_button.text = "Retry"
next_button.disabled = false
next_button.tooltip_text = message
func _on_review_pass_completed(summary: Dictionary) -> void:
if not visible or BlockSessionService.session_kind != "review":
return
awaiting_next_question = false
BlockSessionService.finish_block()
main.show_screen("review_queue_results", summary)
func refresh_theme_controls() -> void:
if media_viewer_background != null:
media_viewer_background.color = Style.BACKGROUND
@@ -3458,7 +3519,7 @@ func _refresh_nav_palette() -> void:
for child in nav_palette.get_children():
child.queue_free()
if BlockSessionService.session_kind == "core":
if BlockSessionService.session_kind in ["core", "review"]:
return
for index in range(BlockSessionService.active_questions.size()):