Add 'lti_user_id' to submission live events

Closes PLAT-2824

Test Plan:

- Create a submission with an attachment as a student in an
  assignmetn associated with a plagiarism detection tool.
- Verify that the live event emitted contains an `lti_user_id`
  that matches the `lti_context_id` of the student.
- As a teacher click the `resubmit to plagiarism tool` button in
  speedgrader. Verify that the live event emitted contains the
  `lti_user_id` filed set to the student's `lti_context_id`.

Change-Id: I26d1da652f22ef7fd1cde361688704598db29fa7
Reviewed-on: https://gerrit.instructure.com/125503
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
wdransfield 2017-09-11 08:33:41 -06:00 committed by Weston Dransfield
parent a32552808d
commit f848bf5c64
7 changed files with 39 additions and 2 deletions

View File

@ -1656,7 +1656,7 @@ class Assignment < ActiveRecord::Base
:group => group
})
homework.submitted_at = Time.zone.now
homework.lti_user_id = Lti::Asset.opaque_identifier_for(student)
homework.with_versioning(:explicit => (homework.submission_type != "discussion_topic")) do
if group
if student == original_student

View File

@ -0,0 +1,24 @@
#
# Copyright (C) 2015 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
class AddLtiStudentIdToSubmission < ActiveRecord::Migration[5.0]
tag :predeploy
def change
add_column :submissions, :lti_user_id, :string
end
end

View File

@ -332,6 +332,7 @@ by `asset_type` and `asset_id`.
| `submission_id` | The Canvas id of the new submission. |
| `assignment_id` | The Canvas id of the assignment being submitted. |
| `user_id` | The Canvas id of the user associated with the submission. |
| `lti_user_id` | The Lti id of the user associated with the submission. |
| `submitted_at` | The timestamp when the assignment was submitted. |
| `updated_at` | The time at which this assignment was last modified in any way |
| `score` | The raw score |
@ -350,6 +351,7 @@ by `asset_type` and `asset_id`.
| `submission_id` | The Canvas id of the new submission. |
| `assignment_id` | The Canvas id of the assignment being submitted. |
| `user_id` | The Canvas id of the user associated with the submission. |
| `lti_user_id` | The Lti id of the user associated with the submission. |
| `submitted_at` | The timestamp when the assignment was submitted. |
| `updated_at` | The time at which this assignment was last modified in any way |
| `score` | The raw score |
@ -368,6 +370,7 @@ by `asset_type` and `asset_id`.
| `submission_id` | The Canvas id of the new submission. |
| `assignment_id` | The Canvas id of the assignment being submitted. |
| `user_id` | The Canvas id of the user associated with the submission. |
| `lti_user_id` | The Lti id of the user associated with the submission. |
| `submitted_at` | The timestamp when the assignment was submitted. |
| `updated_at` | The time at which this assignment was last modified in any way |
| `score` | The raw score |

View File

@ -178,6 +178,7 @@ module Canvas::LiveEvents
assignment_id: submission.global_assignment_id,
user_id: submission.global_user_id,
submitted_at: submission.submitted_at,
lti_user_id: submission.lti_user_id,
graded_at: submission.graded_at,
updated_at: submission.updated_at,
score: submission.score,

View File

@ -345,6 +345,7 @@ describe Canvas::LiveEvents 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
))
@ -360,6 +361,7 @@ describe Canvas::LiveEvents 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
))
@ -374,6 +376,7 @@ describe Canvas::LiveEvents 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
))

View File

@ -1400,6 +1400,12 @@ describe Assignment do
expect(s3.late_policy_status).to eq "late"
expect(s3.seconds_late_override).to eq 120
end
it "sets the submission's 'lti_user_id'" do
setup_assignment_without_submission
submission = @a.submit_homework(@user)
expect(submission.lti_user_id).to eq @user.lti_context_id
end
end
describe "muting" do

View File

@ -96,7 +96,7 @@ describe "Notifications" do
fj('.ui-tabs-anchor:contains("Plain Text")').click
expect(f('.message-body')).to include_text('Anonymous User just made a new comment on the '\
'submission for User for assignment')
"submission for #{@student.reload.short_name} for assignment")
end
context "observer notifications" do