Skip to content

Commit 03d0796

Browse files
slothellecodekitchen
authored andcommitted
fixes assignment creation with quick add dialog
fixes CNVS-15217 test plan - create an ungraded assignment using the quick add dialog - do it again using the 'quiz' or 'discussion' type - do it again and click 'more options' - save the assignment with a single online submission option - verify that it saves/works for every assignment you created - party party celebrate victory wooo 👍 Change-Id: Ib4c924801d3f3ed228971151d88c97b7bc572fb1 Reviewed-on: https://gerrit.instructure.com/40416 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Cameron Sutter <csutter@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Liz Abinante <labinante@instructure.com>
1 parent 234a798 commit 03d0796

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

lib/api/v1/assignment.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,20 +296,12 @@ def update_api_assignment(assignment, assignment_params, user)
296296
return false
297297
end
298298

299-
API_ALLOWED_SUBMISSION_TYPES = %w(
300-
online_quiz
301-
none
302-
on_paper
303-
discussion_topic
304-
external_tool
305-
online_upload
306-
online_text_entry
307-
online_url
308-
media_recording
309-
not_graded
310-
)
299+
API_ALLOWED_SUBMISSION_TYPES = ["online_quiz", "none", "on_paper", "discussion_topic", "external_tool", "online_upload", "online_text_entry", "online_url", "media_recording", "not_graded", ""]
311300

312301
def valid_submission_types?(assignment, assignment_params)
302+
return true if assignment_params['submission_types'].nil?
303+
assignment_params['submission_types'] = Array(assignment_params['submission_types'])
304+
313305
if assignment_params['submission_types'].present? &&
314306
!assignment_params['submission_types'].all? { |s| API_ALLOWED_SUBMISSION_TYPES.include?(s) }
315307
assignment.errors.add('assignment[submission_types]',

spec/apis/v1/assignments_api_spec.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ def create_assignment_json(group, group_category)
578578
end
579579
end
580580

581-
it "should allow valid submission types" do
581+
it "should allow valid submission types as an array" do
582582
raw_api_call(:post, "/api/v1/courses/#{@course.id}/assignments",
583583
{ :controller => 'assignments_api',
584584
:action => 'create',
@@ -594,6 +594,19 @@ def create_assignment_json(group, group_category)
594594
response.should be_success
595595
end
596596

597+
it "should allow valid submission types as a string (quick add dialog)" do
598+
raw_api_call(:post, "/api/v1/courses/#{@course.id}/assignments",
599+
{ :controller => 'assignments_api',
600+
:action => 'create',
601+
:format => 'json',
602+
:course_id => @course.id.to_s },
603+
{ :assignment => {
604+
'name' => 'some assignment',
605+
'submission_types' => 'not_graded'}
606+
})
607+
response.should be_success
608+
end
609+
597610
it "should not allow unpermitted submission types" do
598611
raw_api_call(:post, "/api/v1/courses/#{@course.id}/assignments",
599612
{ :controller => 'assignments_api',

0 commit comments

Comments
 (0)