Update submissions_grade-changed notification to respect LGO

closes VICE-3486
flag=restrict_quantitative_data

Test Plan
1. Create an assignment as a teacher
2. As a student enable "send scores in notification"
3. As a student create the communication channels you want to test
4. As student, create a submission
5. As a teacher grade the submission
6. Check the students messages to verify submission graded message
7. in the console change the submission graded_at
7a. submission.graded_at = Time.zone.parse("Jan 1 2000")
7. as a teacher change the grade
8. verify that the grade changed notification respects lgo

Change-Id: Iceed6caebead2c69df6ff320d5839944d66d4c14
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/317562
Product-Review: Jody Sailor
Reviewed-by: Caleb Guanzon <cguanzon@instructure.com>
QA-Review: Drake Harper <drake.harper@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Jason Gillett 2023-05-05 11:05:37 -06:00
parent 1dc67d2ae2
commit 0a32ee7191
6 changed files with 72 additions and 7 deletions

View File

@ -21,9 +21,13 @@
<%= t :regraded_date, "re-graded: %{date}", :date => (datetime_string(force_zone(asset.graded_at)) rescue t(:no_date_set, "No Date Set")) %>
<% if user.try(:send_scores_in_emails?, asset.assignment.context) %>
<% if asset.excused? %>
<%= t :excused, "This assignment has been excused." %>
<%= t :excused, "This assignment has been excused." %>
<% elsif asset.score %>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% if asset.assignment.restrict_quantitative_data?(user)%>
<%=t :grade, "grade: %{letter_grade}", :letter_grade => asset.assignment.score_to_grade(asset.score, asset.grade, true)%>
<% else %>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% end %>
<% end %>
<% end %>

View File

@ -28,7 +28,11 @@
<% if asset.excused? %>
<p><%= t :excused, "This assignment has been excused." %></p>
<% elsif asset.score %>
<p><%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %></p>
<% if asset.assignment.restrict_quantitative_data?(user)%>
<p><%=t :grade, "grade: %{letter_grade}", :letter_grade => asset.assignment.score_to_grade(asset.score, asset.grade, true)%></p>
<% else %>
<p><%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %></p>
<% end %>
<% end %>
<% end %>

View File

@ -6,7 +6,11 @@
<%= t :regraded_date, "re-graded: %{date}", :date => (datetime_string(force_zone(asset.graded_at)) rescue t(:no_date_set, "No Date Set")) %>
<% if asset.score && user.try(:send_scores_in_emails?, asset.assignment.context) %>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% if asset.assignment.restrict_quantitative_data?(user)%>
<%=t :grade, "grade: %{letter_grade}", :letter_grade => asset.assignment.score_to_grade(asset.score, asset.grade, true)%>
<% else %>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% end %>
<% end %>
<%= t(:score_pending, "score pending review by the teacher") if asset.pending_review? %>

View File

@ -11,7 +11,11 @@
<% end %>
<%= t :regraded_date, "re-graded: %{date}", :date => (datetime_string(force_zone(asset.graded_at)) rescue t(:no_date_set, "No Date Set")) %>
<% if asset.score && user.try(:send_scores_in_emails?, asset.assignment.context) %>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% if asset.assignment.restrict_quantitative_data?(user)%>
<%=t :grade, "grade: %{letter_grade}", :letter_grade => asset.assignment.score_to_grade(asset.score, asset.grade, true)%>
<% else %>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% end %>
<% end %>
<%= t(:score_pending, "score pending review by the teacher") if asset.pending_review? %>

View File

@ -7,6 +7,10 @@
<%= t :tweet, "Canvas Alert - Grade Change: %{date}", :date => (datetime_string(force_zone(asset.graded_at)) rescue t(:no_date_set, "No Date Set")) %>
<% end %>
<% if asset.score -%>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% if asset.score && user.try(:send_scores_in_emails?, asset.assignment.context) %>
<% if asset.assignment.restrict_quantitative_data?(user)%>
<%=t :grade, "grade: %{letter_grade}", :letter_grade => asset.assignment.score_to_grade(asset.score, asset.grade, true)%>
<% else %>
<%= t :score, "score: %{score} out of %{total}", :score => asset.score, :total => (asset.assignment.points_possible || t(:not_applicable, "N/A")) %>
<% end %>
<% end -%> <%= t(:score_pending, "(pending review)") if asset.pending_review? %>

View File

@ -66,4 +66,49 @@ describe "submission_grade_changed" do
expect(message.body).to match("For #{@submission.user.name}")
end
end
context "Restrict Quantitative Data" do
let(:student) { student_in_course(course: @assignment.course, active_all: true).user }
let(:course_root_account) { @assignment.course.root_account }
before do
# truthy feature flag
course_root_account.enable_feature! :restrict_quantitative_data
# truthy setting
course_root_account.settings[:restrict_quantitative_data] = { value: true, locked: true }
course_root_account.save!
# truthy permission(since enabled is being "not"ed)
course_root_account.role_overrides.create!(role: student_role, enabled: false, permission: "restrict_quantitative_data")
course_root_account.reload
asset.assignment.update_attribute(:points_possible, 10)
asset.update_attribute(:score, 5)
student.preferences[:send_scores_in_emails] = true
student.save!
asset.save!
end
it "shows only the letter grade when RQD is enabled - twitter" do
message = generate_message(:submission_grade_changed, :twitter, asset, user: student)
expect(message.body).to include("grade: F")
end
it "shows only the letter grade when RQD is enabled - sms" do
message = generate_message(:submission_grade_changed, :sms, asset, user: student)
expect(message.body).to include("grade: F")
end
it "shows only the letter grade when RQD is enabled - email" do
message = generate_message(:submission_grade_changed, :email, asset, user: student)
expect(message.body).to include("grade: F")
expect(message.html_body).to include("grade: F")
end
it "shows only the letter grade when RQD is enabled - summary" do
message = generate_message(:submission_grade_changed, :summary, asset, user: student)
expect(message.body).to include("grade: F")
end
end
end