diff --git a/app/models/submission.rb b/app/models/submission.rb index 74472d9f3..61c640286 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -266,51 +266,47 @@ def self.bulk_corrections!(tutorial, assignment, files) report end - private + def self.number_of_submissions(tutorial, assignment) + Submission.where(tutorial: tutorial, assignment: assignment) + .where.not(manuscript_data: nil).size + end - def matching_lecture - return true if tutorial&.lecture == assignment&.lecture + def self.number_of_corrections(tutorial, assignment) + Submission.where(tutorial: tutorial, assignment: assignment) + .where.not(correction_data: nil).size + end - errors.add(:tutorial, :lecture_not_matching) - end + def self.number_of_late_submissions(tutorial, assignment) + Submission.where(tutorial: tutorial, assignment: assignment) + .where.not(manuscript_data: nil) + .count(&:too_late?) + end - def set_token - self.token = Submission.generate_token - end + def self.submissions_total(assignment) + Submission.where(assignment: assignment) + .where.not(manuscript_data: nil).size + end - def self.number_of_submissions(tutorial, assignment) - Submission.where(tutorial: tutorial, assignment: assignment) - .where.not(manuscript_data: nil).size - end + def self.corrections_total(assignment) + Submission.where(assignment: assignment) + .where.not(correction_data: nil).size + end - def self.number_of_corrections(tutorial, assignment) - Submission.where(tutorial: tutorial, assignment: assignment) - .where.not(correction_data: nil).size - end + def self.late_submissions_total(assignment) + Submission.where(assignment: assignment) + .where.not(manuscript_data: nil) + .count(&:too_late?) + end - def self.number_of_late_submissions(tutorial, assignment) - Submission.where(tutorial: tutorial, assignment: assignment) - .where.not(manuscript_data: nil) - .count(&:too_late?) - end + private - def self.submissions_total(assignment) - Submission.where(assignment: assignment) - .where.not(manuscript_data: nil).size - end + def matching_lecture + return true if tutorial&.lecture == assignment&.lecture - def self.corrections_total(assignment) - Submission.where(assignment: assignment) - .where.not(correction_data: nil).size + errors.add(:tutorial, :lecture_not_matching) end - def self.late_submissions_total(assignment) - Submission.where(assignment: assignment) - .where.not(manuscript_data: nil) - .count(&:too_late?) + def set_token + self.token = Submission.generate_token end - - private_class_method :number_of_submissions, :number_of_corrections, - :number_of_late_submissions, :submissions_total, - :corrections_total, :late_submissions_total end