Add functional simulation question review

This commit is contained in:
hz
2026-07-14 17:49:23 -05:00
parent 3e39a4ffce
commit 705f079997
13 changed files with 551 additions and 32 deletions
+9 -29
View File
@@ -6,12 +6,12 @@ var main: Control
var score_label: Label
var summary_label: Label
var category_list: VBoxContainer
var review_list: VBoxContainer
var outcome_score: SpinBox
var outcome_date: LineEdit
var outcome_consent: CheckBox
var outcome_status: Label
var outcome_delete_button: Button
var current_simulation := {}
func _ready() -> void:
@@ -42,13 +42,13 @@ func _ready() -> void:
content.add_child(category_heading)
category_list = VBoxContainer.new()
content.add_child(category_list)
var review_heading := Label.new()
review_heading.text = "Answer review"
Style.set_label(review_heading, 22, Style.TEXT)
content.add_child(review_heading)
review_list = VBoxContainer.new()
review_list.add_theme_constant_override("separation", 8)
content.add_child(review_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", current_simulation))
content.add_child(review_button)
var outcome_heading := Label.new()
outcome_heading.text = "Help calibrate future predictions"
@@ -102,6 +102,7 @@ func _ready() -> void:
func on_show(payload: Variant = null) -> void:
var simulation: Dictionary = payload if typeof(payload) == TYPE_DICTIONARY else ExamSimulationService.simulation
current_simulation = simulation
var score: Dictionary = simulation.get("score", {})
var predicted := int(score.get("predictedScore", 0))
var low := int(score.get("rangeLow", 0))
@@ -117,30 +118,9 @@ func on_show(payload: Variant = null) -> void:
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)
_build_review(simulation)
ExamSimulationService.load_outcome()
func _build_review(simulation: Dictionary) -> void:
_clear(review_list)
var responses := {}
for response in simulation.get("responses", []):
responses[str(response.get("questionExternalId", ""))] = response
for raw_question in simulation.get("reviewQuestions", []):
if typeof(raw_question) != TYPE_DICTIONARY:
continue
var question: Dictionary = raw_question
var id := str(question.get("externalId", ""))
var selected := str(responses.get(id, {}).get("choiceId", ""))
var correct := str(question.get("correctChoiceId", ""))
var item := RichTextLabel.new()
item.bbcode_enabled = true
item.fit_content = true
item.custom_minimum_size = Vector2(0, 84)
item.text = "[b]%s[/b] %s\nSelected: %s | Correct: %s\n%s" % ["CORRECT" if selected == correct else "MISS", str(question.get("leadIn", "")), selected if selected != "" else "Unanswered", correct, str(question.get("explanation", ""))]
review_list.add_child(item)
func _clear(container: Control) -> void:
for child in container.get_children():
child.queue_free()