84 lines
2.9 KiB
GDScript
84 lines
2.9 KiB
GDScript
extends Control
|
|
|
|
const Brand := preload("res://scripts/ui/medmind_style.gd")
|
|
|
|
var main
|
|
var status_label: Label
|
|
var start_button: Button
|
|
|
|
|
|
func _ready() -> void:
|
|
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
var center := CenterContainer.new()
|
|
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
add_child(center)
|
|
var card := VBoxContainer.new()
|
|
card.custom_minimum_size = Vector2(620, 0)
|
|
card.add_theme_constant_override("separation", 18)
|
|
center.add_child(card)
|
|
var title := Label.new()
|
|
title.text = "Dynamic Questions"
|
|
title.add_theme_font_override("font", Brand.font)
|
|
title.add_theme_font_size_override("font_size", 34)
|
|
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
card.add_child(title)
|
|
var description := Label.new()
|
|
description.text = "Endless, data-driven Step 3 practice. Clinical values and distractors vary while each tested objective stays medically invariant."
|
|
description.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
description.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
card.add_child(description)
|
|
status_label = Label.new()
|
|
status_label.text = "Checking available objectives..."
|
|
status_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
card.add_child(status_label)
|
|
start_button = Button.new()
|
|
start_button.text = "Start Dynamic Questions"
|
|
start_button.custom_minimum_size = Vector2(0, 52)
|
|
start_button.disabled = true
|
|
start_button.pressed.connect(_start)
|
|
card.add_child(start_button)
|
|
DynamicQuestionService.status_loaded.connect(_on_status)
|
|
DynamicQuestionService.question_loaded.connect(_on_question)
|
|
DynamicQuestionService.request_failed.connect(_on_failed)
|
|
|
|
|
|
func on_show(_payload: Variant = null) -> void:
|
|
start_button.disabled = true
|
|
status_label.text = "Checking available objectives..."
|
|
DynamicQuestionService.load_status()
|
|
|
|
|
|
func _on_status(status: Dictionary) -> void:
|
|
var available := bool(status.get("available", false))
|
|
var count := int(status.get("publishedObjectives", 0))
|
|
var attempts := int(status.get("totalAttempts", 0))
|
|
var due := int(status.get("reviewsDue", 0))
|
|
var coverage := 0
|
|
if count > 0:
|
|
coverage = int(round(float(status.get("attemptedObjectives", 0)) * 100.0 / float(count)))
|
|
status_label.text = "%d objectives | %d%% explored | %d reviews due | %d attempts" % [
|
|
count, coverage, due, attempts]
|
|
start_button.disabled = not available
|
|
if not available:
|
|
status_label.text = "Dynamic question content has not been published yet."
|
|
|
|
|
|
func _start() -> void:
|
|
start_button.disabled = true
|
|
start_button.text = "Generating..."
|
|
DynamicQuestionService.reset_run()
|
|
DynamicQuestionService.load_next()
|
|
|
|
|
|
func _on_question(question: Dictionary) -> void:
|
|
start_button.text = "Start Dynamic Questions"
|
|
start_button.disabled = false
|
|
if BlockSessionService.start_dynamic_question(question):
|
|
main.show_screen("player")
|
|
|
|
|
|
func _on_failed(message: String) -> void:
|
|
start_button.text = "Try Again"
|
|
start_button.disabled = false
|
|
status_label.text = message
|