panda_pal 3.1.4 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/panda_pal/lti_controller.rb +11 -49
- data/lib/lti_xml/base_platform.rb +94 -0
- data/lib/lti_xml/bridge_platform.rb +8 -0
- data/lib/lti_xml/canvas_platform.rb +3 -0
- data/lib/panda_pal/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3df9fdf70cde120c96b5c6d58580bfa3eac730a
|
4
|
+
data.tar.gz: a12fae868bf6809b3c58f67dea9f17daa3f48527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36c1f80a58381ff37585ffbd304c2f1fe6d661e97ba4e5d3c8dc953b5daf450e6e05879ab00efd0bdc25b404a36dac42bcdbf1529510b744931c422ae5e87cdf
|
7
|
+
data.tar.gz: ea225e44fb0afa53fed6a4d5d5a258a23e5a062e3e7e16edca1978fbe2f31bc425b4b6d62440c697a078963d70363d2bfa6feaa4e5f6666f7472f4121bfc2ed6
|
@@ -4,63 +4,25 @@ module PandaPal
|
|
4
4
|
class LtiController < ApplicationController
|
5
5
|
|
6
6
|
def tool_config
|
7
|
-
lti_options = PandaPal.lti_options
|
8
|
-
lti_properties = PandaPal.lti_properties
|
9
|
-
lti_nav = PandaPal.lti_paths
|
10
|
-
lti_environments = PandaPal.lti_environments
|
11
|
-
lti_custom_params = PandaPal.lti_custom_params
|
12
7
|
|
13
|
-
if lti_environments.empty?
|
8
|
+
if PandaPal.lti_environments.empty?
|
14
9
|
render plain: 'Domains must be set in lti_environments'
|
15
10
|
return
|
16
11
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
ims_lti_config[:launch_url] = lti_options[:launch_url]
|
27
|
-
elsif lti_options[:launch_path].present? # Assumes path is provided
|
28
|
-
ims_lti_config[:launch_url] = "#{host}#{lti_options[:launch_path]}"
|
29
|
-
else
|
30
|
-
ims_lti_config[:launch_url] = host
|
31
|
-
end
|
32
|
-
tc = IMS::LTI::Services::ToolConfig.new(ims_lti_config)
|
33
|
-
tc.set_ext_param(platform, :domain, request.host) unless lti_properties.has_key?(:domain)
|
34
|
-
tc.set_ext_param(platform, :privacy_level, 'public') unless lti_properties.has_key?(:public)
|
35
|
-
lti_properties.each do |k, v|
|
36
|
-
tc.set_ext_param(platform, k, v)
|
37
|
-
end
|
38
|
-
lti_custom_params.each do |k, v|
|
39
|
-
tc.set_custom_param k, v
|
40
|
-
end
|
41
|
-
if lti_options.has_key?(:custom_fields)
|
42
|
-
tc.set_ext_param(platform, :custom_fields, lti_options[:custom_fields])
|
43
|
-
lti_options[:custom_fields].each do |k, v|
|
44
|
-
tc.set_ext_param(platform, k, v)
|
45
|
-
end
|
12
|
+
platform = PandaPal.lti_options.delete(:platform) || 'canvas.instructure.com'
|
13
|
+
case platform
|
14
|
+
when 'canvas.instructure.com'
|
15
|
+
xml_config = LtiXml::CanvasPlatform.new(platform, request, main_app)
|
16
|
+
when 'bridgeapp.com'
|
17
|
+
xml_config = LtiXml::BridgePlatform.new(platform, request, main_app)
|
18
|
+
else
|
19
|
+
render plain: 'platform must be set under lti_options'
|
20
|
+
return
|
46
21
|
end
|
47
22
|
|
48
|
-
lti_nav.each do |k, v|
|
49
|
-
tc.set_ext_param(platform, k.to_sym, ext_params(v))
|
50
|
-
end
|
51
|
-
|
52
|
-
tc.set_ext_param(platform, :environments, lti_environments)
|
53
23
|
|
54
|
-
|
55
|
-
xml = tc.to_xml
|
56
|
-
xml = xml.sub(/<blti:launch_url>.*<\/blti:launch_url>/, '') if lti_options[:launch_url] === false
|
57
|
-
render xml: xml
|
24
|
+
render xml: xml_config.xml
|
58
25
|
end
|
59
26
|
|
60
|
-
def ext_params(options)
|
61
|
-
url = options.delete(:url)
|
62
|
-
options[:url] = main_app.send([url, '_url'].join)
|
63
|
-
options
|
64
|
-
end
|
65
27
|
end
|
66
28
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
class LtiXml::BasePlatform
|
2
|
+
|
3
|
+
attr_accessor :request, :host, :platform, :main_app
|
4
|
+
|
5
|
+
def initialize(platform, request, main_app)
|
6
|
+
@request = request
|
7
|
+
@host = "#{request.scheme}://#{request.host_with_port}"
|
8
|
+
@main_app = main_app
|
9
|
+
@platform = platform
|
10
|
+
end
|
11
|
+
|
12
|
+
# Override one of the following formatter methods in your individual platform class, or if you must, you can override
|
13
|
+
# the whole xml method and do it all custom.
|
14
|
+
def xml
|
15
|
+
ims_tool_config
|
16
|
+
add_domain
|
17
|
+
add_privacy_level
|
18
|
+
add_lti_properties
|
19
|
+
add_lti_custom_params
|
20
|
+
add_lti_options
|
21
|
+
add_lti_nav
|
22
|
+
add_environments
|
23
|
+
|
24
|
+
#strip the launch url
|
25
|
+
xml = @tc.to_xml
|
26
|
+
xml = xml.sub(/<blti:launch_url>.*<\/blti:launch_url>/, '') if PandaPal.lti_options[:launch_url] === false
|
27
|
+
|
28
|
+
return xml
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def ims_tool_config
|
34
|
+
ims_lti_config = {title: PandaPal.lti_options[:title]}
|
35
|
+
if PandaPal.lti_options[:secure_launch_url].present? # Assumes full URL is provided
|
36
|
+
ims_lti_config[:secure_launch_url] = PandaPal.lti_options[:secure_launch_url]
|
37
|
+
elsif PandaPal.lti_options[:secure_launch_path].present? # Assumes path is provided
|
38
|
+
ims_lti_config[:secure_launch_url] = "#{host}#{PandaPal.lti_options[:secure_launch_path]}"
|
39
|
+
elsif PandaPal.lti_options[:launch_url].present? # Assumes full URL is provided
|
40
|
+
ims_lti_config[:launch_url] = PandaPal.lti_options[:launch_url]
|
41
|
+
elsif PandaPal.lti_options[:launch_path].present? # Assumes path is provided
|
42
|
+
ims_lti_config[:launch_url] = "#{host}#{PandaPal.lti_options[:launch_path]}"
|
43
|
+
else
|
44
|
+
ims_lti_config[:launch_url] = host
|
45
|
+
end
|
46
|
+
@tc = IMS::LTI::Services::ToolConfig.new(ims_lti_config)
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_domain
|
50
|
+
@tc.set_ext_param(platform, :domain, request.host) unless PandaPal.lti_properties.has_key?(:domain)
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_privacy_level
|
54
|
+
@tc.set_ext_param(platform, :privacy_level, 'public') unless PandaPal.lti_properties.has_key?(:public)
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_lti_properties
|
58
|
+
PandaPal.lti_properties.each do |k, v|
|
59
|
+
@tc.set_ext_param(platform, k, v)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def add_lti_custom_params
|
64
|
+
PandaPal.lti_custom_params.each do |k, v|
|
65
|
+
@tc.set_custom_param k, v
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_lti_options
|
70
|
+
if PandaPal.lti_options.has_key?(:custom_fields)
|
71
|
+
@tc.set_ext_param(platform, :custom_fields, PandaPal.lti_options[:custom_fields])
|
72
|
+
PandaPal.lti_options[:custom_fields].each do |k, v|
|
73
|
+
@tc.set_ext_param(platform, k, v)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_lti_nav
|
79
|
+
PandaPal.lti_paths.each do |k, v|
|
80
|
+
@tc.set_ext_param(platform, k.to_sym, ext_params(v))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_environments
|
85
|
+
@tc.set_ext_param(platform, :environments, PandaPal.lti_environments)
|
86
|
+
end
|
87
|
+
|
88
|
+
def ext_params(options)
|
89
|
+
url = options.delete(:url)
|
90
|
+
options[:url] = main_app.send([url, '_url'].join)
|
91
|
+
options
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/lib/panda_pal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panda_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure ProServe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -161,6 +161,9 @@ files:
|
|
161
161
|
- db/migrate/20170106165533_add_salesforce_id_to_organizations.rb
|
162
162
|
- db/migrate/20171205183457_encrypt_organization_settings.rb
|
163
163
|
- db/migrate/20171205194657_remove_old_organization_settings.rb
|
164
|
+
- lib/lti_xml/base_platform.rb
|
165
|
+
- lib/lti_xml/bridge_platform.rb
|
166
|
+
- lib/lti_xml/canvas_platform.rb
|
164
167
|
- lib/panda_pal.rb
|
165
168
|
- lib/panda_pal/engine.rb
|
166
169
|
- lib/panda_pal/helpers.rb
|