From b4552850c50da3eb3230fcc120c835a516e4644a Mon Sep 17 00:00:00 2001 From: Raymond Zhou <56318341+rayzhou-bit@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:27:48 -0800 Subject: [PATCH] fix: show answer should show correct answers (#34335) --- xmodule/js/src/capa/display.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xmodule/js/src/capa/display.js b/xmodule/js/src/capa/display.js index 51a91cdfc8..f4254b43f8 100644 --- a/xmodule/js/src/capa/display.js +++ b/xmodule/js/src/capa/display.js @@ -729,6 +729,7 @@ answers = response.answers; $.each(answers, function(key, value) { var safeKey = key.replace(':', '\\:'); // fix for courses which use url_names with colons, e.g. problem:question1 + safeKey = safeKey.replace(/\./g, '\\.'); // fix for courses which use url_names with periods. e.g. question1.1 var answer; if (!$.isArray(value)) { answer = that.$('#answer_' + safeKey + ', #solution_' + safeKey); @@ -1085,12 +1086,13 @@ $element = $(element); inputId = $element.attr('id').replace(/inputtype_/, ''); inputId = inputId.replace(':', '\\:'); // fix for courses which use url_names with colons, e.g. problem:question1 + var safeId = inputId.replace(/\./g, '\\.'); // fix for courses which use url_names with periods. e.g. question1.1 answer = answers[inputId]; results = []; for (i = 0, len = answer.length; i < len; i++) { choice = answer[i]; - $inputLabel = $element.find('#input_' + inputId + '_' + choice + ' + label'); - $inputStatus = $element.find('#status_' + inputId); + $inputLabel = $element.find('#input_' + safeId + '_' + choice + ' + label'); + $inputStatus = $element.find('#status_' + safeId); // If the correct answer was already Submitted before "Show Answer" was selected, // the status HTML will already be present. Otherwise, inject the status HTML.