export rubrics with graded discussion topics on selective export

test plan:
* create a course with a rubric
* create a graded discussion topic and associate it with the rubric
* use the content exports api to create a course export, passing
 in a parameter to only export the discussion topic

"select[discussion_topics][]=TOPIC_ID"

* import the exported file into a new course
* the topic should have the rubric associated with it

closes #CNVS-29182

Change-Id: I6aded344a70acf53e0196f3d7cc779296d556102
Reviewed-on: https://gerrit.instructure.com/79179
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
James Williams 2016-05-10 07:40:46 -06:00 committed by Jeremy Stanley
parent 3394d9efa5
commit ce0192da3d
2 changed files with 36 additions and 4 deletions

View File

@ -42,9 +42,10 @@ module CC
rubric = assoc.rubric rubric = assoc.rubric
next if rubric.nil? || !rubric.active? || imported_rubrics[rubric.id] next if rubric.nil? || !rubric.active? || imported_rubrics[rubric.id]
if !export_object?(rubric) if !export_object?(rubric)
if assoc.association_type != "Assignment" || !export_object?(assoc.association_object) next if assoc.association_type != "Assignment"
next
end assignment = assoc.association_object
next unless [assignment, assignment.quiz, assignment.discussion_topic, assignment.wiki_page].compact.any?{|o| export_object?(o)}
end end
imported_rubrics[rubric.id] = true imported_rubrics[rubric.id] = true
rubric.learning_outcome_alignments.each do |align| rubric.learning_outcome_alignments.each do |align|

View File

@ -404,6 +404,37 @@ describe ContentExportsApiController, type: :request do
expect(copied_page).not_to be_nil expect(copied_page).not_to be_nil
expect(@course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists expect(@course.wiki.wiki_pages.where(migration_id: CC::CCHelper.create_key(page_to_not_copy))).not_to be_exists
end end
it "should export rubrics attached to discussions" do
@course = t_course
outcome_with_rubric
assignment_model(:course => @course, :submission_types => 'discussion_topic', :title => 'graded discussion')
@rubric.associate_with(@assignment, @course, purpose: 'grading')
topic = @assignment.discussion_topic
json = 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 => {:discussion_topics => [topic.id]} })
export = t_course.content_exports.where(id: json['id']).first
run_jobs
export.reload
course
cm = @course.content_migrations.new
cm.attachment = export.attachment
cm.migration_type = "canvas_cartridge_importer"
cm.migration_settings[:import_immediately] = true
cm.save!
cm.queue_migration
run_jobs
to_assign = @course.assignments.first
to_outcomes = to_assign.rubric.learning_outcome_alignments.map(&:learning_outcome).map(&:migration_id)
expect(to_outcomes).to eql [CC::CCHelper.create_key(@outcome)]
end
end end
end end