Sha256: 6cd8106a61978c35913e4cb4e77e5dfee18278b04668c1c759fe6950354e3443

Contents?: true

Size: 1.93 KB

Versions: 19

Compression:

Stored size: 1.93 KB

Contents

require_dependency "coalescing_panda/application_controller"

module CoalescingPanda
  class LtiController < ApplicationController

    def lti_config
      lti_options = CoalescingPanda.lti_options
      lti_nav = CoalescingPanda.lti_paths
      lti_nav[:course][:text] = params[:course_navigation_label] if params[:course_navigation_label].present?
      lti_nav[:account][:text] = params[:account_navigation_label] if params[:account_navigation_label].present?
      platform = 'canvas.instructure.com'
      host = "#{request.scheme}://#{request.host_with_port}"
      tc = IMS::LTI::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')
      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, setting_name(k.to_s), ext_params(v))
      end

      #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 styleguide
      render file: 'coalescing_panda/styleguide/styleguide.html'
    end

    def launch
      render 'coalescing_panda/launch'
    end

    def start_session
      session['started'] = true
      redirect_to CGI::unescape(params['referer'])
    end

    private

    def setting_name(name)
      tail = ''
      if %w(course account user).include?(name)
        tail = '_navigation' unless name.include? '_navigation'
      end
      (name+tail).to_sym
    end

    def ext_params(options)
      url = options.delete(:url)
      options[:url] = main_app.send(url+'_url')
      options
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
coalescing_panda-1.1.21.1 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.21 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.20 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.2.2 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.2.1 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.2.0 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.19 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-2.0.0 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.18 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.17 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.16 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.15 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.14 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.13 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.12 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.11 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.10 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.8 app/controllers/coalescing_panda/lti_controller.rb
coalescing_panda-1.1.7 app/controllers/coalescing_panda/lti_controller.rb