content participation for peer reviews

content participation was not being updated for peer review comment or
rubric assessments if a teacher had not already done a comment or
assessment. badge counts should be updated for automatically posted
assignments when another student leaves a comment or rubric assessment.
this change has the content participation only check to make sure
the submission is posted? if it's a manually posted assignment.

fixes EVAL-2860
flag=visibility_feedback_student_grades_page
flag=assignments_2_student

test plan:
- create a peer review assignment with rubric
- assign a student to review another student's assignment
- submit the assignment for both students. then as the reviewer, leave
  a comment on the assignment. also do rubric assessment
- as the reviewee student, verify that the badge count increases and you
  are also able to mark the comment and rubric assessment as read by
  clicking onto the icons in the student grades page

Change-Id: I045cf4bf0ca910bd1bda999bf2c132d6133fd455
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/310487
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Jody Sailor
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Chris Soto 2023-02-06 13:33:22 -07:00 committed by Christopher Soto
parent ac8b57269f
commit d916265963
4 changed files with 20 additions and 7 deletions

View File

@ -61,11 +61,15 @@ class ContentParticipation < ActiveRecord::Base
participant
end
def self.content_posted?(content)
content.assignment.post_manually? ? content.posted? : true
end
def update_participation_count
return unless saved_change_to_workflow_state?
offset = if Account.site_admin.feature_enabled?(:visibility_feedback_student_grades_page)
content.posted? ? unread_count_offset : 0
ContentParticipation.content_posted?(content) ? unread_count_offset : 0
else
((workflow_state == "unread") ? 1 : -1)
end
@ -117,7 +121,7 @@ class ContentParticipation < ActiveRecord::Base
def self.update_existing_participation_item(participations, workflow_state, content_item, content)
participant = participations.find { |p| p.content_item == content_item }
return participant if participant.nil? || !content.posted? || same_workflow_state?(participant, workflow_state)
return participant if participant.nil? || !content_posted?(content) || same_workflow_state?(participant, workflow_state)
participations -= [participant]

View File

@ -97,17 +97,17 @@ class ContentParticipationCount < ActiveRecord::Base
SQL
muted_condition = " AND (assignments.muted IS NULL OR NOT assignments.muted)"
posted_at_condition = " AND submissions.posted_at IS NOT NULL"
posted_at_condition = " AND (submissions.posted_at IS NOT NULL OR post_policies.post_manually IS FALSE)"
visibility_feedback_enabled = Account.site_admin.feature_enabled?(:visibility_feedback_student_grades_page)
submission_conditions << (visibility_feedback_enabled ? posted_at_condition : muted_condition)
subs_with_grades = Submission.active.graded
.joins(:assignment)
.joins(assignment: [:post_policy])
.where(submission_conditions)
.where.not(submissions: { score: nil })
.pluck(:id)
subs_with_comments = Submission.active
.joins(:assignment, :submission_comments)
.joins(:submission_comments, assignment: [:post_policy])
.where(submission_conditions)
.where(<<~SQL.squish, user).pluck(:id)
(submission_comments.hidden IS NULL OR NOT submission_comments.hidden)
@ -116,7 +116,7 @@ class ContentParticipationCount < ActiveRecord::Base
AND submission_comments.author_id <> ?
SQL
subs_with_assessments = Submission.active
.joins(:assignment, :rubric_assessments)
.joins(:rubric_assessments, assignment: [:post_policy])
.where(submission_conditions)
.where.not(rubric_assessments: { data: nil })
.pluck(:id)

View File

@ -211,6 +211,14 @@ describe ContentParticipationCount do
expect(ContentParticipationCount.unread_submission_count_for(@course, @student)).to eq 0
end
it "counts unread for automatically posted submissions that have no posted_at" do
Account.site_admin.enable_feature!(:visibility_feedback_student_grades_page)
student2 = User.create!
@submission = @assignment.update_submission(@student, { commenter: student2, comment: "good!" }).first
expect(@submission.reload.posted_at).to be nil
expect(ContentParticipationCount.unread_submission_count_for(@course, @student)).to eq 1
end
context "muted assignments" do
it "ignores counts from muted assignments" do
@assignment.grade_student(@student, grade: 3, grader: @teacher)

View File

@ -98,7 +98,8 @@ describe ContentParticipation do
end.to change(ContentParticipation, :count).by 1
end
it "doesn't change the read state if submission is not posted" do
it "doesn't change the read state if submission is not posted and post policy is manual" do
@assignment.ensure_post_policy(post_manually: true)
@content.update_columns(posted_at: nil)
ContentParticipation.participate(content: @content, user: @student, workflow_state: "unread")