diff --git a/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb b/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb index 9c8dca6ab42..bcb47cc6373 100644 --- a/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb +++ b/gems/plugins/qti_exporter/lib/qti/assessment_item_converter.rb @@ -228,6 +228,10 @@ class AssessmentItemConverter # returns a tuple of [text, html] # html is null if it's not an html blob def detect_html(node) + if text_node = node.at_css('div.text') + return [text_node.text.strip, nil] + end + text = clear_html(node.text.gsub(/\s+/, " ")).strip html_node = node.at_css('div.html') || (node.name.downcase == 'div' && node['class'] =~ /\bhtml\b/) is_html = false diff --git a/spec/models/content_migration/course_copy_quizzes_spec.rb b/spec/models/content_migration/course_copy_quizzes_spec.rb index 1ce78bff056..af763a71719 100644 --- a/spec/models/content_migration/course_copy_quizzes_spec.rb +++ b/spec/models/content_migration/course_copy_quizzes_spec.rb @@ -538,6 +538,40 @@ equation: 'Test Bank') + data = {:question_type => "matching_question", + :points_possible => 10, + :question_text => "text", + :matches => [{:match_id=>4835, :text=>"aasdf"}, + {:match_id=>6247, :text=>"
not good"}], + :answers => [{:id => 2939, :text => "
srsly is all text
4835}, + {:id => 2940, :html => "good ol html", :match_id=>6247}] + }.with_indifferent_access + aq_from = @bank.assessment_questions.create!(:question_data => data) + + quiz = @copy_from.quizzes.create!(:title => "survey pub", :quiz_type => "survey") + qq_from = quiz.quiz_questions.new(:assessment_question => aq_from) + qq_from.write_attribute(:question_data, data) + qq_from.save! + quiz.generate_quiz_data + quiz.save! + + run_course_copy + + aq = @copy_to.assessment_questions.where(migration_id: mig_id(aq_from)).first + qq = @copy_to.quizzes.first.quiz_questions.first + + [aq, qq].each do |q| + expect(q.question_data[:question_text]).to eq data[:question_text] + expect(q.question_data[:matches][0][:text]).to eq data[:matches][0][:text] + expect(q.question_data[:matches][1][:text]).to eq data[:matches][1][:text] + expect(q.question_data[:answers][0][:text]).to eq data[:answers][0][:text] + expect(q.question_data[:answers][1][:html]).to eq data[:answers][1][:html] + end + end + it "should copy file_upload_questions" do bank = @copy_from.assessment_question_banks.create!(:title => 'Test Bank') data = {:question_type => "file_upload_question",