Add associated_integration_id to plagiarism live events

closes PLAT-5766
flag=none

Test plan
- Planning to test this on beta once it's there
  as that will be easier than trying to test it
  locally
- We'll want to install a fresh Plagiarism tool
  at an account
- Verify that the plagiarism subscription IS receiving
  events for assignments that are linked to the tool
- Verify that the plagiarism subscription IS NOT receiving
  events for assignments that are not linked to the
  tool
- Verify that regular subscriptions are still receiving
  events for both linked and non-linked assignments

Change-Id: I59a1f5f6d1c061dfcd50c1efa2788173875d2231
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/240369
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Michael Guymon <mguymon@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
Product-Review: Mysti Lilla <mysti@instructure.com>
This commit is contained in:
Mysti Lilla 2020-06-16 14:19:47 -06:00
parent d4c4a58f74
commit d5ddea29b1
2 changed files with 94 additions and 34 deletions

View File

@ -217,7 +217,7 @@ module Canvas::LiveEvents
end
def self.get_assignment_data(assignment)
{
event = {
assignment_id: assignment.global_id,
context_id: assignment.global_context_id,
context_uuid: assignment.context.uuid,
@ -236,6 +236,9 @@ module Canvas::LiveEvents
lti_resource_link_id_duplicated_from: assignment.duplicate_of&.lti_resource_link_id,
submission_types: assignment.submission_types
}
actl = assignment.assignment_configuration_tool_lookups.take
event[:associated_integration_id] = "#{actl.tool_vendor_code}-#{actl.tool_product_code}" if actl
event
end
def self.assignment_created(assignment)
@ -309,7 +312,7 @@ module Canvas::LiveEvents
end
def self.get_submission_data(submission)
{
event = {
submission_id: submission.global_id,
assignment_id: submission.global_assignment_id,
user_id: submission.global_user_id,
@ -326,8 +329,11 @@ module Canvas::LiveEvents
late: submission.late?,
missing: submission.missing?,
lti_assignment_id: submission.assignment.lti_context_id,
group_id: submission.group_id
group_id: submission.group_id,
}
actl = AssignmentConfigurationToolLookup.find_by(assignment_id: submission.assignment_id)
event[:associated_integration_id] = "#{actl.tool_vendor_code}-#{actl.tool_product_code}" if actl
event
end
def self.get_attachment_data(attachment)

View File

@ -16,7 +16,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
require 'spec_helper.rb'
describe Canvas::LiveEvents do
# The only methods tested in here are ones that have any sort of logic happening.
@ -573,6 +573,16 @@ describe Canvas::LiveEvents do
))
Canvas::LiveEvents.submission_created(submission)
end
it 'should include the associated_integration_id if the assignment has an assignment configuration tool lookup' do
submission.assignment.assignment_configuration_tool_lookups.create!(tool_product_code: 'turnitin-lti',
tool_vendor_code: 'turnitin.com', tool_type: 'Lti::MessageHandler')
expect_event('submission_created',
hash_including(
associated_integration_id: "turnitin.com-turnitin-lti"
))
Canvas::LiveEvents.submission_created(submission)
end
end
describe ".submission_updated" do
@ -607,6 +617,16 @@ describe Canvas::LiveEvents do
))
Canvas::LiveEvents.submission_updated(submission)
end
it 'should include the associated_integration_id if the assignment has an assignment configuration tool lookup' do
submission.assignment.assignment_configuration_tool_lookups.create!(tool_product_code: 'turnitin-lti',
tool_vendor_code: 'turnitin.com', tool_type: 'Lti::MessageHandler')
expect_event('submission_updated',
hash_including(
associated_integration_id: "turnitin.com-turnitin-lti"
))
Canvas::LiveEvents.submission_updated(submission)
end
end
describe ".submissions_bulk_updated" do
@ -688,6 +708,16 @@ describe Canvas::LiveEvents do
))
Canvas::LiveEvents.plagiarism_resubmit(submission)
end
it 'should include the associated_integration_id if the assignment has an assignment configuration tool lookup' do
submission.assignment.assignment_configuration_tool_lookups.create!(tool_product_code: 'turnitin-lti',
tool_vendor_code: 'turnitin.com', tool_type: 'Lti::MessageHandler')
expect_event('plagiarism_resubmit',
hash_including(
associated_integration_id: "turnitin.com-turnitin-lti"
))
Canvas::LiveEvents.plagiarism_resubmit(submission)
end
end
end
@ -804,58 +834,82 @@ describe Canvas::LiveEvents do
end
describe '.assignment_created' do
it 'triggers a live event with assignment details' do
before :each do
course_with_student_submissions
assignment = @course.assignments.first
@assignment = @course.assignments.first
end
it 'triggers a live event with assignment details' do
expect_event('assignment_created',
hash_including({
assignment_id: assignment.global_id.to_s,
assignment_id: @assignment.global_id.to_s,
context_id: @course.global_id.to_s,
context_uuid: @course.uuid,
context_type: 'Course',
workflow_state: assignment.workflow_state,
title: assignment.title,
description: assignment.description,
due_at: assignment.due_at,
unlock_at: assignment.unlock_at,
lock_at: assignment.lock_at,
points_possible: assignment.points_possible,
lti_assignment_id: assignment.lti_context_id,
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
workflow_state: @assignment.workflow_state,
title: @assignment.title,
description: @assignment.description,
due_at: @assignment.due_at,
unlock_at: @assignment.unlock_at,
lock_at: @assignment.lock_at,
points_possible: @assignment.points_possible,
lti_assignment_id: @assignment.lti_context_id,
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
}.compact!)).once
Canvas::LiveEvents.assignment_created(assignment)
Canvas::LiveEvents.assignment_created(@assignment)
end
it 'should include the associated_integration_id if the assignment has an assignment configuration tool lookup' do
@assignment.assignment_configuration_tool_lookups.create!(tool_product_code: 'turnitin-lti',
tool_vendor_code: 'turnitin.com', tool_type: 'Lti::MessageHandler')
expect_event('assignment_created',
hash_including(
associated_integration_id: "turnitin.com-turnitin-lti"
))
Canvas::LiveEvents.assignment_created(@assignment)
end
end
describe '.assignment_updated' do
it 'triggers a live event with assignment details' do
before :each do
course_with_student_submissions
assignment = @course.assignments.first
@assignment = @course.assignments.first
end
it 'triggers a live event with assignment details' do
expect_event('assignment_updated',
hash_including({
assignment_id: assignment.global_id.to_s,
assignment_id: @assignment.global_id.to_s,
context_id: @course.global_id.to_s,
context_uuid: @course.uuid,
context_type: 'Course',
workflow_state: assignment.workflow_state,
title: assignment.title,
description: assignment.description,
due_at: assignment.due_at,
unlock_at: assignment.unlock_at,
lock_at: assignment.lock_at,
points_possible: assignment.points_possible,
lti_assignment_id: assignment.lti_context_id,
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
workflow_state: @assignment.workflow_state,
title: @assignment.title,
description: @assignment.description,
due_at: @assignment.due_at,
unlock_at: @assignment.unlock_at,
lock_at: @assignment.lock_at,
points_possible: @assignment.points_possible,
lti_assignment_id: @assignment.lti_context_id,
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
}.compact!)).once
Canvas::LiveEvents.assignment_updated(assignment)
Canvas::LiveEvents.assignment_updated(@assignment)
end
it 'should include the associated_integration_id if the assignment has an assignment configuration tool lookup' do
@assignment.assignment_configuration_tool_lookups.create!(tool_product_code: 'turnitin-lti',
tool_vendor_code: 'turnitin.com', tool_type: 'Lti::MessageHandler')
expect_event('assignment_updated',
hash_including(
associated_integration_id: "turnitin.com-turnitin-lti"
))
Canvas::LiveEvents.assignment_updated(@assignment)
end
end