submission missing for submission types and scores of zero

refs: CNVS-10301

This is the canvas-lms part of the fix for the ticket.  This adds logic to
the submission model missing? method to take into consideration whether the
assignment expects a submission or not and has been graded with a grade of zero.

Change-Id: I043dab161e1765268e34464ec49fd0276b16acbb
Reviewed-on: https://gerrit.instructure.com/29186
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
QA-Review: Nick Cloward <ncloward@instructure.com>
Tested-by: Nick Cloward <ncloward@instructure.com>
This commit is contained in:
Nick Cloward 2014-01-23 09:35:05 -07:00
parent 98f1648c3d
commit 7dd31931a7
2 changed files with 27 additions and 2 deletions

View File

@ -997,7 +997,8 @@ class Submission < ActiveRecord::Base
alias_method :late, :late?
def missing?
submitted_at.nil? && past_due?
return false if !past_due? || submitted_at.present?
assignment.expects_submission? || !(self.graded? && self.score > 0)
end
alias_method :missing, :missing?

View File

@ -925,9 +925,33 @@ describe Submission do
@submission.should_not be_missing
end
it "should be true if not submitted and past due" do
it "should be true if not submitted, past due, and expects a submission" do
@submission.assignment.submission_types = "online_quiz"
@submission.submission_type = nil # forces submitted_at to be nil
@submission.cached_due_date = 1.day.ago
# Regardless of score
@submission.score = 0.00000001
@submission.graded_at = Time.zone.now + 1.day
@submission.should be_missing
end
it "should be true if not submitted, score of zero, and does not expect a submission" do
@submission.assignment.submission_types = "on_paper"
@submission.submission_type = nil # forces submitted_at to be nil
@submission.cached_due_date = 1.day.ago
@submission.score = 0
@submission.graded_at = Time.zone.now + 1.day
@submission.should be_missing
end
it "should be false if not submitted, score greater than zero, and does not expect a submission" do
@submission.assignment.submission_types = "on_paper"
@submission.submission_type = nil # forces submitted_at to be nil
@submission.cached_due_date = 1.day.ago
@submission.score = 0.00000001
@submission.graded_at = Time.zone.now + 1.day
@submission.should be_missing
end
end