translate html content in CC 1.3 assignments

test plan:
 - have a course containing an assignment that links to
   a course file
 - share the assignment to Commons
 - import it into another course
 - the link in the new course should contain the correct
   course id (the destination course's id, not the source
   course's id)

fixes CNVS-19366

Change-Id: Id58aca5215281b6d28458849eab00273ddd84109
Reviewed-on: https://gerrit.instructure.com/50527
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Pedro Fajardo <pfajardo@instructure.com>
This commit is contained in:
Jeremy Stanley 2015-03-17 17:48:07 -06:00 committed by Pedro Fajardo
parent 9a46b2f19c
commit 1a261a5371
2 changed files with 7 additions and 6 deletions

View File

@ -73,7 +73,7 @@ module CC
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation"=> "#{CCHelper::ASSIGNMENT_NAMESPACE} #{CCHelper::ASSIGNMENT_XSD_URI}"
) do |a|
AssignmentResources.create_cc_assignment(a, assignment, migration_id, @manifest)
AssignmentResources.create_cc_assignment(a, assignment, migration_id, @html_exporter, @manifest)
end
end
@ -128,9 +128,9 @@ module CC
"online_upload" => "file"
}.freeze
def self.create_cc_assignment(node, assignment, migration_id, manifest = nil)
def self.create_cc_assignment(node, assignment, migration_id, html_exporter, manifest = nil)
node.title(assignment.title)
node.text(assignment.description, texttype: 'text/html')
node.text(html_exporter.html_content(assignment.description), texttype: 'text/html')
if assignment.points_possible
node.gradable(assignment.graded?, points_possible: assignment.points_possible)
else

View File

@ -438,7 +438,8 @@ describe "Common Cartridge exporting" do
end
it "should export CC 1.3 assignments" do
@course.assignments.create! name: 'test assignment', description: '<em>what?</em>', points_possible: 11,
@file = Attachment.create!(:filename => 'test.txt', :uploaded_data => StringIO.new('ohai'), :folder => Folder.unfiled_folder(@course), :context => @course)
@course.assignments.create! name: 'test assignment', description: %Q{<a href="/courses/#{@course.id}/files/#{@file.id}/preview">what?</a>}, points_possible: 11,
submission_types: 'online_text_entry,online_upload,online_url'
@ce.export_type = ContentExport::COMMON_CARTRIDGE
@ce.save!
@ -453,7 +454,7 @@ describe "Common Cartridge exporting" do
# validate cc1.3 assignment xml document
assignment_xml_doc = Nokogiri::XML(@zip_file.read(assignment_xml_file))
expect(assignment_xml_doc.at_css('text').text).to eq '<em>what?</em>'
expect(assignment_xml_doc.at_css('text').text).to eq '<a href="%24IMS-CC-FILEBASE%24/unfiled/test.txt">what?</a>'
expect(assignment_xml_doc.at_css('text').attribute('texttype').value).to eq 'text/html'
expect(assignment_xml_doc.at_css('gradable').text).to eq 'true'
expect(assignment_xml_doc.at_css('gradable').attribute('points_possible').value).to eq '11'
@ -470,7 +471,7 @@ describe "Common Cartridge exporting" do
expect(variant_tag.attribute('identifierref').value).to eql assignment_id
expect(variant_tag.next_element.name).to eq 'file'
html_file = variant_tag.next_element.attribute('href').value
expect(@zip_file.read("#{assignment_id}/test-assignment.html")).to be_include "<em>what?</em>"
expect(@zip_file.read("#{assignment_id}/test-assignment.html")).to be_include "what?"
end
it "should export unpublished modules and items" do