add created_on_blueprint_sync to assignment_created LE

flag = none
closes QUIZ-9498

test plan:
- create a master (blueprint) course with assignments
- open a terminal in quiz_lti where you can inspect
sqs logs
- associate the master course to a child course and
 wait for the synchronization to finish
- from your quiz_lti terminal, observe the
assignment_created event(s)
- the event should have a created_on_blueprint_sync field
 set as "true"

- create assignments manually in blueprint courses
and non-blueprint courses
- observe that this time created_on_blueprint_sync is
set as "false"

Change-Id: I9eac41669f26f070c9c5325da251479a6a4b5751
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/290195
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Jorge Arteaga <jorge.arteaga@instructure.com>
This commit is contained in:
Jorge Arteaga 2022-04-21 19:46:04 -04:00
parent e8fb15ef51
commit 56afeedf23
3 changed files with 74 additions and 4 deletions

View File

@ -47,6 +47,7 @@ Assignment
"context_id": "21070000000000565",
"context_type": "Course",
"context_uuid": "a1b2c3c4z9x8a1s2q5w6p9o8i7u6y5t6a2s3d4f5",
"created_on_blueprint_sync": false,
"description": "<p>test assignment</p>",
"due_at": "2018-10-01T05:59:59Z",
"lock_at": "2018-10-01T05:59:59Z",
@ -75,6 +76,7 @@ Assignment
| **context_id** | The type of context the assignment is used in. |
| **context_type** | The type of context the assignment is used in. |
| **context_uuid** | The uuid of the context associated with the assignment. |
| **created_on_blueprint_sync** | Whether or not the assignment was created in the context of a blueprint sync. |
| **description** | The description of the assignment. NOTE: This field will be truncated to only include the first 8192 characters. |
| **due_at** | The due date for the assignment. |
| **lock_at** | The lock date (assignment is locked after this date). |
@ -476,6 +478,3 @@ Assignment
| **unlock_at** | The unlock date (assignment is unlocked after this date), or null if not applicable. |
| **updated_at** | The time at which this assignment was last modified in any way. |
| **workflow_state** | Workflow state of the assignment (deleted, duplicating, failed_to_import, failed_to_duplicate, failed_to_migrate, importing, published, unpublished). |

View File

@ -222,6 +222,10 @@ module Canvas::LiveEvents
end
def self.get_assignment_data(assignment)
created_on_blueprint_sync =
MasterCourses::ChildSubscription.is_child_course?(assignment.context) &&
assignment.migration_id&.start_with?(MasterCourses::MIGRATION_ID_PREFIX)
event = {
assignment_id: assignment.global_id,
context_id: assignment.global_context_id,
@ -240,7 +244,8 @@ module Canvas::LiveEvents
lti_assignment_description: LiveEvents.truncate(assignment.description),
lti_resource_link_id: assignment.lti_resource_link_id,
lti_resource_link_id_duplicated_from: assignment.duplicate_of&.lti_resource_link_id,
submission_types: assignment.submission_types
submission_types: assignment.submission_types,
created_on_blueprint_sync: created_on_blueprint_sync || false
}
actl = assignment.assignment_configuration_tool_lookups.take
domain = assignment.root_account&.domain(ApplicationController.test_cluster_name)

View File

@ -896,6 +896,72 @@ describe Canvas::LiveEvents do
Canvas::LiveEvents.assignment_created(@assignment)
end
context "when the assignment is created as part of a blueprint sync" do
before do
course = course_model
master_template = MasterCourses::MasterTemplate.create!(course: course)
child_course = course_model
MasterCourses::ChildSubscription.create!(master_template: master_template, child_course: child_course)
@assignment = child_course.assignments.create!(assignment_valid_attributes
.merge({ migration_id: "mastercourse_1_1_bd72ce9cf355d1b2cc467b2156842281" }))
end
it "has the created_on_blueprint_sync field set as true" do
expect_event("assignment_created",
hash_including({
assignment_id: @assignment.global_id.to_s,
created_on_blueprint_sync: true
}))
Canvas::LiveEvents.assignment_created(@assignment)
end
end
context "when the assignment is manually created in a blueprint child course" do
before do
master_template = MasterCourses::MasterTemplate.create!(course: course_model)
child_course = course_model
MasterCourses::ChildSubscription.create!(master_template: master_template, child_course: child_course)
@assignment = child_course.assignments.create!(assignment_valid_attributes)
end
it "has created_on_blueprint_sync set as false" do
expect_event("assignment_created",
hash_including({
assignment_id: @assignment.global_id.to_s,
created_on_blueprint_sync: false
}))
Canvas::LiveEvents.assignment_created(@assignment)
end
end
context "when the assignment is manually created in a blueprint course" do
before do
course = course_model
MasterCourses::MasterTemplate.create!(course: course)
@assignment = course.assignments.create!(assignment_valid_attributes)
end
it "has created_on_blueprint_sync set as false" do
expect_event("assignment_created",
hash_including({
assignment_id: @assignment.global_id.to_s,
created_on_blueprint_sync: false
}))
Canvas::LiveEvents.assignment_created(@assignment)
end
end
context "when the assignment is created in a non-blueprint course" do
it "has created_on_blueprint_sync set as false" do
expect_event("assignment_created",
hash_including({
assignment_id: @assignment.global_id.to_s,
created_on_blueprint_sync: false
}))
Canvas::LiveEvents.assignment_created(@assignment)
end
end
context "with assignment configuration tool lookup" do
include_context "lti2_spec_helper"
let(:product_family) do