From 68725d05534e5ada899efb8a732010ff2b32a16c Mon Sep 17 00:00:00 2001 From: Nate Armstrong Date: Wed, 9 Dec 2020 17:04:08 -0700 Subject: [PATCH] Symbolize keys to fix question banks fixup refs: LS-1692 flag = none Test plan: - Import https://pcraighill.test.instructure.com/courses/221 - View /courses/:course_id/question_banks - Verify that there are broken questions - Apply fixup /courses/:course_id/question_banks?fixup_quiz_math_questions=1 - Verify that all questions are fixed Change-Id: I43ec60fc07ce5f1e4336f1ad64261640ec16f7d1 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/254786 Tested-by: Service Cloud Jenkins Reviewed-by: Jeremy Stanley QA-Review: Nate Armstrong Product-Review: Nate Armstrong --- lib/quiz_math_data_fixup.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/quiz_math_data_fixup.rb b/lib/quiz_math_data_fixup.rb index 79494206af0..f2b6f94cc70 100644 --- a/lib/quiz_math_data_fixup.rb +++ b/lib/quiz_math_data_fixup.rb @@ -29,7 +29,7 @@ module QuizMathDataFixup questions.find_each do |quiz_question| begin old_data = quiz_question.question_data.to_hash - new_data = fixup_question_data(quiz_question.question_data.to_hash) + new_data = fixup_question_data(quiz_question.question_data.to_hash.symbolize_keys) quiz_question.write_attribute(:question_data, new_data) if new_data != old_data if quiz_question.changed? stat = question_bank ? 'updated_math_qb_question' : 'updated_math_question' @@ -66,10 +66,10 @@ module QuizMathDataFixup %i[neutral_comments_html correct_comments_html incorrect_comments_html].each do |key| data[key] = fixup_html(data[key]) if data[key].present? end - + data[:question_text] = fixup_html(data[:question_text]) if data[:question_text].present? - data[:answers].each_with_index do |answer, index| + data[:answers].map(&:symbolize_keys).each_with_index do |answer, index| %i[html comments_html].each do |key| # if there's html, the text field is used as the title attribute/tooltip # clear it out if we updated the html because it's probably hosed.