Skip to content

Commit

Permalink
refactor overdue_and_needs_submission and needs_grading?
Browse files Browse the repository at this point in the history
Change-Id: I2e8c424545b71be8136d04008433ff42eb96bc4d
Reviewed-on: https://gerrit.instructure.com/55831
Reviewed-by: Cameron Sutter <[email protected]>
Reviewed-by: Ryan Taylor <[email protected]>
Tested-by: Jenkins
QA-Review: Michael Hargiss <[email protected]>
Product-Review: Brian Finney <[email protected]>
  • Loading branch information
yenif committed Jun 9, 2015
1 parent 3e50a2a commit 232e2dc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions app/models/quizzes/quiz_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,14 @@ def self.needs_grading

# There is also a needs_grading scope which needs to replicate this logic
def needs_grading?(strict=false)
if strict && self.untaken? && self.overdue?(true)
true
elsif self.untaken? && self.end_at && self.end_at < Time.now
true
elsif self.completed? && !graded?
true
else
false
end
overdue_and_needs_submission?(strict) || (self.completed? && !graded?)
end

alias_method :overdue_and_needs_submission, :needs_grading?
def overdue_and_needs_submission?(strict=false)
(strict && self.untaken? && self.overdue?(true)) ||
(self.untaken? && self.end_at && self.end_at < Time.now)
end
alias_method :overdue_and_needs_submission, :overdue_and_needs_submission?

def has_seen_results?
!!self.has_seen_results
Expand Down

0 comments on commit 232e2dc

Please sign in to comment.