Skip to content

Commit

Permalink
fix: show answer should show correct answers (#34335)
Browse files Browse the repository at this point in the history
  • Loading branch information
rayzhou-bit authored Mar 7, 2024
1 parent 8f88673 commit b455285
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xmodule/js/src/capa/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit b455285

Please sign in to comment.