Skip to content

Commit

Permalink
encode available_canvas_resources variable as JSON
Browse files Browse the repository at this point in the history
test plan:
* testing with the new index placement tools
 on the assignments/modules page should send
 the available canvas resources encoded
 as a JSON string so the oauth signature works

Change-Id: I329c819a17ca70b84a5d165964246af6e635dacb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/218523
Tested-by: Service Cloud Jenkins <[email protected]>
Tested-by: Jenkins
Reviewed-by: Carl Kibler <[email protected]>
QA-Review: Carl Kibler <[email protected]>
Product-Review: James Williams <[email protected]>
  • Loading branch information
maneframe committed Nov 25, 2019
1 parent fdce70a commit ba7f83d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/lti/variable_expander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1346,16 +1346,16 @@ def enabled_capability_params(enabled_capabilities)
-> { @request.parameters['com_instructure_course_allow_canvas_resource_selection'] },
default_name: 'com_instructure_course_allow_canvas_resource_selection'

# Returns a list of content groups which can be selected, providing ID and name of each group,
# Returns a JSON-encoded list of content groups which can be selected, providing ID and name of each group,
# forwarded from the request.
# Empty value if com.instructure.Course.allow_canvas_resource_selection is false.
#
# @example
# ```
# [{"id": "3", name: "First Module"}, {"id": "5", name: "Second Module"]
# [{"id":"3","name":"First Module"},{"id":"5","name":"Second Module"}]
# ```
register_expansion 'com.instructure.Course.available_canvas_resources', [],
-> { @request.parameters['com_instructure_course_available_canvas_resources'] },
-> { @request.parameters['com_instructure_course_available_canvas_resources']&.to_json },
default_name: 'com_instructure_course_available_canvas_resources'

private
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/lti/variable_expander_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ module Lti
it 'has substitution for $com.instructure.Course.available_canvas_resources' do
exp_hash = {test: '$com.instructure.Course.available_canvas_resources'}
variable_expander.expand_variables!(exp_hash)
expect(exp_hash[:test]).to eq [{"id"=>"1", "name"=>"item 1"}, {"id"=>"2", "name"=>"item 2"}]
expect(JSON.parse(exp_hash[:test])).to eq [{"id"=>"1", "name"=>"item 1"}, {"id"=>"2", "name"=>"item 2"}]
end

context 'context is a group' do
Expand Down

0 comments on commit ba7f83d

Please sign in to comment.