Skip to content

Commit 2a4eebb

Browse files
Andrew Butterfieldroor0
authored andcommitted
Submission api no longer causes 500 error
A regression happened that broke SIS grade pass back in the following gerrit: https://gerrit.instructure.com/#/c/62210/ fixes CNVS-23599 Test plan: * Create a course * Create an assignment * Create a submission for that assignment * Make an api call with: /api/v1/courses/<courseid>/assignments/<assignmentid>/submissions?include[]=user * Ensure an internal server error does not occur and that the submission json includes a user for each submission. Change-Id: I1c5bf4d88fe2e8ff8f9b73878e0860a06a566b7c Reviewed-on: https://gerrit.instructure.com/63970 Tested-by: Jenkins Reviewed-by: Derek Bender <djbender@instructure.com> QA-Review: Steven Shepherd <sshepherd@instructure.com> Product-Review: Steven Burnett <sburnett@instructure.com>
1 parent 3aa796c commit 2a4eebb

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/api/v1/submission.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def submission_json(submission, assignment, current_user, session, context = nil
6565
end
6666

6767
if includes.include?("user")
68-
hash['user'] = user_json(submission.user, user, session, ['avatar_url'], submission.context, nil)
68+
hash['user'] = user_json(submission.user, current_user, session, ['avatar_url'], submission.context, nil)
6969
end
7070

7171
if assignment && includes.include?('user_summary')

spec/apis/v1/submissions_api_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ def submit_homework(assignment, student, opts = {:body => "test!"})
126126
expect(json.size).to eq 1
127127
end
128128

129+
it "should include user" do
130+
json = api_call(:get,
131+
"/api/v1/sections/#{@section.id}/assignments/#{@a1.id}/submissions.json",
132+
{ :controller => 'submissions_api', :action => 'index',
133+
:format => 'json', :section_id => @section.id.to_s,
134+
:assignment_id => @a1.id.to_s },
135+
{ :include => %w(user) })
136+
expect(json.size).to eq 1
137+
expect(json[0]['user']).not_to be_nil
138+
expect(json[0]['user']['id']).to eq(@student1.id)
139+
end
140+
129141
it "should return assignment_visible" do
130142
@course.enable_feature!(:differentiated_assignments)
131143
json = api_call(:get,

0 commit comments

Comments
 (0)