Skip to content

Commit

Permalink
82 | Scope query for completed and assigned evaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
emmabjj committed Jan 8, 2025
1 parent c1432fc commit c163d11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/helpers/evaluations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def average_score(submission)

return Score.new(0, "0", "N/A") if assigned_evaluations.empty?

completed_evaluations = submission.evaluations.where.not(completed_at: nil)
completed_evaluations = submission.evaluations.
where(evaluator_submission_assignment: assigned_evaluations).
where.not(completed_at: nil)

unless completed_evaluations.count == assigned_evaluations.count
return Score.new(0, "0", "N/A")
Expand Down
20 changes: 18 additions & 2 deletions spec/helpers/evaluations_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,24 @@
end

it "does not include recused scores in the average" do
assigned = create(:evaluator_submission_assignment, :assigned, :completed, submission:)
recused = create(:evaluator_submission_assignment, :recused, :assigned, :completed, submission:)
submission = create(:submission)

assigned = create(:evaluator_submission_assignment, :assigned, submission: submission)
create(:evaluation,
evaluator_submission_assignment: assigned,
submission: submission,
total_score: 60,
completed_at: Time.current
)

recused = create(:evaluator_submission_assignment, :recused, submission: submission)
create(:evaluation,
evaluator_submission_assignment: recused,
submission: submission,
total_score: 80,
completed_at: Time.current
)

result = helper.average_score(submission)
expect(result.raw_score).to eq(assigned.evaluation.total_score)
end
Expand Down

0 comments on commit c163d11

Please sign in to comment.