panda_pal 5.16.0 → 5.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b33c2970defb1a7405a8482186720ab63a05b10db522e4c39ce56b9aa38c1b9
|
4
|
+
data.tar.gz: 6a44dc5db6d135882e4c2aefe8b7872ea87ccd066fe329b0764e2f8564694800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 589b2581d892bca49ba635d01a70b9db1f6044b9c885758fdbfb6d483ca3c91861bc22515fdbde2086499c7d380b96f199f8dd26e44e1cd900f2a3c3c72fc53a
|
7
|
+
data.tar.gz: 330d2c17013313a47f361f12709acd99291fe918cdea00405b7f76d55925557000c66b0eee08ea68049ece4acd77e86db1fd3acec73ccacaa3165e235cadcafa
|
data/README.md
CHANGED
@@ -166,7 +166,7 @@ PandaPal.stage_placement(:content_selection, {
|
|
166
166
|
})
|
167
167
|
```
|
168
168
|
|
169
|
-
2. **Include helpers** in your controller and build content items
|
169
|
+
2. **Include helpers** in your controller and build content items with **required `launch_type`**:
|
170
170
|
```ruby
|
171
171
|
class ContentSelectionController < ApplicationController
|
172
172
|
include PandaPal::DeepLinkingHelpers
|
@@ -174,8 +174,12 @@ class ContentSelectionController < ApplicationController
|
|
174
174
|
def create
|
175
175
|
content_items = [
|
176
176
|
build_link_content_item(
|
177
|
-
url:
|
178
|
-
title: 'Selected Content'
|
177
|
+
url: panda_pal.v1p3_resource_link_request_url,
|
178
|
+
title: 'Selected Content',
|
179
|
+
custom: {
|
180
|
+
content_id: params[:content_id],
|
181
|
+
launch_type: :content_launch # REQUIRED for proper routing
|
182
|
+
}
|
179
183
|
)
|
180
184
|
]
|
181
185
|
render_deep_linking_response(content_items)
|
@@ -183,6 +187,14 @@ class ContentSelectionController < ApplicationController
|
|
183
187
|
end
|
184
188
|
```
|
185
189
|
|
190
|
+
3. **Add corresponding launch routes**:
|
191
|
+
```ruby
|
192
|
+
# config/routes.rb
|
193
|
+
lti_nav content_launch: 'content#launch'
|
194
|
+
```
|
195
|
+
|
196
|
+
**⚠️ IMPORTANT**: All content items **MUST** include `launch_type` in the `custom` hash. This is used by the `resource_link_request` action to determine which route to redirect to when Canvas launches your content.
|
197
|
+
|
186
198
|
**For complete configuration options, implementation examples, helper method documentation, and troubleshooting, see [DEEP_LINKING.md](DEEP_LINKING.md).**
|
187
199
|
|
188
200
|
## Implementating data segregation
|
@@ -40,7 +40,7 @@ module PandaPal
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def resource_link_request
|
43
|
-
ltype = @decoded_lti_jwt[LtiConstants::Canvas::PLACEMENT]
|
43
|
+
ltype = @decoded_lti_jwt[LtiConstants::Canvas::PLACEMENT] || @decoded_lti_jwt[LtiConstants::Claims::CUSTOM]&.dig("launch_type")
|
44
44
|
|
45
45
|
if ltype
|
46
46
|
current_session.data.merge!({
|
@@ -1,7 +1,26 @@
|
|
1
1
|
module PandaPal
|
2
2
|
module DeepLinkingHelpers
|
3
3
|
# Build a link content item
|
4
|
-
|
4
|
+
# @param url [String] The launch URL for the content
|
5
|
+
# @param title [String] The title of the content item
|
6
|
+
# @param text [String] Optional description text
|
7
|
+
# @param icon [String] Optional icon URL
|
8
|
+
# @param thumbnail [String] Optional thumbnail URL
|
9
|
+
# @param custom [Hash] Custom parameters - MUST include launch_type for proper routing
|
10
|
+
# @param options [Hash] Additional options to merge into the content item
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
# build_link_content_item(
|
14
|
+
# url: panda_pal.v1p3_resource_link_request_url,
|
15
|
+
# title: 'My Quiz',
|
16
|
+
# custom: {
|
17
|
+
# quiz_id: 123,
|
18
|
+
# launch_type: :quiz_launch # REQUIRED for proper routing
|
19
|
+
# }
|
20
|
+
# )
|
21
|
+
def build_link_content_item(url:, title: nil, text: nil, icon: nil, thumbnail: nil, custom: {}, **options)
|
22
|
+
validate_custom_launch_type!(custom)
|
23
|
+
|
5
24
|
content_item = {
|
6
25
|
type: 'link',
|
7
26
|
url: url,
|
@@ -10,11 +29,21 @@ module PandaPal
|
|
10
29
|
content_item[:text] = text if text.present?
|
11
30
|
content_item[:icon] = icon if icon.present?
|
12
31
|
content_item[:thumbnail] = thumbnail if thumbnail.present?
|
32
|
+
content_item[:custom] = custom if custom.present?
|
13
33
|
content_item.merge(options)
|
14
34
|
end
|
15
35
|
|
16
36
|
# Build a file content item
|
17
|
-
|
37
|
+
# @param url [String] The file URL
|
38
|
+
# @param title [String] The title of the content item
|
39
|
+
# @param text [String] Optional description text
|
40
|
+
# @param media_type [String] Optional media type
|
41
|
+
# @param icon [String] Optional icon URL
|
42
|
+
# @param custom [Hash] Custom parameters - MUST include launch_type for proper routing
|
43
|
+
# @param options [Hash] Additional options to merge into the content item
|
44
|
+
def build_file_content_item(url:, title: nil, text: nil, media_type: nil, icon: nil, custom: {}, **options)
|
45
|
+
validate_custom_launch_type!(custom)
|
46
|
+
|
18
47
|
content_item = {
|
19
48
|
type: 'file',
|
20
49
|
url: url,
|
@@ -23,17 +52,26 @@ module PandaPal
|
|
23
52
|
content_item[:text] = text if text.present?
|
24
53
|
content_item[:mediaType] = media_type if media_type.present?
|
25
54
|
content_item[:icon] = icon if icon.present?
|
55
|
+
content_item[:custom] = custom if custom.present?
|
26
56
|
content_item.merge(options)
|
27
57
|
end
|
28
58
|
|
29
59
|
# Build an HTML content item
|
30
|
-
|
60
|
+
# @param html [String] The HTML content
|
61
|
+
# @param title [String] The title of the content item
|
62
|
+
# @param text [String] Optional description text
|
63
|
+
# @param custom [Hash] Custom parameters - MUST include launch_type for proper routing
|
64
|
+
# @param options [Hash] Additional options to merge into the content item
|
65
|
+
def build_html_content_item(html:, title: nil, text: nil, custom: {}, **options)
|
66
|
+
validate_custom_launch_type!(custom)
|
67
|
+
|
31
68
|
content_item = {
|
32
69
|
type: 'html',
|
33
70
|
html: html,
|
34
71
|
title: title
|
35
72
|
}
|
36
73
|
content_item[:text] = text if text.present?
|
74
|
+
content_item[:custom] = custom if custom.present?
|
37
75
|
content_item.merge(options)
|
38
76
|
end
|
39
77
|
|
@@ -68,6 +106,12 @@ module PandaPal
|
|
68
106
|
|
69
107
|
private
|
70
108
|
|
109
|
+
def validate_custom_launch_type!(custom)
|
110
|
+
unless custom.is_a?(Hash) && custom.key?(:launch_type)
|
111
|
+
raise ArgumentError, "custom parameter must include :launch_type for proper routing. Example: custom: { launch_type: :my_content_type }"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
71
115
|
def build_deep_link_jwt(content_items, custom_deep_link_data)
|
72
116
|
# Get issuer (client_id) and audience from session
|
73
117
|
launch_params = current_session[:launch_params]
|
@@ -52,7 +52,7 @@ module PandaPal
|
|
52
52
|
def self.launch_route(opts, launch_type: nil)
|
53
53
|
if opts.is_a?(Symbol) || opts.is_a?(String)
|
54
54
|
launch_type = opts.to_sym
|
55
|
-
opts = PandaPal.lti_paths[launch_type]
|
55
|
+
opts = PandaPal.lti_paths[launch_type] || {}
|
56
56
|
end
|
57
57
|
|
58
58
|
if opts[:route_helper_key]
|
data/lib/panda_pal/version.rb
CHANGED