add fixed and variable parameters for lti2

fixes: PLAT-593 PLAT-594

test-plan:

specs should pass

Change-Id: I05e9b408655779f1c53ef17d5c98aeaf2a8e3a87
Reviewed-on: https://gerrit.instructure.com/39409
Reviewed-by: Brad Humphrey <brad@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Nathan Mills <nathanm@instructure.com>
QA-Review: Nathan Mills <nathanm@instructure.com>
This commit is contained in:
Nathan Mills 2014-08-15 14:34:55 -06:00
parent 6d1b853ee5
commit f8e1321ec4
4 changed files with 16 additions and 6 deletions

View File

@ -35,7 +35,7 @@ gem 'hoe', '3.8.1'
gem 'i18n', '0.6.8'
gem 'i18nema', RUBY_VERSION >= '2.2' ? '0.0.8' : '0.0.7'
gem 'icalendar', '1.5.4'
gem 'ims-lti', '2.0.0.beta.4'
gem 'ims-lti', '2.0.0.beta.6'
gem 'jammit', '0.6.6'
gem 'cssmin', '1.0.3'
gem 'jsmin', '1.0.1'

View File

@ -28,7 +28,6 @@ module Lti
@lti_launch.link_text = I18n.t('lti2.register_tool', 'Register Tool')
@lti_launch.launch_type = message.launch_presentation_document_target
@lti_launch.message_type = message.lti_message_type
render template: 'lti/framed_launch'
end
@ -39,17 +38,19 @@ module Lti
tool_proxy = resource_handler.tool_proxy
#TODO create scoped method for query
if ToolProxyBinding.where(tool_proxy_id: tool_proxy.id, context_id: @context.id, context_type: @context.class).count(:all) > 0
message_service = IMS::LTI::Services::MessageService.new(tool_proxy.guid, tool_proxy.shared_secret)
message = IMS::LTI::Models::Messages::BasicLTILaunchRequest.new(
launch_url: message_handler.launch_path,
oauth_consumer_key: tool_proxy.guid,
lti_version: IMS::LTI::Models::LTIModel::LTI_VERSION_2P0,
resource_link_id: Lti::Asset.opaque_identifier_for(@context),
context_id: Lti::Asset.opaque_identifier_for(@context),
tool_consumer_instance_guid: @context.root_account.lti_guid,
launch_presentation_document_target: IMS::LTI::Models::Messages::Message::LAUNCH_TARGET_IFRAME
)
message.add_custom_params(custom_params(message_handler.parameters))
@lti_launch = Launch.new
@lti_launch.resource_url = message_handler.launch_path
@lti_launch.params = message_service.signed_params(@lti_launch.resource_url, message)
@lti_launch.resource_url = message.launch_url
@lti_launch.params = message.signed_post_params(tool_proxy.shared_secret)
@lti_launch.link_text = message_handler.resource.name
@lti_launch.launch_type = message.launch_presentation_document_target
@lti_launch.message_type = message.lti_message_type
@ -63,6 +64,12 @@ module Lti
private
def custom_params(parameters)
lookup_hash = common_variable_substitutions.inject({}) { |hash, (k,v)| hash[k.gsub(/\A\$/, '')] = v ; hash}
params = IMS::LTI::Models::Parameter.from_json(parameters || [])
IMS::LTI::Models::Parameter.process_params(params, lookup_hash)
end
def tool_consumer_profile_url
tp_id = SecureRandom.uuid
case context

View File

@ -61,7 +61,8 @@ module Lti
end
def capabilities
['basic-lti-launch-request']
%w( basic-lti-launch-request Canvas.api.domain)
end
end

View File

@ -21,11 +21,13 @@
module Lti
module MessageHelper
def common_variable_substitutions
{
'$Canvas.api.domain' => -> {HostUrl.context_host(@domain_root_account, request.host)},
'$Canvas.xapi.url' => -> {lti_xapi_url(@tool)}
}
end
end
end