2012-10-03 12:21:19 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2012 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/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
class AssignmentOverride < ActiveRecord::Base
|
|
|
|
include Workflow
|
|
|
|
include TextHelper
|
|
|
|
|
2013-01-30 03:49:22 +08:00
|
|
|
simply_versioned :keep => 10
|
2012-10-03 12:21:19 +08:00
|
|
|
|
|
|
|
attr_accessible
|
2014-04-11 03:03:43 +08:00
|
|
|
EXPORTABLE_ATTRIBUTES = [
|
|
|
|
:id, :created_at, :updated_at, :assignment_id, :assignment_version, :set_type, :set_id, :title, :workflow_state, :due_at_overridden, :due_at, :all_day,
|
|
|
|
:all_day_date, :unlock_at_overridden, :unlock_at, :lock_at_overridden, :lock_at, :quiz_id, :quiz_version
|
|
|
|
]
|
|
|
|
|
|
|
|
EXPORTABLE_ASSOCIATIONS = [:assignment, :quiz, :assignment_override_students]
|
2012-10-03 12:21:19 +08:00
|
|
|
|
2013-03-07 07:56:01 +08:00
|
|
|
attr_accessor :dont_touch_assignment
|
|
|
|
|
2012-10-03 12:21:19 +08:00
|
|
|
belongs_to :assignment
|
2014-01-15 06:11:27 +08:00
|
|
|
belongs_to :quiz, class_name: 'Quizzes::Quiz'
|
2012-10-03 12:21:19 +08:00
|
|
|
belongs_to :set, :polymorphic => true
|
|
|
|
has_many :assignment_override_students, :dependent => :destroy
|
|
|
|
|
2012-12-13 03:14:17 +08:00
|
|
|
validates_presence_of :assignment_version, :if => :assignment
|
2013-08-08 06:19:48 +08:00
|
|
|
validates_presence_of :title, :workflow_state
|
2012-10-03 12:21:19 +08:00
|
|
|
validates_inclusion_of :set_type, :in => %w(CourseSection Group ADHOC)
|
|
|
|
validates_length_of :title, :maximum => maximum_string_length, :allow_nil => true
|
|
|
|
|
|
|
|
concrete_set = lambda{ |override| ['CourseSection', 'Group'].include?(override.set_type) }
|
|
|
|
|
|
|
|
validates_presence_of :set, :set_id, :if => concrete_set
|
2013-01-30 03:49:22 +08:00
|
|
|
validates_uniqueness_of :set_id, :scope => [:assignment_id, :set_type, :workflow_state],
|
|
|
|
:if => lambda{ |override| override.assignment? && override.active? && concrete_set.call(override) }
|
|
|
|
validates_uniqueness_of :set_id, :scope => [:quiz_id, :set_type, :workflow_state],
|
|
|
|
:if => lambda{ |override| override.quiz? && override.active? && concrete_set.call(override) }
|
2012-10-03 12:21:19 +08:00
|
|
|
validate :if => concrete_set do |record|
|
2013-11-28 06:51:53 +08:00
|
|
|
if record.set && record.assignment && record.active?
|
2012-10-03 12:21:19 +08:00
|
|
|
case record.set
|
|
|
|
when CourseSection
|
|
|
|
record.errors.add :set, "not from assignment's course" unless record.set.course_id == record.assignment.context_id
|
|
|
|
when Group
|
2013-11-28 06:51:53 +08:00
|
|
|
record.errors.add :set, "not from assignment's group category" unless record.set.group_category_id == record.assignment.group_category_id
|
2012-10-03 12:21:19 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
validate :set_id, :unless => concrete_set do |record|
|
|
|
|
if record.set_type == 'ADHOC' && !record.set_id.nil?
|
|
|
|
record.errors.add :set_id, "must be nil with set_type ADHOC"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-13 03:14:17 +08:00
|
|
|
validate do |record|
|
|
|
|
if [record.assignment, record.quiz].all?(&:nil?)
|
|
|
|
record.errors.add :base, "assignment or quiz required"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-01 04:07:26 +08:00
|
|
|
after_save :update_cached_due_dates
|
2013-03-07 07:56:01 +08:00
|
|
|
after_save :touch_assignment, :if => :assignment
|
2012-12-14 09:37:22 +08:00
|
|
|
|
2013-06-01 04:07:26 +08:00
|
|
|
def update_cached_due_dates
|
2013-06-11 03:55:14 +08:00
|
|
|
return unless assignment?
|
2013-06-01 04:07:26 +08:00
|
|
|
if due_at_overridden_changed? ||
|
|
|
|
(due_at_overridden && due_at_changed?) ||
|
|
|
|
(due_at_overridden && workflow_state_changed?)
|
|
|
|
DueDateCacher.recompute(assignment)
|
2012-12-14 09:37:22 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-07 07:56:01 +08:00
|
|
|
def touch_assignment
|
|
|
|
return true if assignment.nil? || dont_touch_assignment
|
|
|
|
assignment.touch
|
|
|
|
end
|
|
|
|
private :touch_assignment
|
|
|
|
|
2013-06-11 03:55:14 +08:00
|
|
|
def assignment?; !!assignment_id; end
|
|
|
|
def quiz?; !!quiz_id; end
|
2013-01-30 03:49:22 +08:00
|
|
|
|
2012-10-03 12:21:19 +08:00
|
|
|
workflow do
|
|
|
|
state :active
|
|
|
|
state :deleted
|
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :destroy!, :destroy
|
|
|
|
def destroy
|
2012-11-06 05:45:34 +08:00
|
|
|
transaction do
|
|
|
|
self.assignment_override_students.destroy_all
|
|
|
|
self.workflow_state = 'deleted'
|
|
|
|
self.save!
|
|
|
|
end
|
2012-10-03 12:21:19 +08:00
|
|
|
end
|
|
|
|
|
2014-07-02 03:38:26 +08:00
|
|
|
scope :active, -> { where(:workflow_state => 'active') }
|
2012-10-03 12:21:19 +08:00
|
|
|
|
|
|
|
before_validation :default_values
|
|
|
|
def default_values
|
|
|
|
self.set_type ||= 'ADHOC'
|
2012-12-13 03:14:17 +08:00
|
|
|
if assignment
|
|
|
|
self.assignment_version = assignment.version_number
|
|
|
|
self.quiz = assignment.quiz
|
|
|
|
self.quiz_version = quiz.version_number if quiz
|
|
|
|
elsif quiz
|
|
|
|
self.quiz_version = quiz.version_number
|
|
|
|
self.assignment = quiz.assignment
|
|
|
|
self.assignment_version = assignment.version_number if assignment
|
|
|
|
end
|
|
|
|
|
2012-10-20 05:33:25 +08:00
|
|
|
self.title = set.name if set_type != 'ADHOC' && set
|
2012-10-03 12:21:19 +08:00
|
|
|
end
|
|
|
|
protected :default_values
|
|
|
|
|
|
|
|
# override set read accessor and set_id read/write accessors so that reading
|
|
|
|
# set/set_id or setting set_id while set_type=ADHOC doesn't try and find the
|
|
|
|
# ADHOC model
|
|
|
|
def set_id
|
|
|
|
read_attribute(:set_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_with_adhoc
|
|
|
|
if self.set_type == 'ADHOC'
|
2013-03-19 03:07:47 +08:00
|
|
|
assignment_override_students.includes(:user).map(&:user)
|
2012-10-03 12:21:19 +08:00
|
|
|
else
|
|
|
|
set_without_adhoc
|
|
|
|
end
|
|
|
|
end
|
|
|
|
alias_method_chain :set, :adhoc
|
|
|
|
|
|
|
|
def set_id=(id)
|
|
|
|
if self.set_type == 'ADHOC'
|
|
|
|
write_attribute(:set_id, id)
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.override(field)
|
|
|
|
define_method "override_#{field}" do |value|
|
|
|
|
send("#{field}_overridden=", true)
|
|
|
|
send("#{field}=", value)
|
|
|
|
end
|
|
|
|
|
|
|
|
define_method "clear_#{field}_override" do
|
|
|
|
send("#{field}_overridden=", false)
|
|
|
|
send("#{field}=", nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
validates_inclusion_of "#{field}_overridden", :in => [false, true]
|
|
|
|
before_validation do |override|
|
|
|
|
if override.send("#{field}_overridden").nil?
|
|
|
|
override.send("#{field}_overridden=", false)
|
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
2012-10-20 05:33:25 +08:00
|
|
|
|
2013-03-21 03:38:19 +08:00
|
|
|
scope "overriding_#{field}", where("#{field}_overridden" => true)
|
2012-10-03 12:21:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
override :due_at
|
|
|
|
override :unlock_at
|
|
|
|
override :lock_at
|
|
|
|
|
|
|
|
def due_at=(new_due_at)
|
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
|
|
|
new_due_at = CanvasTime.fancy_midnight(new_due_at)
|
2012-10-03 12:21:19 +08:00
|
|
|
new_all_day, new_all_day_date = Assignment.all_day_interpretation(
|
|
|
|
:due_at => new_due_at,
|
|
|
|
:due_at_was => read_attribute(:due_at),
|
|
|
|
:all_day_was => read_attribute(:all_day),
|
|
|
|
:all_day_date_was => read_attribute(:all_day_date))
|
|
|
|
|
|
|
|
write_attribute(:due_at, new_due_at)
|
|
|
|
write_attribute(:all_day, new_all_day)
|
|
|
|
write_attribute(:all_day_date, new_all_day_date)
|
|
|
|
end
|
2012-10-18 02:46:22 +08:00
|
|
|
|
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 lock_at=(new_lock_at)
|
|
|
|
write_attribute(:lock_at, CanvasTime.fancy_midnight(new_lock_at))
|
|
|
|
end
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
|
2012-10-30 01:00:07 +08:00
|
|
|
def as_hash
|
|
|
|
{ :title => title,
|
|
|
|
:due_at => due_at,
|
2014-02-25 10:12:07 +08:00
|
|
|
:id => id,
|
2012-10-30 01:00:07 +08:00
|
|
|
:all_day => all_day,
|
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
|
|
|
:set_type => set_type,
|
|
|
|
:set_id => set_id,
|
2012-10-30 01:00:07 +08:00
|
|
|
: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
|
|
|
:lock_at => lock_at,
|
|
|
|
:unlock_at => unlock_at,
|
2012-10-30 01:00:07 +08:00
|
|
|
:override => self }
|
|
|
|
end
|
|
|
|
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
def applies_to_students
|
|
|
|
# FIXME: exclude students for whom this override does not apply
|
|
|
|
# because a higher-priority override exists
|
|
|
|
case set_type
|
|
|
|
when 'ADHOC'
|
|
|
|
set
|
|
|
|
when 'CourseSection'
|
|
|
|
set.participating_students
|
|
|
|
when 'Group'
|
|
|
|
set.participants
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def applies_to_admins
|
|
|
|
case set_type
|
|
|
|
when 'CourseSection'
|
|
|
|
set.participating_admins
|
|
|
|
else
|
|
|
|
assignment.context.participating_admins
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def notify_change?
|
2013-05-21 03:39:36 +08:00
|
|
|
self.assignment &&
|
|
|
|
self.assignment.context.available? &&
|
|
|
|
self.assignment.published? &&
|
|
|
|
self.assignment.created_at < 3.hours.ago &&
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
(!self.prior_version ||
|
|
|
|
self.workflow_state != self.prior_version.workflow_state ||
|
|
|
|
self.due_at_overridden != self.prior_version.due_at_overridden ||
|
|
|
|
self.due_at_overridden && !Assignment.due_dates_equal?(self.due_at, self.prior_version.due_at))
|
|
|
|
end
|
|
|
|
|
|
|
|
has_a_broadcast_policy
|
|
|
|
set_broadcast_policy do |p|
|
|
|
|
p.dispatch :assignment_due_date_changed
|
|
|
|
p.to { applies_to_students }
|
|
|
|
p.whenever { |record| record.notify_change? }
|
|
|
|
p.filter_asset_by_recipient { |record, user|
|
|
|
|
# note that our asset for this message is an Assignment, not an AssignmentOverride
|
|
|
|
record.assignment.overridden_for(user)
|
|
|
|
}
|
|
|
|
|
|
|
|
p.dispatch :assignment_due_date_override_changed
|
|
|
|
p.to { applies_to_admins }
|
|
|
|
p.whenever { |record| record.notify_change? }
|
|
|
|
end
|
2012-10-03 12:21:19 +08:00
|
|
|
end
|