Sha256: 3a8efefb4fda09b53c884b0b88f7abc16739bc089ae161aaaa187b96c15a6d89
Contents?: true
Size: 1.83 KB
Versions: 10
Compression:
Stored size: 1.83 KB
Contents
require_dependency "panda_pal/application_controller" module PandaPal class LtiController < ApplicationController def tool_config lti_options = PandaPal.lti_options lti_properties = PandaPal.lti_properties lti_nav = PandaPal.lti_paths lti_environments = PandaPal.lti_environments lti_custom_params = PandaPal.lti_custom_params if lti_environments.empty? render plain: 'Domains must be set in lti_environments' return end platform = lti_options.delete(:platform) || 'canvas.instructure.com' host = "#{request.scheme}://#{request.host_with_port}" tc = IMS::LTI::Services::ToolConfig.new(:title => lti_options[:title], :launch_url => ("#{host}#{lti_options[:launch_route]}") || 'ABC') tc.set_ext_param(platform, :domain, request.host) unless lti_properties.has_key?(:domain) tc.set_ext_param(platform, :privacy_level, 'public') unless lti_properties.has_key?(:public) lti_properties.each do |k, v| tc.set_ext_param(platform, k, v) end lti_custom_params.each do |k, v| tc.set_custom_param k, v end if lti_options.has_key?(:custom_fields) tc.set_ext_param(platform, :custom_fields, lti_options[:custom_fields]) lti_options[:custom_fields].each do |k, v| tc.set_ext_param(platform, k, v) end end lti_nav.each do |k, v| tc.set_ext_param(platform, k.to_sym, ext_params(v)) end tc.set_ext_param(platform, :environments, lti_environments) #strip the launch url xml = tc.to_xml xml = xml.sub(/<blti:launch_url>.*<\/blti:launch_url>/, '') if lti_options[:launch_route].blank? render xml: xml end def ext_params(options) url = options.delete(:url) options[:url] = main_app.send([url, '_url'].join) options end end end
Version data entries
10 entries across 10 versions & 1 rubygems