Add full-length Step 3 Day 1 simulation
This commit is contained in:
@@ -11,7 +11,9 @@ var question_bank_button: Button
|
||||
var bank_status_label: Label
|
||||
var bank_error_label: Label
|
||||
var retry_button: Button
|
||||
var image_question_test_link: LinkButton
|
||||
var simulation_button: Button
|
||||
var simulation_status_label: Label
|
||||
var pending_simulation_launch := false
|
||||
var current_stage := "exam"
|
||||
var pending_question_bank_launch := false
|
||||
|
||||
@@ -24,6 +26,12 @@ func _ready() -> void:
|
||||
QuestionBankService.questions_changed.connect(_on_questions_changed)
|
||||
if not QuestionBankService.questions_load_failed.is_connected(_on_questions_load_failed):
|
||||
QuestionBankService.questions_load_failed.connect(_on_questions_load_failed)
|
||||
if not ExamSimulationService.readiness_changed.is_connected(_refresh_simulation_state):
|
||||
ExamSimulationService.readiness_changed.connect(_refresh_simulation_state)
|
||||
if not ExamSimulationService.state_changed.is_connected(_on_simulation_state_changed):
|
||||
ExamSimulationService.state_changed.connect(_on_simulation_state_changed)
|
||||
if not ExamSimulationService.request_failed.is_connected(_on_simulation_failed):
|
||||
ExamSimulationService.request_failed.connect(_on_simulation_failed)
|
||||
|
||||
_build_exam_view()
|
||||
_build_mode_view()
|
||||
@@ -36,6 +44,7 @@ func on_show(payload: Variant = null) -> void:
|
||||
elif str(payload) == "exam":
|
||||
_show_stage("exam")
|
||||
_refresh_bank_state()
|
||||
ExamSimulationService.load_readiness()
|
||||
|
||||
|
||||
func on_hide() -> void:
|
||||
@@ -135,6 +144,22 @@ func _build_mode_view() -> void:
|
||||
dynamic_button.disabled = true
|
||||
mode_grid.add_child(dynamic_button)
|
||||
|
||||
simulation_button = Button.new()
|
||||
simulation_button.text = "Step 3 Day 1 Simulation\n232 questions | Checking readiness"
|
||||
simulation_button.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
simulation_button.custom_minimum_size = Vector2(360, 150)
|
||||
simulation_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
simulation_button.add_theme_font_size_override("font_size", 20)
|
||||
Style.style_primary_button(simulation_button)
|
||||
simulation_button.disabled = true
|
||||
simulation_button.pressed.connect(_select_simulation)
|
||||
mode_grid.add_child(simulation_button)
|
||||
|
||||
simulation_status_label = Label.new()
|
||||
simulation_status_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
Style.set_label(simulation_status_label, 15, Style.MUTED)
|
||||
mode_view.add_child(simulation_status_label)
|
||||
|
||||
bank_status_label = Label.new()
|
||||
bank_status_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
Style.set_label(bank_status_label, 16, Style.CYAN)
|
||||
@@ -153,15 +178,6 @@ func _build_mode_view() -> void:
|
||||
retry_button.pressed.connect(_retry_question_bank)
|
||||
mode_view.add_child(retry_button)
|
||||
|
||||
image_question_test_link = LinkButton.new()
|
||||
image_question_test_link.text = "Temporary: test a question with an image"
|
||||
image_question_test_link.tooltip_text = "Load a random published question that includes media"
|
||||
image_question_test_link.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
image_question_test_link.add_theme_color_override("font_color", Style.CYAN)
|
||||
image_question_test_link.add_theme_color_override("font_hover_color", Style.MAGENTA)
|
||||
image_question_test_link.pressed.connect(_select_image_question_for_testing)
|
||||
mode_view.add_child(image_question_test_link)
|
||||
|
||||
var spacer := Control.new()
|
||||
spacer.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
mode_view.add_child(spacer)
|
||||
@@ -206,12 +222,6 @@ func _retry_question_bank() -> void:
|
||||
_refresh_bank_state()
|
||||
|
||||
|
||||
func _select_image_question_for_testing() -> void:
|
||||
pending_question_bank_launch = true
|
||||
QuestionBankService.load_image_question_for_testing()
|
||||
_refresh_bank_state()
|
||||
|
||||
|
||||
func _on_questions_changed() -> void:
|
||||
_refresh_bank_state()
|
||||
if pending_question_bank_launch and visible and current_stage == "step3" and QuestionBankService.load_state == "ready":
|
||||
@@ -224,12 +234,63 @@ func _on_questions_load_failed(_message: String) -> void:
|
||||
_refresh_bank_state()
|
||||
|
||||
|
||||
func _select_simulation() -> void:
|
||||
pending_simulation_launch = true
|
||||
simulation_button.disabled = true
|
||||
if bool(ExamSimulationService.readiness.get("hasActiveSimulation", false)):
|
||||
ExamSimulationService.load_active()
|
||||
else:
|
||||
ExamSimulationService.create_simulation()
|
||||
|
||||
|
||||
func _on_simulation_state_changed() -> void:
|
||||
_refresh_simulation_state()
|
||||
if not pending_simulation_launch or ExamSimulationService.simulation.is_empty():
|
||||
return
|
||||
pending_simulation_launch = false
|
||||
var state := str(ExamSimulationService.simulation.get("state", ""))
|
||||
if state == "block_active":
|
||||
_launch_simulation_block()
|
||||
elif state == "completed":
|
||||
main.show_screen("simulation_results", ExamSimulationService.simulation)
|
||||
else:
|
||||
main.show_screen("simulation_break")
|
||||
|
||||
|
||||
func _launch_simulation_block() -> void:
|
||||
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_simulation_failed(message: String) -> void:
|
||||
pending_simulation_launch = false
|
||||
if simulation_status_label != null:
|
||||
simulation_status_label.text = message
|
||||
_refresh_simulation_state()
|
||||
|
||||
|
||||
func _refresh_simulation_state() -> void:
|
||||
if simulation_button == null:
|
||||
return
|
||||
var ready := bool(ExamSimulationService.readiness.get("ready", false))
|
||||
var active := bool(ExamSimulationService.readiness.get("hasActiveSimulation", false)) or not ExamSimulationService.simulation.is_empty() and str(ExamSimulationService.simulation.get("state", "")) in ["between_blocks", "block_active"]
|
||||
var available := int(ExamSimulationService.readiness.get("availableQuestions", 0))
|
||||
simulation_button.disabled = pending_simulation_launch or (not ready and not active)
|
||||
simulation_button.text = "Resume Step 3 Day 1 Simulation\nProgress is saved between blocks" if active else "Step 3 Day 1 Simulation\n232 questions | %s" % ("Available" if ready else "%d/232 ready" % available)
|
||||
if simulation_status_label != null and not pending_simulation_launch:
|
||||
simulation_status_label.text = "Full-length, 12-block simulation. Predicted scores are provisional and exclude CCS." if ready or active else "The simulation unlocks when at least 232 published questions are available."
|
||||
|
||||
|
||||
func _refresh_bank_state() -> void:
|
||||
if question_bank_button == null:
|
||||
return
|
||||
var state := QuestionBankService.load_state
|
||||
question_bank_button.disabled = pending_question_bank_launch
|
||||
image_question_test_link.disabled = pending_question_bank_launch
|
||||
retry_button.visible = state == "failed" or state == "retrying"
|
||||
retry_button.disabled = state == "retrying"
|
||||
bank_error_label.text = QuestionBankService.last_error if state == "failed" or state == "retrying" else ""
|
||||
|
||||
Reference in New Issue
Block a user