missing policy: ignore submissions for unpublished assignments

Changes the Missing Policy so that it does not apply grades to
missing submissions for unpublished assignments.

closes TALLY-610
flag=none

Test Plan:
* have a course with a student enrolled
* create a missing policy for the course
* create an assignment with a due and until date for the
  near future and do not publish the assignment
* wait for the due date to pass, and for the missing policy to run
* verify no submissions for the assignment were graded

Change-Id: I81c46154c2735d467cafb174aab44321115833bb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/227591
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Jonathan Fenton <jfenton@instructure.com>
This commit is contained in:
Spencer Olson 2020-02-21 13:55:54 -06:00
parent 823736d0fd
commit 6f4226498c
2 changed files with 13 additions and 0 deletions

View File

@ -37,6 +37,7 @@ class MissingPolicyApplicator
joins(assignment: {course: :late_policy}).
eager_load(:grading_period, assignment: [:post_policy, { course: [:late_policy, :default_post_policy] }]).
for_enrollments(Enrollment.all_active_or_pending).
merge(Assignment.published).
missing.
where(score: nil, grade: nil, cached_due_date: 1.day.ago(now)..now,
late_policies: { missing_submission_deduction_enabled: true })

View File

@ -121,6 +121,18 @@ describe MissingPolicyApplicator do
expect(submission.workflow_state).to eql 'graded'
end
it 'ignores submissions for unpublished assignments' do
assignment = create_recent_assignment
assignment.unpublish
late_policy_missing_enabled
applicator.apply_missing_deductions
submission = @course.submissions.first
expect(submission.score).to be_nil
expect(submission.grade).to be_nil
end
context "updated timestamps" do
before(:once) do
@frozen_now = now