fix anonymous annotation notification

fix issue where the notifications on annotations
made to a submission contain the name of the
grader even when anonymous annotations are enabled

fixes EVAL-3639
flag=none

Prerequisite: anonymise all annotations made by instructors
              on submissions for this assignment in DocViewer
Test plan(with doc DocViewer enabled):
  - As the student navigate to the assignment and submit.
  - As the teacher navigate to SpeedGrader and leave annotations for the student.
  - As the student navigate to your email inbox.
  - Open the “A new annotation has been made to your submission document” notification from Canvas.
  - Observe that it contains the name of the grader who made the annotation.

Test plan(without DocViewer):
  - Make sure spec passes from spec/messages/annotation_notification.erb_spec.rb

Change-Id: Ie8902b3a550354298f52f400c17a6447faacd38e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/337072
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Derek Williams <derek.williams@instructure.com>
QA-Review: Samuel Lee <samuel.lee@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
This commit is contained in:
Jackson Huang 2024-01-08 23:51:20 +01:00
parent dfb0e91749
commit 58060ef9b2
4 changed files with 83 additions and 7 deletions

View File

@ -6,7 +6,12 @@
<%= t :subject, "A new annotation has been made to your submission document" %>
<% end %>
<%= t :body, "A new annotation has been made by %{author} on the assignment %{assignment_name}.",
author: data.author_name, assignment_name: asset.assignment.name %>
<% if asset.assignment.anonymous_instructor_annotations %>
<p><%= t "A new annotation has been made on the assignment %{assignment_name}.",
assignment_name: asset.assignment.name %></p>
<% else %>
<p><%= t "A new annotation has been made by %{author} on the assignment %{assignment_name}.",
author: data.author_name, assignment_name: asset.assignment.name %></p>
<% end %>
<%= t("View Submission", link: content(:link)) %>

View File

@ -12,6 +12,10 @@
</a>
<% end %>
<p><%= t :body, "A new annotation has been made by %{author} on the assignment %{assignment_name}.",
author: data.author_name, assignment_name: asset.assignment.name %></p>
<% if asset.assignment.anonymous_instructor_annotations %>
<p><%= t "A new annotation has been made on the assignment %{assignment_name}.",
assignment_name: asset.assignment.name %></p>
<% else %>
<p><%= t "A new annotation has been made by %{author} on the assignment %{assignment_name}.",
author: data.author_name, assignment_name: asset.assignment.name %></p>
<% end %>

View File

@ -6,7 +6,12 @@
<%= t :subject, "A new annotation has been made to your submission document" %>
<% end %>
<%= t :body, "A new annotation has been made by %{author} on the assignment %{assignment_name}.",
author: data.author_name, assignment_name: asset.assignment.name %>
<% if asset.assignment.anonymous_instructor_annotations %>
<p><%= t "A new annotation has been made on the assignment %{assignment_name}.",
assignment_name: asset.assignment.name %></p>
<% else %>
<p><%= t "A new annotation has been made by %{author} on the assignment %{assignment_name}.",
author: data.author_name, assignment_name: asset.assignment.name %></p>
<% end %>
<%= t("View Submission", link: content(:link)) %>

View File

@ -0,0 +1,62 @@
# frozen_string_literal: true
#
# Copyright (C) 2017 - 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/>.
#
require_relative "messages_helper"
describe "annotation_notification" do
include MessagesCommon
let(:notification_name) { :annotation_notification }
let(:asset) { @submission }
let(:path_type) { :email }
let(:data) { { data: { author_name: "User 1" } } }
context ".email" do
context "base case" do
before :once do
assignment_model
@submission = submission_model(assignment: @assignment, user: @student)
end
it "renders" do
msg = generate_message(notification_name, path_type, asset, data)
expect(msg.subject).to match("A new annotation has been made to your submission document")
expect(msg.body).to match(/A new annotation has been made by User 1 on the assignment/)
expect(msg.body).to match(%r{#{HostUrl.protocol}://})
end
end
context "anonymous annotations" do
before :once do
assignment_model(anonymous_instructor_annotations: true)
@submission = submission_model(assignment: @assignment, user: @student)
end
it "renders" do
msg = generate_message(notification_name, path_type, asset, data)
expect(msg.subject).to match("A new annotation has been made to your submission document")
expect(msg.body).to match(/A new annotation has been made on the assignment/)
expect(msg.body).to match(%r{#{HostUrl.protocol}://})
end
end
end
end