Track real first attempt question stats
This commit is contained in:
@@ -192,6 +192,13 @@ func _build_app_menu() -> void:
|
||||
resume.pressed.connect(_close_app_menu)
|
||||
content.add_child(resume)
|
||||
|
||||
var profile := Button.new()
|
||||
profile.text = "Profile"
|
||||
profile.custom_minimum_size = Vector2(0, 48)
|
||||
Style.style_chip(profile, Style.CYAN)
|
||||
profile.pressed.connect(_open_profile_from_menu)
|
||||
content.add_child(profile)
|
||||
|
||||
menu_exit_button = Button.new()
|
||||
menu_exit_button.text = "Exit Run"
|
||||
menu_exit_button.custom_minimum_size = Vector2(0, 48)
|
||||
@@ -232,3 +239,10 @@ func _exit_run() -> void:
|
||||
if BlockSessionService.block_started:
|
||||
BlockSessionService.finish_block()
|
||||
show_screen("dashboard")
|
||||
|
||||
|
||||
func _open_profile_from_menu() -> void:
|
||||
_close_app_menu()
|
||||
if BlockSessionService.block_started:
|
||||
BlockSessionService.finish_block()
|
||||
show_screen("profile")
|
||||
|
||||
@@ -4,6 +4,8 @@ const Style := preload("res://scripts/ui/ui_style.gd")
|
||||
|
||||
var main: Control
|
||||
var profile_text: RichTextLabel
|
||||
var reset_qbank_button: Button
|
||||
var reset_qbank_pending := false
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
@@ -38,10 +40,17 @@ func _ready() -> void:
|
||||
on_show()
|
||||
)
|
||||
row.add_child(reset)
|
||||
|
||||
reset_qbank_button = Button.new()
|
||||
reset_qbank_button.text = "Reset QBank"
|
||||
Style.style_chip(reset_qbank_button, Style.AMBER)
|
||||
reset_qbank_button.pressed.connect(_on_reset_qbank_pressed)
|
||||
row.add_child(reset_qbank_button)
|
||||
add_child(row)
|
||||
|
||||
|
||||
func on_show(_payload: Variant = null) -> void:
|
||||
_reset_qbank_confirmation()
|
||||
var profile := ProfileService.get_profile()
|
||||
var xp_into := ProgressionService.xp_into_level(int(profile["xp"]))
|
||||
var text := "[b]Level %d[/b]\n%d total XP (%d/%d to next level)\nCurrent streak: %d\nBest streak: %d\nToday: %d/%d questions, +%d XP\n\n[b]Badges[/b]\n" % [
|
||||
@@ -82,3 +91,24 @@ func on_show(_payload: Variant = null) -> void:
|
||||
block.get("xp_earned", 0)
|
||||
]
|
||||
profile_text.text = text
|
||||
|
||||
|
||||
func _on_reset_qbank_pressed() -> void:
|
||||
if not reset_qbank_pending:
|
||||
reset_qbank_pending = true
|
||||
reset_qbank_button.text = "Confirm Reset QBank"
|
||||
Style.style_chip(reset_qbank_button, Style.RED)
|
||||
return
|
||||
|
||||
ProfileService.reset_qbank_memory()
|
||||
if BlockSessionService.core_status_message == "All available questions cleared.":
|
||||
BlockSessionService.core_status_message = ""
|
||||
_reset_qbank_confirmation()
|
||||
on_show()
|
||||
|
||||
|
||||
func _reset_qbank_confirmation() -> void:
|
||||
reset_qbank_pending = false
|
||||
if reset_qbank_button != null:
|
||||
reset_qbank_button.text = "Reset QBank"
|
||||
Style.style_chip(reset_qbank_button, Style.AMBER)
|
||||
|
||||
@@ -39,6 +39,8 @@ var shake_origin := Vector2.ZERO
|
||||
func _ready() -> void:
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
add_theme_constant_override("separation", 10)
|
||||
if not QuestionBankService.choice_percentages_updated.is_connected(_on_choice_percentages_updated):
|
||||
QuestionBankService.choice_percentages_updated.connect(_on_choice_percentages_updated)
|
||||
|
||||
var top := HBoxContainer.new()
|
||||
top.add_theme_constant_override("separation", 12)
|
||||
@@ -322,6 +324,9 @@ func _submit_or_next() -> void:
|
||||
if selected_choice == "":
|
||||
return
|
||||
if BlockSessionService.session_kind == "core":
|
||||
var attempted_choice := selected_choice
|
||||
var attempted_question_id := str(BlockSessionService.get_current_question().get("id", ""))
|
||||
QuestionBankService.record_first_attempt(attempted_question_id, attempted_choice)
|
||||
var result := BlockSessionService.submit_core_attempt(selected_choice, eliminated, flagged)
|
||||
if result.is_empty():
|
||||
return
|
||||
@@ -330,7 +335,7 @@ func _submit_or_next() -> void:
|
||||
current_answer = answer
|
||||
_trigger_correct_feedback()
|
||||
return
|
||||
_lock_wrong_choice(selected_choice)
|
||||
_lock_wrong_choice(attempted_choice)
|
||||
selected_choice = ""
|
||||
current_answer = {}
|
||||
next_button.text = "Submit"
|
||||
@@ -615,6 +620,15 @@ func _get_choice_selection_percentage(choice_id: String) -> int:
|
||||
return clamp(int(percentages.get(choice_id, -1)), 0, 100)
|
||||
|
||||
|
||||
func _on_choice_percentages_updated(question_id: String, percentages: Dictionary) -> void:
|
||||
if not visible:
|
||||
return
|
||||
if str(BlockSessionService.get_current_question().get("id", "")) != question_id:
|
||||
return
|
||||
BlockSessionService.update_question_choice_percentages(question_id, percentages)
|
||||
_apply_saved_choice_state()
|
||||
|
||||
|
||||
func _strike_text(value: String) -> String:
|
||||
var result := ""
|
||||
for character in value:
|
||||
|
||||
Reference in New Issue
Block a user