Skip to content

Commit 282c866

Browse files
committed
grade calculator: ignore pending_review submissions
fixes CNVS-26685 Test plan: * make and take a quiz with multiple choice and essay questions * the student's quiz grade should not be included in their current score on the grades-overview page (or in the api) * the partial quiz grade *will* affect their "final" score. Change-Id: I70252375aac87c73e25b9e3dd7f3af4555826a97 Reviewed-on: https://gerrit.instructure.com/75754 Reviewed-by: Keith T. Garner <kgarner@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> Reviewed-by: Spencer Olson <solson@instructure.com> Tested-by: Jenkins QA-Review: KC Naegle <knaegle@instructure.com> Product-Review: Cameron Matheson <cameron@instructure.com>
1 parent bf306e7 commit 282c866

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/grade_calculator.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def compute_scores
5454
except(:order, :select).
5555
for_user(@user_ids).
5656
where(assignment_id: @assignments.map(&:id)).
57-
select("submissions.id, user_id, assignment_id, score, excused")
57+
select("submissions.id, user_id, assignment_id, score, excused, submissions.workflow_state")
5858
submissions_by_user = @submissions.group_by(&:user_id)
5959

6060
result = []
@@ -150,6 +150,9 @@ def create_group_sums(submissions, user_id, ignore_ungraded=true)
150150
# ignore submissions for muted assignments
151151
s = nil if @ignore_muted && a.muted?
152152

153+
# ignore pending_review quiz submissions
154+
s = nil if ignore_ungraded && s.try(:pending_review?)
155+
153156
{
154157
assignment: a,
155158
submission: s,

spec/lib/grade_calculator_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,21 @@ def nil_graded_assignment
372372
expect(@user.enrollments.first.computed_final_score).to eql(48.41)
373373
end
374374

375+
it "ignores pending_review submissions" do
376+
course_with_student(active_all: true)
377+
a1 = @course.assignments.create! name: "fake quiz", points_possible: 50
378+
a2 = @course.assignments.create! name: "assignment", points_possible: 50
379+
380+
s1 = a1.grade_student(@student, grade: 25).first
381+
Submission.update_all({workflow_state: "pending_review"}, {id: s1.id})
382+
383+
a2.grade_student(@student, grade: 50)
384+
385+
enrollment = @student.enrollments.first.reload
386+
expect(enrollment.computed_current_score).to eq 100.0
387+
expect(enrollment.computed_final_score).to eq 75.0
388+
end
389+
375390
it "should not include unpublished assignments" do
376391
two_graded_assignments
377392
@assignment2.unpublish

0 commit comments

Comments
 (0)