fix indenting of imported modules; fixes #4375
Change-Id: Ibbf3466424e58e41e47691fcbd6e548450d47e15 Reviewed-on: https://gerrit.instructure.com/3264 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
0416648787
commit
e10c1cc2f5
|
@ -723,7 +723,7 @@ class ContextModule < ActiveRecord::Base
|
|||
existing_item ||= content_tags.new(:context => context)
|
||||
context.imported_migration_items << existing_item if context.imported_migration_items && existing_item.new_record?
|
||||
existing_item.migration_id = hash[:migration_id]
|
||||
hash[:indents] = [hash[:indents] || 0, level].max
|
||||
hash[:indent] = [hash[:indent] || 0, level].max
|
||||
if hash[:linked_resource_type] =~ /wiki_type|wikipage/i
|
||||
wiki = self.context.wiki.wiki_pages.find_by_migration_id(hash[:migration_id]) if hash[:migration_id]
|
||||
if wiki
|
||||
|
@ -731,7 +731,7 @@ class ContextModule < ActiveRecord::Base
|
|||
:title => hash[:title] || hash[:linked_resource_title],
|
||||
:type => 'wiki_page',
|
||||
:id => wiki.id,
|
||||
:indent => hash[:indents].to_i
|
||||
:indent => hash[:indent].to_i
|
||||
}, existing_item)
|
||||
end
|
||||
elsif hash[:linked_resource_type] =~ /page_type|file_type|attachment/i
|
||||
|
@ -747,7 +747,7 @@ class ContextModule < ActiveRecord::Base
|
|||
:title => title,
|
||||
:type => 'attachment',
|
||||
:id => file.id,
|
||||
:indent => hash[:indents].to_i
|
||||
:indent => hash[:indent].to_i
|
||||
}, existing_item)
|
||||
end
|
||||
elsif hash[:linked_resource_type] =~ /assignment|project/i
|
||||
|
@ -758,7 +758,7 @@ class ContextModule < ActiveRecord::Base
|
|||
:title => hash[:title] || hash[:linked_resource_title],
|
||||
:type => 'assignment',
|
||||
:id => ass.id,
|
||||
:indent => hash[:indents].to_i
|
||||
:indent => hash[:indent].to_i
|
||||
}, existing_item)
|
||||
end
|
||||
elsif (hash[:linked_resource_type] || hash[:type]) =~ /folder|heading|contextmodulesubheader/i
|
||||
|
@ -766,7 +766,7 @@ class ContextModule < ActiveRecord::Base
|
|||
item = self.add_item({
|
||||
:title => hash[:title] || hash[:linked_resource_title],
|
||||
:type => 'context_module_sub_header',
|
||||
:indent => hash[:indents].to_i
|
||||
:indent => hash[:indent].to_i
|
||||
}, existing_item)
|
||||
elsif hash[:linked_resource_type] =~ /url/i
|
||||
# external url
|
||||
|
@ -774,7 +774,7 @@ class ContextModule < ActiveRecord::Base
|
|||
item = self.add_item({
|
||||
:title => hash[:title] || hash[:linked_resource_title] || hash['description'],
|
||||
:type => 'external_url',
|
||||
:indent => hash[:indents].to_i,
|
||||
:indent => hash[:indent].to_i,
|
||||
:url => hash['url']
|
||||
}, existing_item)
|
||||
end
|
||||
|
@ -784,7 +784,7 @@ class ContextModule < ActiveRecord::Base
|
|||
item = self.add_item({
|
||||
:title => hash[:title] || hash[:linked_resource_title] || hash['description'],
|
||||
:type => 'context_external_tool',
|
||||
:indent => hash[:indents].to_i,
|
||||
:indent => hash[:indent].to_i,
|
||||
:url => hash['url']
|
||||
}, existing_item)
|
||||
end
|
||||
|
@ -794,7 +794,7 @@ class ContextModule < ActiveRecord::Base
|
|||
item = self.add_item({
|
||||
:title => hash[:title] || hash[:linked_resource_title],
|
||||
:type => 'quiz',
|
||||
:indent => hash[:indents].to_i,
|
||||
:indent => hash[:indent].to_i,
|
||||
:id => quiz.id
|
||||
}, existing_item)
|
||||
end
|
||||
|
@ -804,7 +804,7 @@ class ContextModule < ActiveRecord::Base
|
|||
item = self.add_item({
|
||||
:title => hash[:title] || hash[:linked_resource_title],
|
||||
:type => 'discussion_topic',
|
||||
:indent => hash[:indents].to_i,
|
||||
:indent => hash[:indent].to_i,
|
||||
:id => topic.id
|
||||
}, existing_item)
|
||||
end
|
||||
|
|
|
@ -339,7 +339,7 @@ describe "Common Cartridge importing" do
|
|||
mod2.save!
|
||||
|
||||
asmnt1 = @copy_from.assignments.create!(:title => "some assignment")
|
||||
tag = mod1.add_item({:id => asmnt1.id, :type => 'assignment'})
|
||||
tag = mod1.add_item({:id => asmnt1.id, :type => 'assignment', :indent => 1})
|
||||
c_reqs = []
|
||||
c_reqs << {:type => 'min_score', :min_score => 5, :id => tag.id}
|
||||
page = @copy_from.wiki.wiki_pages.create!(:title => "some page")
|
||||
|
@ -390,6 +390,7 @@ describe "Common Cartridge importing" do
|
|||
tag = mod1_2.content_tags.first
|
||||
tag.content_id.should == asmnt2.id
|
||||
tag.content_type.should == 'Assignment'
|
||||
tag.indent.should == 1
|
||||
cr1 = mod1_2.completion_requirements.find {|cr| cr[:id] == tag.id}
|
||||
cr1[:type].should == 'min_score'
|
||||
cr1[:min_score].should == 5
|
||||
|
|
Loading…
Reference in New Issue