Skip to content
Snippets Groups Projects
Commit 36aefa2c authored by Han Yan's avatar Han Yan Committed by Keith Garner
Browse files

add content_migration settings for Q.N CC import

closes QUIZ-4809

test plan:
- make a Q.N CC import
- Check Canvas api endpoint:
    http://canvas.docker/api/v1/courses/<course_id>/content_migrations/<your_id>
- make sure imported_assets/lti_assginment_quiz_set appears, and
  format is like [[xxx, xxx],[xxx, xxx]...]

Change-Id: Id174ee7742dc34b76c7e7f4afedbaaed0062ea4d
Reviewed-on: https://gerrit.instructure.com/155273


Reviewed-by: default avatarSteve Kacsmark <skacsmark@instructure.com>
Tested-by: Jenkins
QA-Review: Steve Kacsmark <skacsmark@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
parent 6ced3958
Branches
Tags release/2018-07-14.04
No related merge requests found
......@@ -28,17 +28,34 @@ module QuizzesNext::Importers
::Importers::CourseContentImporter.
import_content(context, @data, params, @migration)
migration_lti!
end
private
def migration_lti!
lti_assignment_quiz_set = []
@migration.imported_migration_items_by_class(Assignment).each do |assignment|
next unless assignment.quiz?
quiz = assignment.quiz
lti_assignment_quiz_set << [assignment.global_id, quiz.global_id]
assignment.workflow_state = 'importing'
assignment.importing_started_at = Time.zone.now
assignment.quiz_lti! && assignment.save!
# Quizzes will be created in Quizzes.Next app
# assignment.quiz_lti! breaks relation to quiz. Destroying Quizzes:Quiz wouldn't
# mark assginment to be deleted.
quiz.destroy
end
setup_assets_imported(lti_assignment_quiz_set)
end
# Quizzes will be created in Quizzes.Next app
# assignment.quiz_lti! breaks relation to quiz. Destroying Quizzes:Quiz wouldn't
# mark assginment to be deleted.
@migration.imported_migration_items_by_class(Quizzes::Quiz).each(&:destroy)
def setup_assets_imported(lti_assignment_quiz_set)
imported_asset_hash = @migration.migration_settings[:imported_assets] || {}
imported_asset_hash[:lti_assignment_quiz_set] = lti_assignment_quiz_set
@migration.migration_settings[:imported_assets] = imported_asset_hash
@migration.save!
end
end
end
......@@ -31,6 +31,7 @@ describe QuizzesNext::Importers::CourseContentImporter do
let(:assignment3) { instance_double('Assignment') }
let(:quiz1) { instance_double('Quizzes::Quiz') }
let(:quiz2) { instance_double('Quizzes::Quiz') }
let(:quiz3) { instance_double('Quizzes::Quiz') }
let(:data) { double }
let(:time_now) { Time.zone.parse('03 May 2018 00:00:00 +0000') }
......@@ -42,11 +43,17 @@ describe QuizzesNext::Importers::CourseContentImporter do
allow(migration).
to receive(:imported_migration_items_by_class).
with(Quizzes::Quiz).
and_return([quiz1, quiz2])
and_return([quiz1, quiz2, quiz3])
allow(Time.zone).to receive(:now).and_return(time_now)
allow(assignment1).to receive(:quiz?).and_return(true)
allow(assignment2).to receive(:quiz?).and_return(true)
allow(assignment3).to receive(:quiz?).and_return(false)
allow(assignment1).to receive(:quiz).and_return(quiz1)
allow(assignment2).to receive(:quiz).and_return(quiz2)
allow(assignment1).to receive(:global_id).and_return(112_233)
allow(assignment2).to receive(:global_id).and_return(888_777)
allow(quiz1).to receive(:global_id).and_return(123_456)
allow(quiz2).to receive(:global_id).and_return(22_345)
end
it 'makes lti assignments' do
......@@ -62,7 +69,11 @@ describe QuizzesNext::Importers::CourseContentImporter do
expect(assignment2).to receive(:save!)
expect(quiz1).to receive(:destroy)
expect(quiz2).to receive(:destroy)
expect(quiz2).not_to receive(:destroy)
importer.import_content(double)
expect(migration.migration_settings[:imported_assets][:lti_assignment_quiz_set]).
to eq([[112_233, 123_456], [888_777, 22_345]])
end
end
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment