2011-02-01 09:57:29 +08:00
|
|
|
#
|
2017-04-28 12:02:05 +08:00
|
|
|
# Copyright (C) 2011 - present Instructure, Inc.
|
2011-02-01 09:57:29 +08:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
|
2016-10-12 06:59:38 +08:00
|
|
|
module Factories
|
2016-12-12 04:03:44 +08:00
|
|
|
def assignment_model(opts = {})
|
|
|
|
course = opts.delete(:course) || opts[:context] || course_model(reusable: true)
|
2016-10-12 06:59:38 +08:00
|
|
|
# turn the group_category title into a group category "object"
|
|
|
|
group_category = opts.delete(:group_category)
|
2016-12-12 04:03:44 +08:00
|
|
|
@group_category = course.group_categories.create!(name: group_category) if group_category
|
2016-10-12 06:59:38 +08:00
|
|
|
opts[:group_category] = @group_category if @group_category
|
|
|
|
@assignment = factory_with_protected_attributes(course.assignments, assignment_valid_attributes.merge(opts))
|
|
|
|
@a = @assignment
|
|
|
|
@c = course
|
|
|
|
@a
|
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
|
2016-10-12 06:59:38 +08:00
|
|
|
def assignment_valid_attributes
|
|
|
|
{
|
2016-12-12 04:03:44 +08:00
|
|
|
title: "value for title",
|
|
|
|
description: "value for description",
|
|
|
|
due_at: Time.zone.now,
|
|
|
|
points_possible: "1.5"
|
2016-10-12 06:59:38 +08:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2016-10-12 06:59:38 +08:00
|
|
|
def assignment_with_override(opts={})
|
|
|
|
assignment_model(opts)
|
|
|
|
@override = @a.assignment_overrides.build
|
|
|
|
@override.set = @c.default_section
|
|
|
|
@override.save!
|
|
|
|
@override
|
|
|
|
end
|
2014-07-04 01:55:21 +08:00
|
|
|
|
2016-10-12 06:59:38 +08:00
|
|
|
def differentiated_assignment(opts={})
|
2017-06-02 03:48:57 +08:00
|
|
|
course_section = opts.delete(:course_section)
|
2016-10-12 06:59:38 +08:00
|
|
|
@assignment = opts[:assignment] || assignment_model(opts)
|
|
|
|
@assignment.only_visible_to_overrides = true
|
|
|
|
@assignment.save!
|
|
|
|
@override = @assignment.assignment_overrides.build
|
2017-06-02 03:48:57 +08:00
|
|
|
@override.set = course_section || @course.default_section
|
2016-10-12 06:59:38 +08:00
|
|
|
@override.save!
|
|
|
|
@override
|
|
|
|
end
|
2015-07-08 03:04:12 +08:00
|
|
|
|
2016-10-12 06:59:38 +08:00
|
|
|
def create_assignments(course_ids, count_per_course = 1, fields = {})
|
2019-06-26 04:26:05 +08:00
|
|
|
account = Account.default
|
2016-10-12 06:59:38 +08:00
|
|
|
course_ids = Array(course_ids)
|
|
|
|
course_ids *= count_per_course
|
|
|
|
records = course_ids.each_with_index.map do |id, i|
|
|
|
|
{
|
|
|
|
context_id: id, context_type: 'Course', context_code: "course_#{id}",
|
|
|
|
title: "#{id}:#{i}", grading_type: "points", submission_types: "none",
|
2019-06-26 04:26:05 +08:00
|
|
|
workflow_state: 'published',
|
|
|
|
root_account_id: account.id,
|
2016-10-12 06:59:38 +08:00
|
|
|
}.merge(fields)
|
|
|
|
end
|
|
|
|
create_records(Assignment, records)
|
2015-07-08 03:04:12 +08:00
|
|
|
end
|
|
|
|
end
|