Add group id to submission live events

Closes PLAT-2874

Test Plan:
- Create a group assignment associated with a
  plagiarism detection tool.
- As a student submit to the assignment and verify
  the resulting live event contains the group id.
- Resubmit to the assignment and verify the resulting
  live event contains the group id.
- Create an originality report for the submission.
- From speed grader trigger the resubmit to plagiarism
  tool provider button to emit a live event.
- Verify the resulting live event contains the submission's
  group id.

Change-Id: I3ae14946c2b08e4f0ae6bb5175621609bf31524c
Reviewed-on: https://gerrit.instructure.com/128835
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
wdransfield 2017-10-06 11:06:56 -06:00 committed by Weston Dransfield
parent aac714911f
commit c3a4e90334
3 changed files with 83 additions and 40 deletions

View File

@ -342,6 +342,7 @@ by `asset_type` and `asset_id`.
| `url` | The URL of the submission (for 'online_url' submissions) |
| `attempt` | This is the submission attempt number. |
| `lti_assignment_id` | The LTI assignment guid of the submission's assignment |
| `group_id` | The submissionss group ID if the assignment is a group assignment. |
#### `submission_updated`
@ -361,6 +362,7 @@ by `asset_type` and `asset_id`.
| `url` | The URL of the submission (for 'online_url' submissions) |
| `attempt` | This is the submission attempt number. |
| `lti_assignment_id` | The LTI assignment guid of the submission's assignment |
| `group_id` | The submissionss group ID if the assignment is a group assignment. |
#### `plagiarism_resubmit`
@ -380,6 +382,7 @@ by `asset_type` and `asset_id`.
| `url` | The URL of the submission (for 'online_url' submissions) |
| `attempt` | This is the submission attempt number. |
| `lti_assignment_id` | The LTI assignment guid of the submission's assignment |
| `group_id` | The submissionss group ID if the assignment is a group assignment. |
#### `user_created`

View File

@ -199,7 +199,8 @@ module Canvas::LiveEvents
body: LiveEvents.truncate(submission.body),
url: submission.url,
attempt: submission.attempt,
lti_assignment_id: submission.assignment.lti_context_id
lti_assignment_id: submission.assignment.lti_context_id,
group_id: submission.group_id
}
end

View File

@ -367,50 +367,89 @@ describe Canvas::LiveEvents do
end
end
describe ".submission_created" do
it "should include the user_id and assignment_id" do
context 'submissions' do
let(:submission) do
course_with_student_submissions
submission = @course.assignments.first.submissions.first
expect_event('submission_created',
hash_including(
user_id: @student.global_id.to_s,
lti_user_id: @student.lti_context_id,
assignment_id: submission.global_assignment_id.to_s,
lti_assignment_id: submission.assignment.lti_context_id.to_s
))
Canvas::LiveEvents.submission_created(submission)
@course.assignments.first.submissions.first
end
end
describe ".submission_updated" do
it "should include the user_id and assignment_id" do
course_with_student_submissions
submission = @course.assignments.first.submissions.first
expect_event('submission_updated',
hash_including(
user_id: @student.global_id.to_s,
lti_user_id: @student.lti_context_id,
assignment_id: submission.global_assignment_id.to_s,
lti_assignment_id: submission.assignment.lti_context_id.to_s
))
Canvas::LiveEvents.submission_updated(submission)
let(:group) do
Group.create!(
name: 'test group',
workflow_state: 'available',
context: submission.assignment.course
)
end
end
describe '.plagiarism_resubmit' do
it "should include the user_id and assignment_id" do
course_with_student_submissions
submission = @course.assignments.first.submissions.first
expect_event('plagiarism_resubmit',
hash_including(
user_id: @student.global_id.to_s,
lti_user_id: @student.lti_context_id,
assignment_id: submission.global_assignment_id.to_s,
lti_assignment_id: submission.assignment.lti_context_id.to_s
))
Canvas::LiveEvents.plagiarism_resubmit(submission)
before { submission }
describe ".submission_created" do
it "should include the user_id and assignment_id" do
expect_event('submission_created',
hash_including(
user_id: @student.global_id.to_s,
lti_user_id: @student.lti_context_id,
assignment_id: submission.global_assignment_id.to_s,
lti_assignment_id: submission.assignment.lti_context_id.to_s
))
Canvas::LiveEvents.submission_created(submission)
end
it 'should include the group_id if assignment is a group assignment' do
submission.update_attributes(group: group)
expect_event('submission_created',
hash_including(
group_id: group.id.to_s
))
Canvas::LiveEvents.submission_created(submission)
end
end
describe ".submission_updated" do
it "should include the user_id and assignment_id" do
expect_event('submission_updated',
hash_including(
user_id: @student.global_id.to_s,
lti_user_id: @student.lti_context_id,
assignment_id: submission.global_assignment_id.to_s,
lti_assignment_id: submission.assignment.lti_context_id.to_s
))
Canvas::LiveEvents.submission_updated(submission)
end
it 'should include the group_id if assignment is a group assignment' do
submission.update_attributes(group: group)
expect_event('submission_updated',
hash_including(
group_id: group.id.to_s
))
Canvas::LiveEvents.submission_updated(submission)
end
end
describe '.plagiarism_resubmit' do
it "should include the user_id and assignment_id" do
expect_event('plagiarism_resubmit',
hash_including(
user_id: @student.global_id.to_s,
lti_user_id: @student.lti_context_id,
assignment_id: submission.global_assignment_id.to_s,
lti_assignment_id: submission.assignment.lti_context_id.to_s
))
Canvas::LiveEvents.plagiarism_resubmit(submission)
end
it 'should include the group_id if assignment is a group assignment' do
submission.update_attributes(group: group)
expect_event('plagiarism_resubmit',
hash_including(
group_id: group.id.to_s
))
Canvas::LiveEvents.plagiarism_resubmit(submission)
end
end
end