Class: CoalescingPanda::LtiController

Inherits:
ApplicationController show all
Defined in:
app/controllers/coalescing_panda/lti_controller.rb

Instance Method Summary collapse

Instance Method Details

#launchObject



47
48
49
# File 'app/controllers/coalescing_panda/lti_controller.rb', line 47

def launch
  render 'coalescing_panda/launch'
end

#lti_configObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/coalescing_panda/lti_controller.rb', line 6

def lti_config
  lti_options = CoalescingPanda.lti_options
  lti_nav = CoalescingPanda.lti_paths
  lti_environments = CoalescingPanda.lti_environments

  if lti_environments.empty?
    render text: 'Domains must be set in lti_environments'
    return
  end

  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')
  tc.set_custom_param(:custom_canvas_role, '$Canvas.membership.roles')
  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

  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

#start_sessionObject



51
52
53
54
# File 'app/controllers/coalescing_panda/lti_controller.rb', line 51

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

#styleguideObject



43
44
45
# File 'app/controllers/coalescing_panda/lti_controller.rb', line 43

def styleguide
  render file: 'coalescing_panda/styleguide/styleguide.html'
end