fix grade badge count with comments

due to an arel mistranslation the submission comment id was being used for
comparison instead of the submission id

fixes CNVS-5435

test plan:
- as a teacher, comment but do not score an assignment for a user
- as a student, you should have a badge for that submission comment
- go to the grades page
- the badge should be gone

Change-Id: Id4364e65cb917d54f7511355ce2619746d2e15fa
Reviewed-on: https://gerrit.instructure.com/20061
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
Simon Williams 2013-04-25 10:14:14 -06:00
parent 64a0ddd5c4
commit 1d6b4d6705
2 changed files with 16 additions and 4 deletions

View File

@ -79,8 +79,8 @@ class ContentParticipationCount < ActiveRecord::Base
where(submission_conditions).
where("submissions.score IS NOT NULL").
pluck(:id)
subs_with_comments = SubmissionComment.
joins(:submission => :assignment).
subs_with_comments = Submission.
joins(:assignment, :submission_comments).
where(submission_conditions).
where(<<-SQL, user).pluck(:id)
(submission_comments.hidden IS NULL OR NOT submission_comments.hidden)

View File

@ -125,6 +125,12 @@ describe ContentParticipationCount do
ContentParticipationCount.unread_submission_count_for(@course, @student).should == 1
end
it "should be read after viewing the graded assignment" do
@submission = @assignment.grade_student(@student, { :grade => 3 }).first
@submission.change_read_state("read", @student)
ContentParticipationCount.unread_submission_count_for(@course, @student).should == 0
end
it "should be unread after submission is graded" do
@assignment.submit_homework(@student)
@submission = @assignment.grade_student(@student, { :grade => 3 }).first
@ -136,10 +142,16 @@ describe ContentParticipationCount do
ContentParticipationCount.unread_submission_count_for(@course, @student).should == 1
end
it "should be unread after submission is commented on by self" do
it "should be read after viewing the submission comment" do
@submission = @assignment.grade_student(@student, { :grader => @teacher, :comment => "good!" }).first
@submission.change_read_state("read", @student)
ContentParticipationCount.unread_submission_count_for(@course, @student).should == 0
end
it "should be read after submission is commented on by self" do
@submission = @assignment.submit_homework(@student)
@comment = SubmissionComment.create!(:submission => @submission, :comment => "hi", :author => @student)
@submission.read?(@student).should be_true
ContentParticipationCount.unread_submission_count_for(@course, @student).should == 0
end
it "should be read if other submission fields change" do