detect text nodes in qti answer extraction
test plan: (note: test in conjunction with g/51584) * create a matching quiz question * in the left-hand side, type what appears to be html content (but isn't), e.g. "<img> text" * copy the course * should have copied the question exactly refs #CNVS-19634 Change-Id: Iedd6388b9cfa9fa58a0725afb20d51780692595a Reviewed-on: https://gerrit.instructure.com/51623 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
117090c057
commit
9c6dbe7193
|
@ -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
|
||||
|
|
|
@ -538,6 +538,40 @@ equation: <img class="equation_image" title="Log_216" src="/equation_images/Log_
|
|||
expect(aq.question_data[:answers][1][:left_html]).to eq data2[:answers][1][:left_html]
|
||||
end
|
||||
|
||||
it "should correctly copy matching question fields with html-lookalike text" do
|
||||
skip("qti tool update")
|
||||
@bank = @copy_from.assessment_question_banks.create!(:title => 'Test Bank')
|
||||
data = {:question_type => "matching_question",
|
||||
:points_possible => 10,
|
||||
:question_text => "text",
|
||||
:matches => [{:match_id=>4835, :text=>"<i>aasdf</i>"},
|
||||
{:match_id=>6247, :text=>"<p>not good"}],
|
||||
:answers => [{:id => 2939, :text => "<p>srsly is all text</p> <img totes & bork", :match_id=>4835},
|
||||
{:id => 2940, :html => "<img src=\"http://example.com\">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",
|
||||
|
|
Loading…
Reference in New Issue