class PenaltyPeriodSubmissionRule

Public Instance Methods

after_collection_message() click to toggle source
# File app/models/penalty_period_submission_rule.rb, line 9
def after_collection_message
  I18n.t 'submission_rules.penalty_period_submission_rule.after_collection_message'
end
apply_submission_rule(submission) click to toggle source
# File app/models/penalty_period_submission_rule.rb, line 30
def apply_submission_rule(submission)
  # Calculate the appropriate penalty, and attach the ExtraMark to the
  # submission Result
  result = submission.get_original_result
  overtime_hours = calculate_overtime_hours_from(submission.revision_timestamp)
  penalty_amount = calculate_penalty(overtime_hours)
  if penalty_amount > 0
    penalty = ExtraMark.new
    penalty.result = result
    penalty.extra_mark = -penalty_amount
    penalty.unit = ExtraMark::UNITS[:percentage]

    penalty.description = I18n.t 'submission_rules.penalty_period_submission_rule.extramark_description', :overtime_hours => overtime_hours, :penalty_amount => penalty_amount
    penalty.save
  end

  submission
end
assignment_valid?() click to toggle source

GracePeriodSubmissionRule works with all Assignments

# File app/models/penalty_period_submission_rule.rb, line 26
def assignment_valid?
  !assignment.nil?
end
commit_after_collection_message() click to toggle source

the Students with a message saying that the due date has passed, and the work they’re submitting will probably not be graded

# File app/models/penalty_period_submission_rule.rb, line 5
def commit_after_collection_message
  I18n.t 'submission_rules.penalty_period_submission_rule.commit_after_collection_message'
end
description_of_rule() click to toggle source
# File app/models/penalty_period_submission_rule.rb, line 49
def description_of_rule
  I18n.t 'submission_rules.penalty_period_submission_rule.description'
end
grader_tab_partial() click to toggle source
# File app/models/penalty_period_submission_rule.rb, line 53
def grader_tab_partial
  'submission_rules/penalty_period/grader_tab'
end
overtime_message(grouping) click to toggle source

This message will be dislayed to Students on viewing their file manager after the due date has passed, but before the calculated collection date.

# File app/models/penalty_period_submission_rule.rb, line 15
def overtime_message(grouping)
  # How far are we into overtime?
  overtime_hours = calculate_overtime_hours_from(Time.zone.now)
  # Calculate the penalty that the grouping will suffer
  potential_penalty = calculate_penalty(overtime_hours)

  I18n.t 'submission_rules.penalty_period_submission_rule.overtime_message', :potential_penalty => potential_penalty
end