Add full-length Step 3 Day 1 simulation

This commit is contained in:
hz
2026-07-14 16:54:11 -05:00
parent 8aaf7d61e9
commit 206a5c0124
19 changed files with 1520 additions and 32 deletions
+125
View File
@@ -0,0 +1,125 @@
extends VBoxContainer
const Style := preload("res://scripts/ui/ui_style.gd")
var main: Control
var title: Label
var detail: Label
var start_button: Button
var abandon_button: Button
var error_label: Label
var abandon_armed := false
func _ready() -> void:
set_anchors_preset(Control.PRESET_FULL_RECT)
add_theme_constant_override("separation", 18)
if not ExamSimulationService.state_changed.is_connected(_on_state_changed):
ExamSimulationService.state_changed.connect(_on_state_changed)
if not ExamSimulationService.request_failed.is_connected(_on_failed):
ExamSimulationService.request_failed.connect(_on_failed)
var eyebrow := Label.new()
eyebrow.text = "STEP 3 DAY 1 SIMULATION"
Style.set_label(eyebrow, 14, Style.CYAN)
add_child(eyebrow)
title = Label.new()
Style.set_label(title, 34, Style.TEXT)
add_child(title)
detail = Label.new()
detail.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
Style.set_label(detail, 18, Style.MUTED)
add_child(detail)
start_button = Button.new()
start_button.custom_minimum_size = Vector2(240, 54)
start_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
Style.style_primary_button(start_button)
start_button.pressed.connect(_start_block)
add_child(start_button)
abandon_button = Button.new()
abandon_button.text = "Abandon simulation"
abandon_button.custom_minimum_size = Vector2(240, 44)
abandon_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
Style.style_chip(abandon_button, Style.RED)
abandon_button.pressed.connect(_abandon)
add_child(abandon_button)
error_label = Label.new()
error_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
Style.set_label(error_label, 16, Style.RED)
add_child(error_label)
var note := Label.new()
note.text = "Each block runs for 30 minutes. You may review and change answers within the active block, but closed blocks cannot be reopened. Leaving during a block does not stop its server timer."
note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
Style.set_label(note, 16, Style.MUTED)
add_child(note)
var spacer := Control.new()
spacer.size_flags_vertical = Control.SIZE_EXPAND_FILL
add_child(spacer)
func on_show(_payload: Variant = null) -> void:
abandon_armed = false
_refresh()
func _refresh() -> void:
var block := int(ExamSimulationService.simulation.get("currentBlock", -1))
var break_seconds := int(ExamSimulationService.simulation.get("breakSecondsRemaining", 3300))
if block < 0:
title.text = "Foundations of Independent Practice"
detail.text = "232 questions across 12 timed blocks. Results and explanations remain hidden until the simulation is complete. Estimated break pool: %d minutes." % int(break_seconds / 60)
else:
title.text = "Block %d complete" % (block + 1)
detail.text = "%d of 12 blocks complete. Your progress is saved. Break pool: approximately %d minutes." % [block + 1, int(break_seconds / 60)]
start_button.text = "Start Block %d" % (block + 2)
start_button.disabled = ExamSimulationService.is_loading
abandon_button.text = "Confirm abandon" if abandon_armed else "Abandon simulation"
abandon_button.disabled = ExamSimulationService.is_loading
error_label.text = ""
func _start_block() -> void:
start_button.disabled = true
start_button.text = "Preparing..."
ExamSimulationService.start_next_block()
func _abandon() -> void:
if not abandon_armed:
abandon_armed = true
abandon_button.text = "Confirm abandon"
error_label.text = "This permanently closes the current simulation. Select Confirm abandon to continue."
return
abandon_button.disabled = true
ExamSimulationService.abandon()
func _on_state_changed() -> void:
if not visible:
return
if ExamSimulationService.simulation.is_empty():
main.show_screen("selection", "step3")
return
if str(ExamSimulationService.simulation.get("state", "")) != "block_active":
_refresh()
return
BlockSessionService.start_simulation_block(
ExamSimulationService.get_current_questions(),
int(ExamSimulationService.simulation.get("currentBlock", 0)),
int(ExamSimulationService.simulation.get("totalBlocks", 12)),
ExamSimulationService.get_block_deadline_unix())
BlockSessionService.restore_simulation_responses(ExamSimulationService.simulation.get("responses", []))
main.show_screen("player")
func _on_failed(message: String) -> void:
if not visible:
return
error_label.text = message
start_button.disabled = false
_refresh()