Fix eliminated-choice strikethrough disappearing on wrong/correct reveal
A choice that was crossed out (right-click) and also happened to be locked as the submitted-wrong choice, or revealed as the correct answer, silently lost its strikethrough because the percentage-badge branches took precedence over the elimination check in the same if/elif chain. Decoupled the two so a choice can show both the strikethrough and its reveal percentage at once.
This commit is contained in:
@@ -2968,17 +2968,11 @@ func _set_choice_button_text(index: int, choice: Dictionary) -> void:
|
||||
choice_buttons[index].custom_minimum_size = Vector2(0, 54)
|
||||
_set_choice_percent_label(index, "")
|
||||
_set_choice_top_label(index, "")
|
||||
if locked_wrong_choice_ids.has(choice_id):
|
||||
if locked_wrong_choice_ids.has(choice_id) or _should_show_correct_choice_percentage(choice_id):
|
||||
var percentage := _get_choice_selection_percentage(choice_id)
|
||||
if percentage >= 0:
|
||||
_set_choice_percent_label(index, "%d%%" % percentage)
|
||||
choice_buttons[index].text = choice_text
|
||||
elif _should_show_correct_choice_percentage(choice_id):
|
||||
var correct_percentage := _get_choice_selection_percentage(choice_id)
|
||||
if correct_percentage >= 0:
|
||||
_set_choice_percent_label(index, "%d%%" % correct_percentage)
|
||||
choice_buttons[index].text = choice_text
|
||||
elif eliminated.has(choice_id):
|
||||
if eliminated.has(choice_id):
|
||||
choice_buttons[index].text = ""
|
||||
_set_choice_top_label(index, "[s]%s[/s]" % _escape_bbcode(choice_text))
|
||||
else:
|
||||
|
||||
@@ -11,6 +11,7 @@ func _initialize() -> void:
|
||||
_test_correct_feedback_does_not_auto_advance()
|
||||
_test_correct_review_locks_answer_interactions()
|
||||
_test_eliminated_choice_uses_rich_text_strikeout()
|
||||
_test_eliminated_choice_that_is_also_locked_wrong_still_strikes_through()
|
||||
_test_explanation_highlighting_has_no_status_heading()
|
||||
_test_collapsed_followup_review_expands()
|
||||
_test_review_content_normalization()
|
||||
@@ -143,6 +144,27 @@ func _test_eliminated_choice_uses_rich_text_strikeout() -> void:
|
||||
player.free()
|
||||
|
||||
|
||||
func _test_eliminated_choice_that_is_also_locked_wrong_still_strikes_through() -> void:
|
||||
var player = load("res://scripts/ui/question_player.gd").new()
|
||||
player.choice_buttons.append(Button.new())
|
||||
player.choice_percent_labels.append(Label.new())
|
||||
var strike_label := RichTextLabel.new()
|
||||
strike_label.bbcode_enabled = true
|
||||
player.choice_top_labels.append(strike_label)
|
||||
player.choice_followup_panels.append(PanelContainer.new())
|
||||
player.eliminated = ["A"]
|
||||
player.locked_wrong_choice_ids = ["A"]
|
||||
player.presented_choices = [{"id": "A", "text": "Observation only"}]
|
||||
player._set_choice_button_text(0, player.presented_choices[0])
|
||||
_assert(strike_label.text == "[s]Observation only[/s]", "a choice that's both eliminated and locked-wrong should still strike through")
|
||||
_assert(player.choice_buttons[0].text == "", "the struck-through choice's button text should stay cleared")
|
||||
player.choice_buttons[0].free()
|
||||
player.choice_percent_labels[0].free()
|
||||
strike_label.free()
|
||||
player.choice_followup_panels[0].free()
|
||||
player.free()
|
||||
|
||||
|
||||
func _test_explanation_highlighting_has_no_status_heading() -> void:
|
||||
var player = load("res://scripts/ui/question_player.gd").new()
|
||||
player.explanation_label = RichTextLabel.new()
|
||||
|
||||
Reference in New Issue
Block a user