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 <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Nate Armstrong <narmstrong@instructure.com>
Product-Review: Nate Armstrong <narmstrong@instructure.com>
This commit is contained in:
Nate Armstrong 2020-12-09 17:04:08 -07:00 committed by Nate Armstrong
parent fe6c8e0617
commit 68725d0553
1 changed files with 3 additions and 3 deletions

View File

@ -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.