diff --git a/lib/lti/variable_expander.rb b/lib/lti/variable_expander.rb index 2e5e807fd9c..d9b10e5f255 100644 --- a/lib/lti/variable_expander.rb +++ b/lib/lti/variable_expander.rb @@ -1346,16 +1346,16 @@ module Lti -> { @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 diff --git a/spec/lib/lti/variable_expander_spec.rb b/spec/lib/lti/variable_expander_spec.rb index 0a89dec3a0f..28dca22d497 100644 --- a/spec/lib/lti/variable_expander_spec.rb +++ b/spec/lib/lti/variable_expander_spec.rb @@ -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