Module: Course::Assessment::Submission::WorkflowEventConcern

Extended by:
ActiveSupport::Concern
Included in:
Course::Assessment::Submission
Defined in:
app/models/concerns/course/assessment/submission/workflow_event_concern.rb

Instance Method Summary collapse

Instance Method Details

#finalise(_ = nil) ⇒ Object (protected)

Handles the finalisation of a submission.

This finalises all current answers as well.


14
15
16
17
18
19
# File 'app/models/concerns/course/assessment/submission/workflow_event_concern.rb', line 14

def finalise(_ = nil)
  self. = Time.zone.now
  current_answers.select(&:attempting?).each(&:finalise!)

  assign_zero_experience_points if assessment.questions.empty?
end

#mark(_ = nil) ⇒ Object (protected)

Handles the marking of a submission.

This will grade all the answers, and set the points_awarded as a draft.


24
25
26
# File 'app/models/concerns/course/assessment/submission/workflow_event_concern.rb', line 24

def mark(_ = nil)
  publish_answers
end

#publish(_ = nil) ⇒ Object (protected)

Handles the publishing of a submission.

This grades all the answers as well.


37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/concerns/course/assessment/submission/workflow_event_concern.rb', line 37

def publish(_ = nil)
  publish_answers

  self.publisher = User.stamper || User.system
  self.published_at = Time.zone.now
  self.awarder = User.stamper || User.system
  self.awarded_at = Time.zone.now

  return unless persisted? && !assessment.autograded? && submission_graded_email_enabled?
  execute_after_commit { Course::Mailer.submission_graded_email(self).deliver_later }
end

#unmark(_ = nil) ⇒ Object (protected)


28
29
30
31
32
# File 'app/models/concerns/course/assessment/submission/workflow_event_concern.rb', line 28

def unmark(_ = nil)
  answers.each do |answer|
    answer.unmark! if answer.graded?
  end
end

#unsubmit(_ = nil) ⇒ Object (protected)

Handles the unsubmission of a submitted submission.


50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/models/concerns/course/assessment/submission/workflow_event_concern.rb', line 50

def unsubmit(_ = nil)
  # Skip the state validation in answers.
  @unsubmitting = true

  unsubmit_current_answers
  self.points_awarded = nil
  self.draft_points_awarded = nil
  self.awarded_at = nil
  self.awarder = nil
  self. = nil
  self.publisher = nil
  self.published_at = nil
end