2017-01-14 02:24:28 +08:00
|
|
|
module AssignmentUtil
|
|
|
|
def self.due_date_required?(assignment)
|
2017-03-15 03:53:24 +08:00
|
|
|
assignment.post_to_sis.present? && due_date_required_for_account?(assignment.context)
|
2017-01-14 02:24:28 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.due_date_ok?(assignment)
|
2017-03-28 01:05:52 +08:00
|
|
|
!due_date_required?(assignment) ||
|
|
|
|
assignment.due_at.present? ||
|
|
|
|
assignment.grading_type == 'not_graded'
|
2017-01-14 02:24:28 +08:00
|
|
|
end
|
|
|
|
|
2017-01-20 06:11:35 +08:00
|
|
|
def self.assignment_name_length_required?(assignment)
|
2017-03-15 03:53:24 +08:00
|
|
|
assignment.post_to_sis.present? && name_length_required_for_account?(assignment.context)
|
2017-01-26 13:48:55 +08:00
|
|
|
end
|
|
|
|
|
2017-03-15 03:53:24 +08:00
|
|
|
def self.assignment_max_name_length(context)
|
|
|
|
account = Context.get_account(context)
|
|
|
|
account.try(:sis_assignment_name_length_input).try(:[], :value).to_i
|
2017-02-14 05:53:38 +08:00
|
|
|
end
|
|
|
|
|
2017-03-15 03:53:24 +08:00
|
|
|
def self.post_to_sis_friendly_name(context)
|
|
|
|
account = Context.get_account(context)
|
|
|
|
account.try(:root_account).try(:settings).try(:[], :sis_name) || "SIS"
|
2017-02-17 05:14:29 +08:00
|
|
|
end
|
|
|
|
|
2017-03-15 03:53:24 +08:00
|
|
|
def self.name_length_required_for_account?(context)
|
|
|
|
account = Context.get_account(context)
|
|
|
|
account.try(:sis_syncing).try(:[], :value) &&
|
|
|
|
account.try(:sis_assignment_name_length).try(:[], :value) &&
|
2017-04-08 02:13:40 +08:00
|
|
|
sis_integration_settings_enabled?(context)
|
2017-01-20 06:11:35 +08:00
|
|
|
end
|
2017-02-05 06:42:00 +08:00
|
|
|
|
2017-03-15 03:53:24 +08:00
|
|
|
def self.due_date_required_for_account?(context)
|
|
|
|
account = Context.get_account(context)
|
|
|
|
account.try(:sis_syncing).try(:[], :value).present? &&
|
|
|
|
account.try(:sis_require_assignment_due_date).try(:[], :value) &&
|
2017-04-08 02:13:40 +08:00
|
|
|
sis_integration_settings_enabled?(context)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.sis_integration_settings_enabled?(context)
|
|
|
|
account = Context.get_account(context)
|
2017-03-15 03:53:24 +08:00
|
|
|
account.try(:feature_enabled?, 'new_sis_integrations').present?
|
2017-02-05 06:42:00 +08:00
|
|
|
end
|
2017-01-20 06:11:35 +08:00
|
|
|
end
|