ims-lti 1.2.4 → 2.0.0.beta.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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/Changelog.txt +0 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +15 -103
  5. data/lib/ims.rb +3 -1
  6. data/lib/ims/lti.rb +6 -64
  7. data/lib/ims/lti/converters.rb +5 -0
  8. data/lib/ims/lti/converters/time_json_converter.rb +13 -0
  9. data/lib/ims/lti/models.rb +29 -0
  10. data/lib/ims/lti/models/base_url_choice.rb +15 -0
  11. data/lib/ims/lti/models/base_url_selector.rb +5 -0
  12. data/lib/ims/lti/models/contact.rb +5 -0
  13. data/lib/ims/lti/models/icon_endpoint.rb +5 -0
  14. data/lib/ims/lti/models/icon_info.rb +6 -0
  15. data/lib/ims/lti/models/localized_name.rb +11 -0
  16. data/lib/ims/lti/models/localized_text.rb +11 -0
  17. data/lib/ims/lti/models/lti_model.rb +169 -0
  18. data/lib/ims/lti/models/message_handler.rb +6 -0
  19. data/lib/ims/lti/models/messages.rb +6 -0
  20. data/lib/ims/lti/models/messages/basic_lti_launch_request.rb +8 -0
  21. data/lib/ims/lti/models/messages/message.rb +43 -0
  22. data/lib/ims/lti/models/messages/registration_request.rb +17 -0
  23. data/lib/ims/lti/models/parameter.rb +5 -0
  24. data/lib/ims/lti/models/product_family.rb +8 -0
  25. data/lib/ims/lti/models/product_info.rb +19 -0
  26. data/lib/ims/lti/models/product_instance.rb +10 -0
  27. data/lib/ims/lti/models/resource_handler.rb +18 -0
  28. data/lib/ims/lti/models/resource_type.rb +6 -0
  29. data/lib/ims/lti/models/rest_service.rb +14 -0
  30. data/lib/ims/lti/models/rest_service_profile.rb +7 -0
  31. data/lib/ims/lti/models/security_contract.rb +9 -0
  32. data/lib/ims/lti/models/service_owner.rb +8 -0
  33. data/lib/ims/lti/models/service_provider.rb +11 -0
  34. data/lib/ims/lti/models/tool_consumer_profile.rb +20 -0
  35. data/lib/ims/lti/models/tool_profile.rb +22 -0
  36. data/lib/ims/lti/models/tool_proxy.rb +11 -0
  37. data/lib/ims/lti/models/vendor.rb +28 -0
  38. data/lib/ims/lti/services.rb +5 -0
  39. data/lib/ims/lti/services/message_service.rb +40 -0
  40. data/lib/ims/lti/version.rb +5 -0
  41. metadata +68 -52
  42. data/Changelog +0 -54
  43. data/LICENSE +0 -18
  44. data/lib/ims/lti/deprecated_role_checks.rb +0 -52
  45. data/lib/ims/lti/extensions.rb +0 -45
  46. data/lib/ims/lti/extensions/canvas.rb +0 -122
  47. data/lib/ims/lti/extensions/content.rb +0 -209
  48. data/lib/ims/lti/extensions/outcome_data.rb +0 -216
  49. data/lib/ims/lti/launch_params.rb +0 -166
  50. data/lib/ims/lti/outcome_request.rb +0 -225
  51. data/lib/ims/lti/outcome_response.rb +0 -166
  52. data/lib/ims/lti/request_validator.rb +0 -56
  53. data/lib/ims/lti/role_checks.rb +0 -101
  54. data/lib/ims/lti/tool_base.rb +0 -29
  55. data/lib/ims/lti/tool_config.rb +0 -231
  56. data/lib/ims/lti/tool_consumer.rb +0 -86
  57. data/lib/ims/lti/tool_provider.rb +0 -143
data/Changelog DELETED
@@ -1,54 +0,0 @@
1
- 2020-02-03 Version 1.2.3
2
- * Add support for submittedAt date
3
-
4
- 2017-03-08 Version 1.2.0
5
- * Don't downcase roles
6
-
7
- 2016-10-05 Version 1.1.13
8
- * Fix Oauth::Unauthorized initialization bug
9
- * Relax oauth dependency
10
-
11
- 2016-06-16 Version 1.1.12
12
- * Add support for detecting observer role
13
-
14
- 2015-02-20 Version 1.1.8
15
- * Replace usage of the 'uuid' gem with SecureRandom
16
- * Update the outcome extension doc example
17
-
18
- 2015-01-09 Version 1.1.7
19
- * Add support for new outcome extension resultTotalScore
20
-
21
- 2013-04-24 Version 1.1.3
22
-
23
- * Corrected lti_version launch parameter
24
-
25
- 2012-09-05 Version 1.1.2
26
-
27
- * Added better role checking and convenience methods
28
-
29
- 2012-09-04 Version 1.1.1
30
-
31
- * Added cdata value for outcome data extension
32
-
33
- 2012-08-14 Version 1.1.0
34
-
35
- * Added framework for LTI extensions
36
- * Added LTI outcome data extension
37
- * Fix tests reliant on random ordering
38
- * Add rails 3 note to readme install docs
39
- * Create Changelog
40
-
41
-
42
- 2012-03-14 Version 1.0.2
43
-
44
- * Refactor OAuth validation into its own module
45
-
46
-
47
- 2012-03-13 Version 1.0.1
48
-
49
- * Add gem dependencies to gemspec
50
-
51
-
52
- 2012-03-11 Version 1.0.0
53
-
54
- * Publish fully functional and operational IMS LTI library
data/LICENSE DELETED
@@ -1,18 +0,0 @@
1
- Copyright (c) 2012 Instructure
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of
4
- this software and associated documentation files (the "Software"), to deal in
5
- the Software without restriction, including without limitation the rights to use,
6
- copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
- Software, and to permit persons to whom the Software is furnished to do so,
8
- subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,52 +0,0 @@
1
- # These are here for backwards-compatibility
2
- # But they are deprecated and the new ones in
3
- # role_checks.rb should be used
4
- module IMS::LTI
5
- module DeprecatedRoleChecks
6
- # Check whether the Launch Parameters have a role
7
- def has_role?(role)
8
- role = role.downcase
9
- @roles && @roles.any?{|r| r.downcase.index(role)}
10
- end
11
-
12
- # Convenience method for checking if the user has 'learner' or 'student' role
13
- def student?
14
- has_role?('learner') || has_role?('student')
15
- end
16
-
17
- # Convenience method for checking if the user has 'instructor' or 'faculty' or 'staff' role
18
- def instructor?
19
- has_role?('instructor') || has_role?('faculty') || has_role?('staff')
20
- end
21
-
22
- # Convenience method for checking if the user has 'contentdeveloper' role
23
- def content_developer?
24
- has_role?('ContentDeveloper')
25
- end
26
-
27
- # Convenience method for checking if the user has 'Member' role
28
- def member?
29
- has_role?('Member')
30
- end
31
-
32
- # Convenience method for checking if the user has 'Manager' role
33
- def manager?
34
- has_role?('Manager')
35
- end
36
-
37
- # Convenience method for checking if the user has 'Mentor' role
38
- def mentor?
39
- has_role?('Mentor')
40
- end
41
-
42
- # Convenience method for checking if the user has 'administrator' role
43
- def admin?
44
- has_role?('administrator')
45
- end
46
-
47
- # Convenience method for checking if the user has 'TeachingAssistant' role
48
- def ta?
49
- has_role?('TeachingAssistant')
50
- end
51
- end
52
- end
@@ -1,45 +0,0 @@
1
-
2
- module IMS::LTI
3
- module Extensions
4
-
5
- # Base functionality for creating LTI extension modules
6
- # See the test for this class for a simple example of how to create an extension module
7
- module Base
8
- def outcome_request_extensions
9
- []
10
- end
11
-
12
- def outcome_response_extensions
13
- []
14
- end
15
-
16
- def extend_outcome_request(request)
17
- outcome_request_extensions.each do |ext|
18
- request.extend(ext)
19
- end
20
- request
21
- end
22
-
23
- def extend_outcome_response(response)
24
- outcome_response_extensions.each do |ext|
25
- response.extend(ext)
26
- end
27
- response
28
- end
29
- end
30
-
31
- module ExtensionBase
32
- def outcome_request_extensions
33
- super
34
- end
35
-
36
- def outcome_response_extensions
37
- super
38
- end
39
- end
40
- end
41
- end
42
-
43
- require 'ims/lti/extensions/outcome_data'
44
- require 'ims/lti/extensions/content'
45
- require 'ims/lti/extensions/canvas'
@@ -1,122 +0,0 @@
1
- module IMS::LTI
2
- module Extensions
3
- # Module that adds Canvas specific LTI extensions
4
- #
5
- # It adds convenience methods for generating common canvas use case LTI configurations
6
- #
7
- # == Usage
8
- # To generate an XML configuration:
9
- #
10
- # # Create a config object and set some options
11
- # tc = IMS::LTI::ToolConfig.new(:title => "Example Sinatra Tool Provider", :launch_url => url)
12
- # tc.description = "This example LTI Tool Provider supports LIS Outcome pass-back."
13
- #
14
- # # Extend the Canvas Tool config and add canvas related extensions
15
- # tc.extend IMS::LTI::Extensions::Canvas::ToolConfig
16
- # tc.homework_submission! 'http://someplace.com/homework', 'Find Homework'
17
- #
18
- # # generate the XML
19
- # tc.to_xml
20
- #
21
- # Or to create a config object from an XML String:
22
- #
23
- # tc = IMS::LTI::ToolConfig.create_from_xml(xml)
24
-
25
- module Canvas
26
- module ToolConfig
27
- PLATFORM = 'canvas.instructure.com'
28
-
29
- # Canvas extension defaults
30
- # These properties will cascade down to any options that are configured
31
- def set_canvas_ext_param(key, value)
32
- set_ext_param(PLATFORM, key, value)
33
- end
34
-
35
- def get_canvas_param(param_key)
36
- get_ext_param PLATFORM, param_key
37
- end
38
-
39
- def canvas_privacy_public!()
40
- set_canvas_ext_param(:privacy_level, 'public')
41
- end
42
-
43
- def canvas_privacy_name_only!()
44
- set_canvas_ext_param(:privacy_level, 'name_only')
45
- end
46
-
47
- def canvas_privacy_anonymous!()
48
- set_canvas_ext_param(:privacy_level, 'anonymous')
49
- end
50
-
51
- def canvas_domain!(domain)
52
- set_canvas_ext_param(:domain, domain)
53
- end
54
-
55
- def canvas_text!(text)
56
- set_canvas_ext_param(:text, text)
57
- end
58
-
59
- def canvas_icon_url!(icon_url)
60
- set_canvas_ext_param(:icon_url, icon_url)
61
- end
62
-
63
- def canvas_tool_id!(tool_id)
64
- set_canvas_ext_param(:tool_id, tool_id)
65
- end
66
-
67
- def canvas_selector_dimensions!(width, height)
68
- set_canvas_ext_param(:selection_width, width)
69
- set_canvas_ext_param(:selection_height, height)
70
- end
71
-
72
- # Canvas options
73
- # These configure canvas to expose the tool in various locations. Any properties that are set
74
- # at this level will override the defaults for this launch of the tool
75
-
76
- # Enables homework submissions via the tool
77
- # Valid properties are url, text, selection_width, selection_height, enabled
78
- def canvas_homework_submission!(params = {})
79
- set_canvas_ext_param(:homework_submission, params)
80
- end
81
-
82
- # Adds the tool to canvas' rich text editor
83
- # Valid properties are url, icon_url, text, selection_width, selection_height, enabled
84
- def canvas_editor_button!(params = {})
85
- set_canvas_ext_param(:editor_button, params)
86
- end
87
-
88
- # Adds the tool to canvas' resource selector
89
- # Valid properties are url, text, selection_width, selection_height, enabled
90
- def canvas_resource_selection!(params = {})
91
- set_canvas_ext_param(:resource_selection, params)
92
- end
93
-
94
- # Adds the tool to account level navigation in canvas
95
- # Valid properties are url, text, enabled
96
- def canvas_account_navigation!(params = {})
97
- set_canvas_ext_param(:account_navigation, params)
98
- end
99
-
100
- # Adds the tool to course level navigation in canvas
101
- # Valid properties are url, text, visibility, default, enabled
102
- # Visibility describes who will see the navigation element. Possible values are "admins", "members", and nil
103
- # Default determines if it is on or off by default. Possible values are "admins", "members", and nil
104
- def canvas_course_navigation!(params = {})
105
- set_canvas_ext_param(:course_navigation, params)
106
- end
107
-
108
- # Adds the tool to user level navigation in canvas
109
- # Valid properties are url, text, enabled
110
- def canvas_user_navigation!(params = {})
111
- set_canvas_ext_param(:user_navigation, params)
112
- end
113
-
114
- # Adds canvas environment configurations options
115
- # Valid properties are launch_url, domain, test_launch_url, test_domain, beta_launch_url, beta_domain
116
- def canvas_environments!(params = {})
117
- set_canvas_ext_param(:environments, params)
118
- end
119
- end
120
- end
121
- end
122
- end
@@ -1,209 +0,0 @@
1
- module IMS::LTI
2
- module Extensions
3
-
4
- # An LTI extension that adds support for content back to the consumer
5
- #
6
- # # Initialize TP object with OAuth creds and post parameters
7
- # provider = IMS::LTI::ToolProvider.new(consumer_key, consumer_secret, params)
8
- # # add extension
9
- # provider.extend IMS::LTI::Extensions::Content::ToolProvider
10
- #
11
- # If the tool was launched as an content request and it supports the content extension
12
- # you can redirect the user to the tool consumer using the return url helper methods.
13
- # The tool consumer is then responsible for consuming the content.
14
- #
15
- # #Check if a certain response type is available
16
- # if provider.accepts_url? do
17
- # #Generate the URL for the user
18
- # redirect provider.url_content_return_url(url)
19
- # end
20
- #
21
- module Content
22
- module ToolProvider
23
- include IMS::LTI::Extensions::ExtensionBase
24
- include Base
25
-
26
- # a list of the supported outcome data types
27
- def accepted_content_types
28
- return @content_types if @content_types
29
- @content_types = []
30
- if val = @ext_params["content_return_types"]
31
- @content_types = val.split(',').map {|i| i.to_sym}
32
- end
33
-
34
- @content_types
35
- end
36
-
37
- def accepted_file_extensions
38
- return @file_extensions if @file_extensions
39
- @file_extensions = []
40
- if val = @ext_params["content_file_extensions"]
41
- @file_extensions = val.split(',').map {|i| i.downcase.strip}
42
- end
43
-
44
- @file_extensions
45
- end
46
-
47
- def accepts_file?(file_name = nil)
48
- accepted_content_types.include?(:file) &&
49
- ( file_name.nil? ||
50
- accepted_file_extensions.empty? ||
51
- accepted_file_extensions.any?{|ext| file_name.downcase[/#{ext}$/]} )
52
- end
53
-
54
- def accepts_url?
55
- accepted_content_types.include?(:url)
56
- end
57
-
58
- def accepts_lti_launch_url?
59
- accepted_content_types.include?(:lti_launch_url)
60
- end
61
-
62
- def accepts_image_url?
63
- accepted_content_types.include?(:image_url)
64
- end
65
-
66
- def accepts_iframe?
67
- accepted_content_types.include?(:iframe)
68
- end
69
-
70
- def accepts_oembed?
71
- accepted_content_types.include?(:oembed)
72
- end
73
-
74
- def content_intended_use
75
- @ext_params["content_intended_use"].to_sym if @ext_params["content_intended_use"]
76
- end
77
-
78
- # check if the content extension is supported
79
- def accepts_content?
80
- !!@ext_params["content_return_types"]
81
- end
82
-
83
- # check if the consumer accepts a given type of content
84
- def accepts_content_type?(content_type)
85
- accepted_content_types.include? content_type.to_sym
86
- end
87
-
88
- #check the use of the content
89
- def is_content_for? (intended_use)
90
- content_intended_use == intended_use
91
- end
92
-
93
- def content_return_url
94
- @ext_params["content_return_url"]
95
- end
96
-
97
- #generates the return url for file submissions
98
- def file_content_return_url(url, text, content_type = nil)
99
- url = CGI::escape(url)
100
- text = CGI::escape(text)
101
- content_type = CGI::escape(content_type) if content_type
102
-
103
- return_url = "#{content_return_url}?return_type=file&url=#{url}&text=#{text}"
104
- return_url = "#{return_url}&content_type=#{content_type}" if content_type
105
-
106
- return return_url
107
- end
108
-
109
- #generates the return url for url submissions
110
- def url_content_return_url(url, title = nil, text = 'link', target = '_blank')
111
- url = CGI::escape(url)
112
- text = CGI::escape(text)
113
- target = CGI::escape(target)
114
-
115
- return_url = "#{content_return_url}?return_type=url&url=#{url}&text=#{text}&target=#{target}"
116
- return_url = "#{return_url}&title=#{CGI::escape(title)}" if title
117
-
118
- return return_url
119
- end
120
-
121
- #generates the return url for lti launch submissions
122
- def lti_launch_content_return_url(url, text='link', title=nil)
123
- url = CGI::escape(url)
124
- text = CGI::escape(text)
125
-
126
- return_url = "#{content_return_url}?return_type=lti_launch_url&url=#{url}&text=#{text}"
127
- return_url = "#{return_url}&title=#{CGI::escape(title)}" if title
128
-
129
- return return_url
130
- end
131
-
132
- #generates the return url for image submissions
133
- def image_content_return_url(url, width, height, alt = '')
134
- url = CGI::escape(url)
135
- width = CGI::escape(width.to_s)
136
- height = CGI::escape(height.to_s)
137
- alt = CGI::escape(alt)
138
-
139
- "#{content_return_url}?return_type=image_url&url=#{url}&width=#{width}&height=#{height}&alt=#{alt}"
140
- end
141
-
142
- #generates the return url for iframe submissions
143
- def iframe_content_return_url(url, width, height, title = nil)
144
- url = CGI::escape(url)
145
- width = CGI::escape(width.to_s)
146
- height = CGI::escape(height.to_s)
147
-
148
- return_url = "#{content_return_url}?return_type=iframe&url=#{url}&width=#{width}&height=#{height}"
149
- return_url = "#{return_url}&title=#{CGI::escape(title)}" if title
150
-
151
- return return_url
152
- end
153
-
154
- #generates the return url for oembed submissions
155
- def oembed_content_return_url(url, endpoint)
156
- url = CGI::escape(url)
157
- endpoint = CGI::escape(endpoint)
158
-
159
- "#{content_return_url}?return_type=oembed&url=#{url}&endpoint=#{endpoint}"
160
- end
161
- end
162
-
163
- module ToolConsumer
164
- include IMS::LTI::Extensions::ExtensionBase
165
- include Base
166
-
167
- # a list of the content types accepted
168
- #
169
- # tc.add_content_return_types=(['url', 'text'])
170
- # tc.add_content_return_types=("url,text")
171
- def content_return_types=(val)
172
- val = val.join(',') if val.is_a? Array
173
- set_ext_param('content_return_types', val)
174
- end
175
-
176
- # a comma-separated string of the supported outcome data types
177
- def content_return_types
178
- get_ext_param('content_return_types')
179
- end
180
-
181
- def content_intended_use=(val)
182
- set_ext_param('content_intended_use', val)
183
- end
184
-
185
- def content_intended_use
186
- get_ext_param('content_intended_use')
187
- end
188
-
189
- # convenience method for setting support for homework content
190
- def support_homework_content!
191
- self.content_intended_use = 'homework'
192
- self.content_return_types = 'file,url'
193
- end
194
-
195
- # convenience method for setting support for embed content
196
- def support_embed_content!
197
- self.content_intended_use = 'embed'
198
- self.content_return_types = 'oembed,lti_launch_url,url,image_url,iframe'
199
- end
200
-
201
- # convenience method for setting support for navigation content
202
- def support_navigation_content!
203
- self.content_intended_use = 'navigation'
204
- self.content_return_types = 'lti_launch_url'
205
- end
206
- end
207
- end
208
- end
209
- end