copy new_tab setting for external tool links during course copy.

fixes #8648

test plan:
  * create a course with an external tool link in a module
    that is set to open in a new tab;
  * create a second course, and copy the first course's content
    into it;
  * verify that the link is copied and that it is properly set
    to open in a new tab.

Change-Id: Ib12cf67405393dfbeea416cbe056152daec805de
Reviewed-on: https://gerrit.instructure.com/10778
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
Zach Pendleton 2012-05-16 13:28:19 -06:00
parent 08e0f600ab
commit 16c3919328
4 changed files with 19 additions and 14 deletions

View File

@ -828,6 +828,7 @@ class ContextModule < ActiveRecord::Base
if item
item_map[hash[:migration_id]] = item if hash[:migration_id]
item.migration_id = hash[:migration_id]
item.new_tab = hash[:new_tab]
item.position = (@item_migration_position ||= self.content_tags.active.map(&:position).compact.max || 0)
item.workflow_state = 'active'
@item_migration_position += 1

View File

@ -18,11 +18,11 @@
module CC::Importer::Canvas
module ModuleConverter
include CC::Importer
def convert_modules(doc)
modules = []
return modules unless doc
doc.css('module').each do |r_node|
mod = {}
mod[:migration_id] = r_node['identifier']
@ -32,7 +32,7 @@ module CC::Importer::Canvas
mod[:end_at] = get_time_val(r_node, 'end_at')
mod[:unlock_at] = get_time_val(r_node, 'unlock_at')
mod[:require_sequential_progress] = get_bool_val(r_node, 'require_sequential_progress')
mod[:items] = []
r_node.css('item').each do |item_node|
item = {}
@ -41,12 +41,13 @@ module CC::Importer::Canvas
item[:indent] = get_int_val(item_node, 'indent')
item[:url] = get_node_val(item_node, 'url')
item[:title] = get_node_val(item_node, 'title')
item[:new_tab] = get_bool_val(item_node, 'new_tab')
item[:linked_resource_type] = get_node_val(item_node, 'content_type')
item[:linked_resource_id] = get_node_val(item_node, 'identifierref')
mod[:items] << item
end
mod[:completion_requirements] = []
r_node.css('completionRequirement').each do |cr_node|
cr = {}
@ -54,24 +55,24 @@ module CC::Importer::Canvas
cr[:item_migration_id] = get_node_val(cr_node, 'identifierref')
cr[:min_score] = get_float_val(cr_node, 'min_score')
cr[:max_score] = get_float_val(cr_node, 'max_score')
mod[:completion_requirements] << cr
end
mod[:prerequisites] = []
r_node.css('prerequisite').each do |p_node|
prereq = {}
prereq[:type] = p_node['type']
prereq[:title] = get_node_val(p_node, 'title')
prereq[:module_migration_id] = get_node_val(p_node, 'identifierref')
prereq[:title] = get_node_val(p_node, 'title')
prereq[:module_migration_id] = get_node_val(p_node, 'identifierref')
mod[:prerequisites] << prereq
end
modules << mod
end
modules
end
end
end

View File

@ -76,6 +76,7 @@ module CC
item_node.identifierref CCHelper.create_key(ct.content_or_self) unless ct.content_type == 'ContextModuleSubHeader'
item_node.url ct.url if ["ContextExternalTool", 'ExternalUrl'].member? ct.content_type
item_node.position ct.position
item_node.new_tab ct.new_tab
item_node.indent ct.indent
end
end

View File

@ -249,10 +249,10 @@ describe "Canvas Cartridge importing" do
mod1 = @copy_from.context_modules.create!(:name => "some module")
tag = mod1.add_item({:title => "test", :type => 'context_external_tool', :url => "http://example.com.ims/lti"})
tag = mod1.add_item({:title => "test", :type => 'context_external_tool', :url => "http://example.com.ims/lti", :new_tab => true})
tag = mod1.add_item({:title => "test2", :type => 'context_external_tool', :url => "http://example.com.ims/lti"})
mod1.save!
mod1.content_tags.count.should == 2
#export to xml
@ -271,9 +271,11 @@ describe "Canvas Cartridge importing" do
tag = mod1_2.content_tags.first
tag.content_id.should == tool_to.id
tag.content_type.should == 'ContextExternalTool'
tag.new_tab.should == true
tag.url.should == "http://example.com.ims/lti"
tag = mod1_2.content_tags.last
tag.content_id.should == tool_to.id
tag.new_tab.should_not == true
tag.content_type.should == 'ContextExternalTool'
tag.url.should == "http://example.com.ims/lti"
end