Skip to content

Commit 51dc49b

Browse files
committed
can set due_at in assignments api. fixes #5805.
assignments api now accepts and returns assignment[due_at]. Change-Id: I36c2130c833ebda358b5eee9de983747b54beaed Reviewed-on: https://gerrit.instructure.com/6366 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
1 parent 052283d commit 51dc49b

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

app/controllers/assignments_api_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def show
122122
end
123123
end
124124

125-
ALLOWED_FIELDS = %w(name position points_possible grading_type)
125+
ALLOWED_FIELDS = %w(name position points_possible grading_type due_at)
126126

127127
# @API
128128
# Create a new assignment for this course. The assignment is created in the
@@ -134,14 +134,18 @@ def show
134134
# @argument assignment[points_possible] [Float] The maximum points possible on
135135
# the assignment.
136136
# @argument assignment[grading_type] [Optional, "pass_fail"|"percent"|"letter_grade"|"points"] The strategy used for grading the assignment. The assignment is ungraded if this field is omitted.
137+
# @argument assignment[due_at] [Timestamp] The day/time the assignment is due. Accepts
138+
# times in ISO 8601 format, e.g. 2011-10-21T18:48Z.
137139
def create
138140
assignment_params = {}
139141
if params[:assignment].is_a?(Hash)
140142
assignment_params = params[:assignment].slice(*ALLOWED_FIELDS)
143+
assignment_params["time_zone_edited"] = Time.zone.name if assignment_params["due_at"]
141144
end
142145
# TODO: allow rubric creation
143146

144147
@assignment = @context.active_assignments.build(assignment_params)
148+
@assignment.infer_due_at
145149

146150
if authorized_action(@assignment, @current_user, :create)
147151
if custom_vals = params[:assignment][:set_custom_field_values]

spec/apis/v1/assignments_api_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
:format => 'json', :course_id => @course.id.to_s },
140140
{ :assignment => { 'name' => 'some assignment',
141141
'position' => '1', 'points_possible' => '12',
142+
'due_at' => '2011-01-01',
142143
'grading_type' => 'points', 'set_custom_field_values' => { 'test_custom' => { 'value' => '1' } } } })
143144

144145
json.should == {
@@ -150,7 +151,7 @@
150151
'points_possible' => 12,
151152
'grading_type' => 'points',
152153
'needs_grading_count' => 0,
153-
'due_at' => nil,
154+
'due_at' => '2011-01-01T23:59:00Z',
154155
'submission_types' => [
155156
'none',
156157
],

0 commit comments

Comments
 (0)