Files
step3/scripts/ui/simulation_results.gd
T

95 lines
4.0 KiB
GDScript

extends VBoxContainer
const Style := preload("res://scripts/ui/ui_style.gd")
var main: Control
var score_label: Label
var summary_label: Label
var category_list: VBoxContainer
var current_simulation := {}
var return_screen := "selection"
var done_button: Button
func _ready() -> void:
set_anchors_preset(Control.PRESET_FULL_RECT)
add_theme_constant_override("separation", 12)
var eyebrow := Label.new()
eyebrow.text = "STEP 3 DAY 1 SIMULATION COMPLETE"
Style.set_label(eyebrow, 14, Style.CYAN)
add_child(eyebrow)
score_label = Label.new()
Style.set_label(score_label, 36, Style.LIME)
add_child(score_label)
summary_label = Label.new()
summary_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
Style.set_label(summary_label, 17, Style.TEXT)
add_child(summary_label)
var scroll := ScrollContainer.new()
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
add_child(scroll)
var content := VBoxContainer.new()
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
content.add_theme_constant_override("separation", 10)
scroll.add_child(content)
var category_heading := Label.new()
category_heading.text = "Performance by content area"
Style.set_label(category_heading, 22, Style.TEXT)
content.add_child(category_heading)
category_list = VBoxContainer.new()
content.add_child(category_list)
var review_button := Button.new()
review_button.text = "Review Questions"
review_button.custom_minimum_size = Vector2(240, 50)
review_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
Style.style_primary_button(review_button)
review_button.pressed.connect(func(): main.show_screen("simulation_review", {"simulation": current_simulation, "return_screen": return_screen}))
content.add_child(review_button)
done_button = Button.new()
done_button.text = "Return to study modes"
done_button.custom_minimum_size = Vector2(240, 50)
done_button.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
Style.style_primary_button(done_button)
done_button.pressed.connect(_return_from_results)
add_child(done_button)
func on_show(payload: Variant = null) -> void:
var wrapper: Dictionary = payload if typeof(payload) == TYPE_DICTIONARY else {}
var simulation: Dictionary = wrapper.get("simulation", wrapper) if not wrapper.is_empty() else ExamSimulationService.simulation
return_screen = str(wrapper.get("return_screen", "selection"))
done_button.text = "Return to simulation history" if return_screen == "simulation_history" else "Return to study modes"
current_simulation = simulation
var score: Dictionary = simulation.get("score", {})
var predicted := int(score.get("predictedScore", 0))
var low := int(score.get("rangeLow", 0))
var high := int(score.get("rangeHigh", 0))
var probability := int(round(float(score.get("passProbability", 0.0)) * 100.0))
var raw_accuracy := float(score.get("rawAccuracy", 0.0)) * 100.0
var adjusted_accuracy := float(score.get("difficultyAdjustedAccuracy", 0.0)) * 100.0
score_label.text = "Provisional Step 3 estimate: %d (%d-%d)" % [predicted, low, high]
summary_label.text = "%d/%d correct (%.1f%%) | Difficulty-adjusted accuracy: %.1f%%\nHeuristic probability of provisional score >=200: %d%% | Previously seen questions: %d\nThis transparent, unvalidated educational heuristic is not an official USMLE or NBME score and excludes CCS performance." % [
int(score.get("correct", 0)), int(score.get("total", 0)), raw_accuracy, adjusted_accuracy,
probability, int(score.get("seenCount", 0))]
_clear(category_list)
for category in score.get("categories", {}):
var value: Dictionary = score["categories"][category]
var label := Label.new()
label.text = "%s: %d/%d" % [category, int(value.get("correct", 0)), int(value.get("total", 0))]
Style.set_label(label, 16, Style.TEXT)
category_list.add_child(label)
func _return_from_results() -> void:
if return_screen == "simulation_history":
main.show_screen("simulation_history", "preserve")
else:
main.show_screen("selection", "step3")
func _clear(container: Control) -> void:
for child in container.get_children():
child.queue_free()