2017-04-28 04:02:40 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2012 - present Instructure, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-12-13 03:14:17 +08:00
|
|
|
module DatesOverridable
|
2013-07-24 09:46:05 +08:00
|
|
|
attr_accessor :applied_overrides, :overridden_for_user, :overridden,
|
2016-10-18 23:43:09 +08:00
|
|
|
:has_no_overrides, :has_too_many_overrides, :preloaded_override_students
|
2013-02-05 08:51:39 +08:00
|
|
|
attr_writer :without_overrides
|
2014-09-24 04:23:30 +08:00
|
|
|
include DifferentiableAssignment
|
2012-12-20 04:38:12 +08:00
|
|
|
|
2016-09-08 23:28:13 +08:00
|
|
|
class NotOverriddenError < RuntimeError; end
|
|
|
|
|
2012-12-13 03:14:17 +08:00
|
|
|
def self.included(base)
|
|
|
|
base.has_many :assignment_overrides, :dependent => :destroy
|
2015-11-20 08:14:32 +08:00
|
|
|
base.has_many :active_assignment_overrides, -> { where(workflow_state: 'active') }, class_name: 'AssignmentOverride'
|
2017-11-07 04:57:54 +08:00
|
|
|
base.has_many :assignment_override_students, -> { where(workflow_state: 'active') }, :dependent => :destroy
|
|
|
|
base.has_many :all_assignment_override_students, class_name: 'AssignmentOverrideStudent', :dependent => :destroy
|
2014-02-12 06:11:25 +08:00
|
|
|
|
2016-01-07 04:18:06 +08:00
|
|
|
base.validates_associated :active_assignment_overrides
|
2012-12-29 05:02:21 +08:00
|
|
|
|
|
|
|
base.extend(ClassMethods)
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
def without_overrides
|
|
|
|
@without_overrides || self
|
|
|
|
end
|
|
|
|
|
2016-10-06 07:09:26 +08:00
|
|
|
def overridden_for(user, skip_clone: false)
|
|
|
|
AssignmentOverrideApplicator.assignment_overridden_for(self, user, skip_clone: skip_clone)
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
# All overrides, not just dates
|
2016-02-02 05:21:58 +08:00
|
|
|
def overrides_for(user, opts={})
|
|
|
|
overrides = AssignmentOverrideApplicator.overrides_for_assignment_and_user(self, user)
|
2016-02-18 16:24:07 +08:00
|
|
|
if opts[:ensure_set_not_empty]
|
|
|
|
overrides.select(&:set_not_empty?)
|
2016-02-02 05:21:58 +08:00
|
|
|
else
|
|
|
|
overrides
|
|
|
|
end
|
2014-02-12 06:11:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def overridden_for?(user)
|
|
|
|
overridden && (overridden_for_user == user)
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_overrides?
|
2017-10-19 03:32:28 +08:00
|
|
|
if current_version?
|
|
|
|
assignment_overrides.loaded? ? assignment_overrides.any?(&:active?) : assignment_overrides.active.exists?
|
|
|
|
else
|
|
|
|
# the old version's overrides might have be deleted too but it's probably more trouble than it's worth to check here
|
|
|
|
assignment_overrides.loaded? ? assignment_overrides.any? : assignment_overrides.exists?
|
|
|
|
end
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
|
|
|
|
make fancy midnight work for assignment overrides
also fixes an issue where some dates display as "Friday at 11:59pm" instead
of just "Friday"
Also does a little bit of refactoring and spec backfilling for the
override list presenter. The override list presenter now returns a much
more friendly list of "due date" hashes to the outside world to make it
easier to consume in views. Views don't have to format the dates by
passing in a hash anymore.
test plan:
- specs should pass
- as a teacher, create an assignment with overrides using the web
form. In one of the overrides, enter a day like March 1 at 12am.
- save the overrides
- Make sure fancy midnight works for lock dates and due dates, but not
unlock dates (12:00 am unlock date should show up as 12:00 am, not
11:59 pm)
- on the assignment's show page, you should just see "Friday", meaning
that the assignment is due at 11:59 pm on March 1.
- The "fancy midnight" scheme should work correctly for
assignments,quizzes,and discussion topics, including the default due
dates.
- Be sure to check that the dates show up correctly on the
assignment,quiz, and discussion show pages.
- Be sure to make an override that has a blank due_at, lock_at, and
unlock_at, but has a default due date, lock date, and unlock date.
The overrides should not inherit from the default due date (fixes
CNVS-4216)
fixes CNVS-4216, CNVS-4004, CNVS-3890
Change-Id: I8b5e10c074eb2a237a1298cb7def0cb32d3dcb7f
Reviewed-on: https://gerrit.instructure.com/18142
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2013-03-06 00:04:59 +08:00
|
|
|
def has_active_overrides?
|
2016-09-17 01:54:19 +08:00
|
|
|
active_assignment_overrides.any?
|
make fancy midnight work for assignment overrides
also fixes an issue where some dates display as "Friday at 11:59pm" instead
of just "Friday"
Also does a little bit of refactoring and spec backfilling for the
override list presenter. The override list presenter now returns a much
more friendly list of "due date" hashes to the outside world to make it
easier to consume in views. Views don't have to format the dates by
passing in a hash anymore.
test plan:
- specs should pass
- as a teacher, create an assignment with overrides using the web
form. In one of the overrides, enter a day like March 1 at 12am.
- save the overrides
- Make sure fancy midnight works for lock dates and due dates, but not
unlock dates (12:00 am unlock date should show up as 12:00 am, not
11:59 pm)
- on the assignment's show page, you should just see "Friday", meaning
that the assignment is due at 11:59 pm on March 1.
- The "fancy midnight" scheme should work correctly for
assignments,quizzes,and discussion topics, including the default due
dates.
- Be sure to check that the dates show up correctly on the
assignment,quiz, and discussion show pages.
- Be sure to make an override that has a blank due_at, lock_at, and
unlock_at, but has a default due date, lock date, and unlock date.
The overrides should not inherit from the default due date (fixes
CNVS-4216)
fixes CNVS-4216, CNVS-4004, CNVS-3890
Change-Id: I8b5e10c074eb2a237a1298cb7def0cb32d3dcb7f
Reviewed-on: https://gerrit.instructure.com/18142
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2013-03-06 00:04:59 +08:00
|
|
|
end
|
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
def multiple_due_dates?
|
|
|
|
if overridden
|
|
|
|
!!multiple_due_dates_apply_to?(overridden_for_user)
|
|
|
|
else
|
2016-09-08 23:28:13 +08:00
|
|
|
raise NotOverriddenError, "#{self.class.name} has not been overridden"
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
2014-02-12 06:11:25 +08:00
|
|
|
end
|
2012-12-13 03:14:17 +08:00
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
def multiple_due_dates_apply_to?(user)
|
|
|
|
return false if context.user_has_been_student?(user)
|
2012-12-13 03:14:17 +08:00
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
if context.user_has_been_observer?(user)
|
|
|
|
observed_student_due_dates(user).length > 1
|
|
|
|
elsif context.user_has_been_admin?(user)
|
|
|
|
dates = all_dates_visible_to(user)
|
|
|
|
dates && dates.map{ |hash| self.class.due_date_compare_value(hash[:due_at]) }.uniq.size > 1
|
2012-12-13 03:14:17 +08:00
|
|
|
elsif context.user_has_no_enrollments?(user)
|
2014-02-12 06:11:25 +08:00
|
|
|
all_due_dates.length > 1
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def all_due_dates
|
2014-12-04 00:36:34 +08:00
|
|
|
due_at_overrides = assignment_overrides.loaded? ? assignment_overrides.select{|ao| ao.active? && ao.due_at_overridden} : assignment_overrides.active.overriding_due_at
|
|
|
|
dates = due_at_overrides.map(&:as_hash)
|
|
|
|
dates << base_due_date_hash unless differentiated_assignments_applies?
|
|
|
|
dates
|
2014-04-17 03:45:28 +08:00
|
|
|
end
|
|
|
|
|
2016-02-03 07:32:04 +08:00
|
|
|
# returns a hash of observer, student, or admin to course ids.
|
|
|
|
# the observer bucket is additionally a hash with the values being a set
|
|
|
|
# of the users they observer (possibly including nil, for unassociated observers)
|
|
|
|
# note that #include?(course_id) will work equivalently on a Hash (of observers)
|
|
|
|
# or an array (of admins or students)
|
|
|
|
def self.precache_enrollments_for_multiple_assignments(assignments, user)
|
|
|
|
courses_user_has_been_enrolled_in = { observer: {}, student: [], admin: []}
|
|
|
|
current_shard = Shard.current
|
|
|
|
Shard.partition_by_shard(assignments) do |shard_assignments|
|
|
|
|
Enrollment.where(course_id: shard_assignments.map(&:context), user_id: user).
|
|
|
|
active.
|
2017-03-14 06:08:22 +08:00
|
|
|
distinct.
|
2016-02-03 07:32:04 +08:00
|
|
|
# duplicate the subquery logic of ObserverEnrollment.observed_users, where it verifies the observee exists
|
|
|
|
where("associated_user_id IS NULL OR EXISTS (
|
|
|
|
SELECT 1 FROM #{Enrollment.quoted_table_name} e2
|
|
|
|
WHERE e2.type IN ('StudentEnrollment', 'StudentViewEnrollment')
|
|
|
|
AND e2.workflow_state NOT IN ('rejected', 'completed', 'deleted', 'inactive')
|
|
|
|
AND e2.user_id=enrollments.associated_user_id
|
|
|
|
AND e2.course_id=enrollments.course_id)").
|
|
|
|
pluck(:course_id, :type, :associated_user_id).each do |(course_id, type, associated_user_id)|
|
|
|
|
relative_course_id = Shard.relative_id_for(course_id, Shard.current, current_shard)
|
|
|
|
bucket = case type
|
|
|
|
when 'ObserverEnrollment' then :observer
|
|
|
|
when 'StudentEnrollment', 'StudentViewEnrollment' then :student
|
|
|
|
# when 'TeacherEnrollment', 'TaEnrollment', 'DesignerEnrollment' then :admin
|
|
|
|
else; :admin
|
|
|
|
end
|
|
|
|
if bucket == :observer
|
|
|
|
observees = (courses_user_has_been_enrolled_in[bucket][relative_course_id] ||= Set.new)
|
|
|
|
observees << Shard.relative_id_for(associated_user_id, Shard.current, current_shard)
|
|
|
|
else
|
|
|
|
courses_user_has_been_enrolled_in[bucket] << relative_course_id
|
|
|
|
end
|
2014-04-17 03:45:28 +08:00
|
|
|
end
|
2013-12-05 06:09:17 +08:00
|
|
|
end
|
2016-02-03 07:32:04 +08:00
|
|
|
courses_user_has_been_enrolled_in
|
|
|
|
end
|
|
|
|
|
|
|
|
def all_dates_visible_to(user, courses_user_has_been_enrolled_in: nil)
|
|
|
|
return all_due_dates if user.nil?
|
|
|
|
|
|
|
|
if courses_user_has_been_enrolled_in
|
|
|
|
if courses_user_has_been_enrolled_in[:observer][context_id].try(:any?)
|
|
|
|
observed_student_due_dates(user, courses_user_has_been_enrolled_in[:observer][context_id].to_a)
|
|
|
|
elsif courses_user_has_been_enrolled_in[:student].include?(context_id) ||
|
|
|
|
courses_user_has_been_enrolled_in[:admin].include?(context_id) ||
|
|
|
|
courses_user_has_been_enrolled_in[:observer].include?(context_id)
|
|
|
|
overrides = overrides_for(user)
|
|
|
|
overrides = overrides.map(&:as_hash)
|
|
|
|
if !differentiated_assignments_applies? &&
|
|
|
|
(overrides.empty? || courses_user_has_been_enrolled_in[:admin].include?(context_id))
|
|
|
|
overrides << base_due_date_hash
|
|
|
|
end
|
|
|
|
overrides
|
|
|
|
else
|
|
|
|
all_due_dates
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if ObserverEnrollment.observed_students(context, user).any?
|
|
|
|
observed_student_due_dates(user)
|
|
|
|
elsif context.user_has_been_student?(user) ||
|
|
|
|
context.user_has_been_admin?(user) ||
|
|
|
|
context.user_has_been_observer?(user)
|
|
|
|
overrides = overrides_for(user)
|
|
|
|
overrides = overrides.map(&:as_hash)
|
|
|
|
if !differentiated_assignments_applies? && (overrides.empty? || context.user_has_been_admin?(user))
|
|
|
|
overrides << base_due_date_hash
|
|
|
|
end
|
|
|
|
overrides
|
|
|
|
else
|
|
|
|
all_due_dates
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
make fancy midnight work for assignment overrides
also fixes an issue where some dates display as "Friday at 11:59pm" instead
of just "Friday"
Also does a little bit of refactoring and spec backfilling for the
override list presenter. The override list presenter now returns a much
more friendly list of "due date" hashes to the outside world to make it
easier to consume in views. Views don't have to format the dates by
passing in a hash anymore.
test plan:
- specs should pass
- as a teacher, create an assignment with overrides using the web
form. In one of the overrides, enter a day like March 1 at 12am.
- save the overrides
- Make sure fancy midnight works for lock dates and due dates, but not
unlock dates (12:00 am unlock date should show up as 12:00 am, not
11:59 pm)
- on the assignment's show page, you should just see "Friday", meaning
that the assignment is due at 11:59 pm on March 1.
- The "fancy midnight" scheme should work correctly for
assignments,quizzes,and discussion topics, including the default due
dates.
- Be sure to check that the dates show up correctly on the
assignment,quiz, and discussion show pages.
- Be sure to make an override that has a blank due_at, lock_at, and
unlock_at, but has a default due date, lock date, and unlock date.
The overrides should not inherit from the default due date (fixes
CNVS-4216)
fixes CNVS-4216, CNVS-4004, CNVS-3890
Change-Id: I8b5e10c074eb2a237a1298cb7def0cb32d3dcb7f
Reviewed-on: https://gerrit.instructure.com/18142
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2013-03-06 00:04:59 +08:00
|
|
|
end
|
|
|
|
|
2016-02-03 07:32:04 +08:00
|
|
|
def observed_student_due_dates(user, observed_student_ids = nil)
|
|
|
|
observed_students = if observed_student_ids
|
|
|
|
User.find(observed_student_ids)
|
|
|
|
else
|
|
|
|
ObserverEnrollment.observed_students(context, user).keys
|
|
|
|
end
|
|
|
|
dates = observed_students.map do |student|
|
2014-02-12 06:11:25 +08:00
|
|
|
self.all_dates_visible_to(student)
|
|
|
|
end
|
|
|
|
dates.flatten.uniq
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
|
|
|
|
2013-08-21 03:33:02 +08:00
|
|
|
def dates_hash_visible_to(user)
|
|
|
|
all_dates = all_dates_visible_to(user)
|
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
if all_dates
|
2014-04-17 03:45:28 +08:00
|
|
|
# remove base if all sections are set
|
2015-02-07 02:13:33 +08:00
|
|
|
overrides = all_dates.select{ |d| d[:set_type] == 'CourseSection' }
|
2015-06-26 03:35:23 +08:00
|
|
|
if overrides.count > 0 && overrides.count == context.active_section_count
|
2014-02-12 06:11:25 +08:00
|
|
|
all_dates.delete_if {|d| d[:base] }
|
|
|
|
end
|
2013-08-21 03:33:02 +08:00
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
formatted_dates_hash(all_dates)
|
|
|
|
else
|
|
|
|
[due_date_hash]
|
|
|
|
end
|
2014-02-13 17:23:06 +08:00
|
|
|
end
|
|
|
|
|
2015-10-07 01:39:07 +08:00
|
|
|
def teacher_due_date_for_display(user)
|
|
|
|
ao = overridden_for user
|
2018-04-24 05:33:03 +08:00
|
|
|
due_at || ao.due_at || all_due_dates.dig(0, :due_at)
|
2015-10-07 01:39:07 +08:00
|
|
|
end
|
|
|
|
|
2014-02-13 17:23:06 +08:00
|
|
|
def formatted_dates_hash(dates)
|
2018-04-24 05:33:03 +08:00
|
|
|
return [] if dates.blank?
|
2014-05-29 04:54:41 +08:00
|
|
|
|
2014-02-13 17:23:06 +08:00
|
|
|
dates = dates.sort_by do |date|
|
2013-08-21 03:33:02 +08:00
|
|
|
due_at = date[:due_at]
|
2014-03-18 04:54:26 +08:00
|
|
|
[ due_at.present? ? CanvasSort::First : CanvasSort::Last, due_at.presence || CanvasSort::First ]
|
2013-08-21 03:33:02 +08:00
|
|
|
end
|
|
|
|
|
2014-03-05 00:02:02 +08:00
|
|
|
dates.map { |h| h.slice(:id, :due_at, :unlock_at, :lock_at, :title, :base) }
|
2013-08-21 03:33:02 +08:00
|
|
|
end
|
|
|
|
|
2012-12-13 03:14:17 +08:00
|
|
|
def due_date_hash
|
make fancy midnight work for assignment overrides
also fixes an issue where some dates display as "Friday at 11:59pm" instead
of just "Friday"
Also does a little bit of refactoring and spec backfilling for the
override list presenter. The override list presenter now returns a much
more friendly list of "due date" hashes to the outside world to make it
easier to consume in views. Views don't have to format the dates by
passing in a hash anymore.
test plan:
- specs should pass
- as a teacher, create an assignment with overrides using the web
form. In one of the overrides, enter a day like March 1 at 12am.
- save the overrides
- Make sure fancy midnight works for lock dates and due dates, but not
unlock dates (12:00 am unlock date should show up as 12:00 am, not
11:59 pm)
- on the assignment's show page, you should just see "Friday", meaning
that the assignment is due at 11:59 pm on March 1.
- The "fancy midnight" scheme should work correctly for
assignments,quizzes,and discussion topics, including the default due
dates.
- Be sure to check that the dates show up correctly on the
assignment,quiz, and discussion show pages.
- Be sure to make an override that has a blank due_at, lock_at, and
unlock_at, but has a default due date, lock date, and unlock date.
The overrides should not inherit from the default due date (fixes
CNVS-4216)
fixes CNVS-4216, CNVS-4004, CNVS-3890
Change-Id: I8b5e10c074eb2a237a1298cb7def0cb32d3dcb7f
Reviewed-on: https://gerrit.instructure.com/18142
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2013-03-06 00:04:59 +08:00
|
|
|
hash = { :due_at => due_at, :unlock_at => unlock_at, :lock_at => lock_at }
|
2012-12-13 03:14:17 +08:00
|
|
|
if self.is_a?(Assignment)
|
|
|
|
hash.merge!({ :all_day => all_day, :all_day_date => all_day_date })
|
make fancy midnight work for assignment overrides
also fixes an issue where some dates display as "Friday at 11:59pm" instead
of just "Friday"
Also does a little bit of refactoring and spec backfilling for the
override list presenter. The override list presenter now returns a much
more friendly list of "due date" hashes to the outside world to make it
easier to consume in views. Views don't have to format the dates by
passing in a hash anymore.
test plan:
- specs should pass
- as a teacher, create an assignment with overrides using the web
form. In one of the overrides, enter a day like March 1 at 12am.
- save the overrides
- Make sure fancy midnight works for lock dates and due dates, but not
unlock dates (12:00 am unlock date should show up as 12:00 am, not
11:59 pm)
- on the assignment's show page, you should just see "Friday", meaning
that the assignment is due at 11:59 pm on March 1.
- The "fancy midnight" scheme should work correctly for
assignments,quizzes,and discussion topics, including the default due
dates.
- Be sure to check that the dates show up correctly on the
assignment,quiz, and discussion show pages.
- Be sure to make an override that has a blank due_at, lock_at, and
unlock_at, but has a default due date, lock date, and unlock date.
The overrides should not inherit from the default due date (fixes
CNVS-4216)
fixes CNVS-4216, CNVS-4004, CNVS-3890
Change-Id: I8b5e10c074eb2a237a1298cb7def0cb32d3dcb7f
Reviewed-on: https://gerrit.instructure.com/18142
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2013-03-06 00:04:59 +08:00
|
|
|
elsif self.assignment
|
|
|
|
hash.merge!({ :all_day => assignment.all_day, :all_day_date => assignment.all_day_date})
|
2012-12-13 03:14:17 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
if @applied_overrides && override = @applied_overrides.find { |o| o.due_at == due_at }
|
|
|
|
hash[:override] = override
|
|
|
|
hash[:title] = override.title
|
|
|
|
end
|
|
|
|
|
|
|
|
hash
|
|
|
|
end
|
|
|
|
|
2014-02-12 06:11:25 +08:00
|
|
|
def base_due_date_hash
|
|
|
|
without_overrides.due_date_hash.merge(:base => true)
|
2012-12-29 05:02:21 +08:00
|
|
|
end
|
|
|
|
|
2019-05-07 04:24:47 +08:00
|
|
|
def context_module_tag_info(user, context, user_is_admin: false, has_submission: )
|
2019-06-05 02:54:47 +08:00
|
|
|
return {} unless user
|
2015-12-05 05:15:30 +08:00
|
|
|
self.association(:context).target ||= context
|
2019-05-07 04:24:47 +08:00
|
|
|
tag_info = Rails.cache.fetch_with_batched_keys(
|
2019-12-03 22:05:31 +08:00
|
|
|
["context_module_tag_info3", user.cache_key(:enrollments), user.cache_key(:groups)].cache_key,
|
2019-05-07 04:24:47 +08:00
|
|
|
batch_object: self, batched_keys: :availability
|
|
|
|
) do
|
|
|
|
hash = {}
|
2016-10-18 23:43:09 +08:00
|
|
|
if user_is_admin && self.has_too_many_overrides
|
|
|
|
hash[:has_many_overrides] = true
|
|
|
|
elsif self.multiple_due_dates_apply_to?(user)
|
2015-12-05 05:15:30 +08:00
|
|
|
hash[:vdd_tooltip] = OverrideTooltipPresenter.new(self, user).as_json
|
|
|
|
else
|
|
|
|
if due_date = self.overridden_for(user).due_at
|
|
|
|
hash[:due_date] = due_date
|
|
|
|
end
|
|
|
|
end
|
|
|
|
hash
|
|
|
|
end
|
2019-05-07 04:24:47 +08:00
|
|
|
tag_info[:points_possible] = self.points_possible
|
2015-12-05 05:15:30 +08:00
|
|
|
|
2016-09-15 01:43:53 +08:00
|
|
|
if user && tag_info[:due_date]
|
2015-12-05 05:15:30 +08:00
|
|
|
if tag_info[:due_date] < Time.now
|
|
|
|
if self.is_a?(Quizzes::Quiz) || (self.is_a?(Assignment) && expects_submission?)
|
|
|
|
tag_info[:past_due] = true unless has_submission
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
tag_info[:due_date] = tag_info[:due_date].utc.iso8601
|
|
|
|
end
|
|
|
|
tag_info
|
|
|
|
end
|
|
|
|
|
2012-12-29 05:02:21 +08:00
|
|
|
module ClassMethods
|
|
|
|
def due_date_compare_value(date)
|
|
|
|
# due dates are considered equal if they're the same up to the minute
|
2020-04-22 07:01:34 +08:00
|
|
|
return nil if date.nil?
|
2012-12-29 05:02:21 +08:00
|
|
|
date.to_i / 60
|
|
|
|
end
|
|
|
|
|
|
|
|
def due_dates_equal?(date1, date2)
|
|
|
|
due_date_compare_value(date1) == due_date_compare_value(date2)
|
|
|
|
end
|
|
|
|
end
|
2012-12-20 04:38:12 +08:00
|
|
|
end
|