add content_export_id to quiz_export_complete LE

refs QUIZ-8266
flag = none

this PS should be tested with g/277137 g/278455

test plan:
- create a classic quiz that contains questions and stimuli
- migrate the quiz
- access the quiz_api console
- observe that the migrated quiz and its items and stimuli
  have their migration_id fields populated

Change-Id: Ibf6ae46685daca16b2f546ec8f10475a91c1fe14
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277070
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Reviewed-by: James Logan <james.logan@instructure.com>
Product-Review: Jorge Arteaga <jorge.arteaga@instructure.com>
This commit is contained in:
Jorge Arteaga 2021-10-28 17:50:34 -04:00
parent 906bf3fdf4
commit 636c9ed1d2
2 changed files with 11 additions and 2 deletions

View File

@ -631,7 +631,12 @@ module Canvas::LiveEvents
end
def self.quiz_export_complete(content_export)
payload = content_export.settings[:quizzes2]
# when importing content export packages, migration_ids are obtained
# from content_migrations, a content_migration and content_export can share
# the same ID.
# The "content-export-" prefix prevents from saving the same migration_id on
# records that belong to different migrations
payload = (content_export.settings[:quizzes2] || {}).merge({ content_export_id: "content-export-#{content_export.global_id}" })
post_event_stringified('quiz_export_complete', payload, amended_context(content_export.context))
end

View File

@ -1156,6 +1156,10 @@ describe Canvas::LiveEvents do
@context = context
end
def global_id
123_456_789
end
def settings
{
quizzes2: {
@ -1169,7 +1173,7 @@ describe Canvas::LiveEvents do
let(:content_export) { export_class.new(course_model) }
it 'triggers a live event with content export settings and amended context details' do
fake_export_context = { key1: 'val1', key2: 'val2' }
fake_export_context = { key1: 'val1', key2: 'val2', content_export_id: "content-export-123456789" }
expect_event(
'quiz_export_complete',