diff --git a/app/models/content_export.rb b/app/models/content_export.rb index 5b60378a705..902286b7239 100644 --- a/app/models/content_export.rb +++ b/app/models/content_export.rb @@ -217,6 +217,14 @@ class ContentExport < ActiveRecord::Base self.settings[:selected_content] ||= {} end + def select_content_key(obj) + if zip_export? + obj.asset_string + else + CC::CCHelper.create_key(obj) + end + end + # Method Summary # Takes in an ActiveRecord object. Determines if the item being # checked should be exported or not. @@ -231,7 +239,7 @@ class ContentExport < ActiveRecord::Base return true if is_set?(selected_content["all_#{asset_type}"]) return false unless selected_content[asset_type] - return true if is_set?(selected_content[asset_type][CC::CCHelper.create_key(obj)]) + return true if is_set?(selected_content[asset_type][select_content_key(obj)]) false end @@ -253,7 +261,7 @@ class ContentExport < ActiveRecord::Base asset_type = type || obj.class.table_name selected_content[asset_type] ||= {} - selected_content[asset_type][CC::CCHelper.create_key(obj)] = true + selected_content[asset_type][select_content_key(obj)] = true end def add_error(user_message, exception_or_info=nil) diff --git a/app/models/content_migration.rb b/app/models/content_migration.rb index d7aad35d78c..f9d17a52c05 100644 --- a/app/models/content_migration.rb +++ b/app/models/content_migration.rb @@ -626,6 +626,8 @@ class ContentMigration < ActiveRecord::Base 'content_tags' when 'pages' 'wiki_pages' + when 'files' + 'attachments' else key end diff --git a/spec/apis/v1/content_exports_api_spec.rb b/spec/apis/v1/content_exports_api_spec.rb index 0a1fa71bc53..ff2485b50d1 100644 --- a/spec/apis/v1/content_exports_api_spec.rb +++ b/spec/apis/v1/content_exports_api_spec.rb @@ -359,6 +359,13 @@ describe ContentExportsApiController, type: :request do { :select => {:pages => [page_to_copy.id]} }) export3 = t_course.content_exports.find_by_id(json3['id']) export3.export_object?(page_to_copy).should be_true + + file = attachment_model(context: t_course) + json4 = api_call_as_user(t_teacher, :post, "/api/v1/courses/#{t_course.id}/content_exports?export_type=common_cartridge", + { controller: 'content_exports_api', action: 'create', format: 'json', course_id: t_course.to_param, export_type: 'common_cartridge'}, + { :select => {:files => [file.id]} }) + export4 = t_course.content_exports.find_by_id(json4['id']) + export4.export_object?(file).should be_true end it "should export by module item id" do @@ -465,6 +472,14 @@ describe ContentExportsApiController, type: :request do end end + it "should support 'files' in addition to 'attachments'" do + json = api_call_as_user(t_teacher, :post, "/api/v1/courses/#{t_course.id}/content_exports", + { controller: 'content_exports_api', action: 'create', format: 'json', course_id: t_course.to_param }, + { export_type: 'zip', select: {'files' => [@file1.id]} }) + ce = ContentExport.find(json['id']) + ce.export_object?(@file1).should be true + end + context "as a student" do it "should exclude non-zip and/or other users' exports from #index" do my_zip_export = past_export(t_course, t_student, 'zip')