save context and annotation id on docviewer events
Context and annotation id are necessary keys to looking up an annotation in DocViewer. This just allows that information to be saved when it is sent from DocViewer. closes GRADE-1593 Test Plan - Create/edit dynamic_settings.yml and add in an entry under "config" that is: canvadoc: secret: "c2Vrcml0" * the secret is "sekrit" base64 encoded if you're curious. - Open a rails console and enter: `Canvas::Security.create_jwt({}, nil, 'sekrit', :HS512)` The resulting token is your auth token for the duration of testing. - Create an assignment that accepts file uploads. - As a student, submit to that with a document. - As a teacher, launch speedgrader once for that assignment and view the document. - Open a rails console and find the submission, the attachment for that submission, and the canvadoc id related to that attachment. - Post to the docviewer audit events url (submissions/:submission_id/docviewer_audit_events) with data in the body looking like: { docviewer_audit_event: { annotation_body: "", annotation_id: "23", color: "", content: "", context: "some context", created_at: "", modified_at: "", page: "", type: "" }, token: your token from the second step, canvas_user_id: id of the teacher, document_id: the canvadoc id } - Open a rails console and verify that an AnonymousOrModerationEvent with the attributes context and annotation_id saved in the payload. Change-Id: I7431fbbb93926e755db5fb83a2004f3fa232fc45 Reviewed-on: https://gerrit.instructure.com/165276 Tested-by: Jenkins Reviewed-by: Jeremy Neander <jneander@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Gary Mei <gmei@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
This commit is contained in:
parent
fe90328f24
commit
db48d23136
|
@ -38,15 +38,18 @@ class DocviewerAuditEventsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
event_params = docviewer_audit_event_params
|
||||
event = AnonymousOrModerationEvent.new(
|
||||
assignment: assignment,
|
||||
canvadoc: canvadoc,
|
||||
event_type: "docviewer_#{docviewer_audit_event_params[:event_type]}",
|
||||
event_type: "docviewer_#{event_params[:event_type]}",
|
||||
submission: submission,
|
||||
user: user,
|
||||
payload: {
|
||||
annotation_body: docviewer_audit_event_params[:annotation_body],
|
||||
related_annotation_id: docviewer_audit_event_params[:related_annotation_id]
|
||||
annotation_body: event_params[:annotation_body],
|
||||
annotation_id: event_params[:annotation_id],
|
||||
context: event_params[:context],
|
||||
related_annotation_id: event_params[:related_annotation_id]
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -75,6 +78,8 @@ class DocviewerAuditEventsController < ApplicationController
|
|||
|
||||
def docviewer_audit_event_params
|
||||
params.require(:docviewer_audit_event).permit(
|
||||
:annotation_id,
|
||||
:context,
|
||||
:event_type,
|
||||
:related_annotation_id,
|
||||
annotation_body: %i[color content created_at modified_at page type]
|
||||
|
|
|
@ -308,6 +308,22 @@ describe DocviewerAuditEventsController do
|
|||
expect(type).to eq 'a type'
|
||||
end
|
||||
|
||||
it "saves the annotation_id in the payload" do
|
||||
assignment = @course.assignments.create!(anonymous_grading: true, name: "anonymous")
|
||||
@submission = assignment.submit_homework(@student, submission_type: "online_upload", attachments: [@attachment])
|
||||
post :create, format: :json, params: default_params.deep_merge(docviewer_audit_event: { annotation_id: 23 })
|
||||
event = AnonymousOrModerationEvent.find_by!(assignment: assignment, submission: @submission)
|
||||
expect(event.payload.fetch("annotation_id")).to eq "23"
|
||||
end
|
||||
|
||||
it "saves the context in the payload" do
|
||||
assignment = @course.assignments.create!(anonymous_grading: true, name: "anonymous")
|
||||
@submission = assignment.submit_homework(@student, submission_type: "online_upload", attachments: [@attachment])
|
||||
post :create, format: :json, params: default_params.deep_merge(docviewer_audit_event: { context: "a context" })
|
||||
event = AnonymousOrModerationEvent.find_by!(assignment: assignment, submission: @submission)
|
||||
expect(event.payload.fetch("context")).to eq "a context"
|
||||
end
|
||||
|
||||
it 'saves the related_annotation_id in the payload' do
|
||||
assignment = Assignment.create!(course: @course, anonymous_grading: true, name: 'anonymous')
|
||||
@submission = assignment.submit_homework(@student, submission_type: 'online_upload', attachments: [@attachment])
|
||||
|
|
Loading…
Reference in New Issue