Sha256: eea7ca69ecd20ec0d1d9d4db3a26a5d0ab089f0ce98c12125223843d1c771ad4
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
require_dependency "panda_pal/application_controller" module PandaPal class LtiController < ApplicationController def tool_config lti_options = PandaPal.lti_options lti_nav = PandaPal.lti_paths lti_environments = PandaPal.lti_environments lti_custom_params = PandaPal.lti_custom_params if lti_environments.empty? render text: '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) tc.set_ext_param(platform, :privacy_level, 'public') 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
panda_pal-2.0.0 | app/controllers/panda_pal/lti_controller.rb |