Add SUPER exam results preview
This commit is contained in:
@@ -13,6 +13,7 @@ var bank_error_label: Label
|
||||
var retry_button: Button
|
||||
var simulation_button: Button
|
||||
var simulation_status_label: Label
|
||||
var simulation_preview_link: LinkButton
|
||||
var pending_simulation_launch := false
|
||||
var current_stage := "exam"
|
||||
var pending_question_bank_launch := false
|
||||
@@ -32,6 +33,8 @@ func _ready() -> void:
|
||||
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)
|
||||
if not AuthState.auth_changed.is_connected(_refresh_simulation_preview_visibility):
|
||||
AuthState.auth_changed.connect(_refresh_simulation_preview_visibility)
|
||||
|
||||
_build_exam_view()
|
||||
_build_mode_view()
|
||||
@@ -44,6 +47,7 @@ func on_show(payload: Variant = null) -> void:
|
||||
elif str(payload) == "exam":
|
||||
_show_stage("exam")
|
||||
_refresh_bank_state()
|
||||
_refresh_simulation_preview_visibility()
|
||||
ExamSimulationService.load_readiness()
|
||||
|
||||
|
||||
@@ -160,6 +164,16 @@ func _build_mode_view() -> void:
|
||||
Style.set_label(simulation_status_label, 15, Style.MUTED)
|
||||
mode_view.add_child(simulation_status_label)
|
||||
|
||||
simulation_preview_link = LinkButton.new()
|
||||
simulation_preview_link.text = "Temporary: preview completed exam results"
|
||||
simulation_preview_link.tooltip_text = "SUPER only; generates a nonpersistent simulated result"
|
||||
simulation_preview_link.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
|
||||
simulation_preview_link.add_theme_color_override("font_color", Style.CYAN)
|
||||
simulation_preview_link.add_theme_color_override("font_hover_color", Style.MAGENTA)
|
||||
simulation_preview_link.pressed.connect(_preview_simulation_results)
|
||||
mode_view.add_child(simulation_preview_link)
|
||||
_refresh_simulation_preview_visibility()
|
||||
|
||||
bank_status_label = Label.new()
|
||||
bank_status_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
Style.set_label(bank_status_label, 16, Style.CYAN)
|
||||
@@ -243,6 +257,17 @@ func _select_simulation() -> void:
|
||||
ExamSimulationService.create_simulation()
|
||||
|
||||
|
||||
func _preview_simulation_results() -> void:
|
||||
pending_simulation_launch = true
|
||||
simulation_preview_link.disabled = true
|
||||
ExamSimulationService.load_results_preview()
|
||||
|
||||
|
||||
func _refresh_simulation_preview_visibility() -> void:
|
||||
if simulation_preview_link != null:
|
||||
simulation_preview_link.visible = AuthState.role.to_upper() == "SUPER"
|
||||
|
||||
|
||||
func _on_simulation_state_changed() -> void:
|
||||
_refresh_simulation_state()
|
||||
if not pending_simulation_launch or ExamSimulationService.simulation.is_empty():
|
||||
@@ -269,6 +294,8 @@ func _launch_simulation_block() -> void:
|
||||
|
||||
func _on_simulation_failed(message: String) -> void:
|
||||
pending_simulation_launch = false
|
||||
if simulation_preview_link != null:
|
||||
simulation_preview_link.disabled = false
|
||||
if simulation_status_label != null:
|
||||
simulation_status_label.text = message
|
||||
_refresh_simulation_state()
|
||||
|
||||
Reference in New Issue
Block a user