Skip to content

Commit

Permalink
prevent annotation notifications when unposted
Browse files Browse the repository at this point in the history
closes EVAL-2487
flag=none

Test Plan 1:
* Prerequisites: A course with one active student enrollment and one
  file upload assignment created

1. Set the Grade Posting Policy for the assignment to Manually.
2. As the student, set the notification preference(s) for Submission
   Comment to Notify Immediately.
3. Submit to the assignment as the student.
4. Annotate the submission in SpeedGrader.
5. View the student’s notifications and verify no annotation
   notification was sent.
6. Post grades to the student.
7. Annotate the submission in SpeedGrader.
8. View the student's notifications and verify an annotation
   notification was sent.

Test Plan 2:
* Prerequisites: A course with one active student enrollment and one
  file upload assignment created

1. Set the Grade Posting Policy for the assignment to Automatic.
2. As the student, set the notification preference(s) for Submission
   Comment to Notify Immediately.
3. Submit to the assignment as the student.
4. Annotate the submission in SpeedGrader.
5. View the student's notifications and verify an annotation
   notification was sent.

Change-Id: Iffde01e37435b615553ecada832a2b5640216134
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/293419
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: Kai Bjorkman <[email protected]>
Reviewed-by: Paulo Chaves <[email protected]>
Reviewed-by: Eduardo Escobar <[email protected]>
QA-Review: Kai Bjorkman <[email protected]>
Product-Review: Spencer Olson <[email protected]>
  • Loading branch information
spencerolson committed Jun 30, 2022
1 parent 18c459a commit 35cfb6f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/speed_grader/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def json
}

if url_opts[:enable_annotations]
url_opts[:disable_annotation_notifications] = assignment.post_manually? && !sub.posted?
url_opts[:enrollment_type] = canvadocs_user_role(course, current_user)
end

Expand Down
28 changes: 24 additions & 4 deletions spec/models/speed_grader/assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
end
end
let(:versioned_attachments) { sub[:submission_history][0][:submission][:versioned_attachments] }
let(:canvadoc_url) { versioned_attachments.first.dig(:attachment, :canvadoc_url) }

it "creates a non-annotatable DocViewer session for Discussion attachments" do
assignment.anonymous_grading = true
Expand All @@ -405,7 +406,6 @@
entry.save!
topic.ensure_submission(@student)

canvadoc_url = versioned_attachments.first.dig(:attachment, :canvadoc_url)
expect(canvadoc_url.include?("enable_annotations%22:false")).to eq true
end

Expand All @@ -417,7 +417,6 @@
entry.save!
topic.ensure_submission(@student)

canvadoc_url = versioned_attachments.first.fetch(:attachment).fetch(:canvadoc_url)
expect(canvadoc_url.include?("anonymous_instructor_annotations%22:true")).to eq true
end

Expand All @@ -428,17 +427,38 @@
entry.save!
topic.ensure_submission(@student)

canvadoc_url = versioned_attachments.first.fetch(:attachment).fetch(:canvadoc_url)
expect(canvadoc_url.include?("enrollment_type%22:%22teacher%22")).to eq true
end

it "passes submission id to DocViewer" do
submission = assignment.submit_homework(@student, attachments: [attachment])
allow(Canvadocs).to receive(:enabled?).and_return(true)

canvadoc_url = versioned_attachments.first.fetch(:attachment).fetch(:canvadoc_url)
expect(canvadoc_url.include?("%22submission_id%22:#{submission.id}")).to be true
end

describe "disable_annotation_notifications" do
it "disables annotations if the assignment posts manually and the submission is not posted" do
assignment.ensure_post_policy(post_manually: true)
assignment.submit_homework(@student, attachments: [attachment])
allow(Canvadocs).to receive(:enabled?).and_return(true)
expect(canvadoc_url).to include "disable_annotation_notifications%22:true"
end

it "enables annotations if the assignment posts automatically" do
assignment.submit_homework(@student, attachments: [attachment])
allow(Canvadocs).to receive(:enabled?).and_return(true)
expect(canvadoc_url).to include "disable_annotation_notifications%22:false"
end

it "enables annotations if the assignment posts manually and the submission has been posted" do
assignment.ensure_post_policy(post_manually: true)
submission = assignment.submit_homework(@student, attachments: [attachment])
assignment.post_submissions(submission_ids: [submission.id])
allow(Canvadocs).to receive(:enabled?).and_return(true)
expect(canvadoc_url).to include "disable_annotation_notifications%22:false"
end
end
end

it "includes submission missing status in each submission history version" do
Expand Down

0 comments on commit 35cfb6f

Please sign in to comment.