recheck submissions are still missing in missing_policy_applicator

recheck this value right before the missing policy is applied
to make sure users have not submitted while the applicator was running

closes EVAL-3279
flag=none

test plan:
- tests pass

Change-Id: I40648825b36bdc99821fe2fa5fc1f152776a04ae
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/336292
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Drake Harper <drake.harper@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
This commit is contained in:
Derek Williams 2024-01-02 15:16:30 -05:00
parent 63f5c82ba0
commit b828a91602
2 changed files with 15 additions and 1 deletions

View File

@ -56,7 +56,7 @@ class MissingPolicyApplicator
GuardRail.activate(:primary) do
plucked_submissions = submissions.pluck(:user_id, :id, :course_id)
submissions = Submission.active.where(id: submissions)
submissions = Submission.active.missing.where(id: submissions)
submissions.update_all(
score:,

View File

@ -451,5 +451,19 @@ describe MissingPolicyApplicator do
end
end
end
describe "apply missing deduction" do
it "double checks and doesn't update submissions if they have been submitted" do
late_policy_missing_enabled
create_recent_assignment
submission = @course.submissions.first
submission.update_columns(score: nil, grade: nil, workflow_state: "submitted", submission_type: "online_text_entry")
assignment = submission.assignment
applicator.send(:apply_missing_deduction, assignment, [submission])
expect(submission.reload.score).to be_nil
end
end
end
end