ims-lti 2.0.0.beta.20 → 2.0.0.beta.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/ims/lti/models.rb +4 -0
- data/lib/ims/lti/models/content_item_container.rb +14 -0
- data/lib/ims/lti/models/content_item_placement.rb +18 -0
- data/lib/ims/lti/models/content_items.rb +7 -0
- data/lib/ims/lti/models/content_items/content_item.rb +25 -0
- data/lib/ims/lti/models/content_items/file_item.rb +7 -0
- data/lib/ims/lti/models/content_items/lti_link.rb +7 -0
- data/lib/ims/lti/models/image.rb +7 -0
- data/lib/ims/lti/models/lti_model.rb +14 -5
- data/lib/ims/lti/models/messages.rb +3 -0
- data/lib/ims/lti/models/messages/basic_lti_launch_request.rb +1 -1
- data/lib/ims/lti/models/messages/content_item_selection.rb +25 -0
- data/lib/ims/lti/models/messages/content_item_selection_request.rb +26 -0
- data/lib/ims/lti/models/messages/message.rb +17 -6
- data/lib/ims/lti/models/messages/registration_request.rb +1 -1
- data/lib/ims/lti/models/messages/request_message.rb +12 -0
- data/lib/ims/lti/models/tool_setting_container.rb +1 -1
- metadata +16 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9efa243962781962b68c7d0fff8fd999ced4968
|
4
|
+
data.tar.gz: 5c219ef0195c7dcb97540f97500bf176a2307445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8137fa5cd4f7170773094e8b533c79701a97ef58555a84f9b033c5998c7a3d735c5bd99e31b3d052420641888b322af9ff6a245f85901f08a5a07319187407f
|
7
|
+
data.tar.gz: a01f74beb1a0b3db1c588b9f2bf321354d40860289ea06cc59c7b7f2236dac98f1b20f97dc4a0735f962d7f4f86e4fc6bee192142700d477e5d14ea656778383
|
data/README.md
CHANGED
data/lib/ims/lti/models.rb
CHANGED
@@ -27,5 +27,9 @@ module IMS::LTI
|
|
27
27
|
require_relative 'models/base_url_selector'
|
28
28
|
require_relative 'models/tool_setting'
|
29
29
|
require_relative 'models/tool_setting_container'
|
30
|
+
require_relative 'models/content_items'
|
31
|
+
require_relative 'models/content_item_placement'
|
32
|
+
require_relative 'models/content_item_container'
|
33
|
+
require_relative 'models/image'
|
30
34
|
end
|
31
35
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module IMS::LTI::Models
|
2
|
+
class ContentItemContainer < IMS::LTI::Models::LTIModel
|
3
|
+
add_attribute :context, json_key: '@context'
|
4
|
+
add_attribute :graph, json_key: '@graph', relation: 'IMS::LTI::Models::ContentItems::ContentItem'
|
5
|
+
|
6
|
+
CONTENT_ITEM_CONTAINER_CONTEXT = 'http://purl.imsglobal.org/ctx/lti/v1/ContentItem'
|
7
|
+
|
8
|
+
def initialize(opts = {})
|
9
|
+
super(opts)
|
10
|
+
self.context = CONTENT_ITEM_CONTAINER_CONTEXT
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module IMS::LTI::Models
|
2
|
+
class ContentItemPlacement < LTIModel
|
3
|
+
|
4
|
+
DOCUMENT_TARGETS = {
|
5
|
+
embed: 'http://purl.imsglobal.org/vocab/lti/v2/lti#embed',
|
6
|
+
frame: 'http://purl.imsglobal.org/vocab/lti/v2/lti#frame',
|
7
|
+
iframe: 'http://purl.imsglobal.org/vocab/lti/v2/lti#iframe',
|
8
|
+
none: 'http://purl.imsglobal.org/vocab/lti/v2/lti#none',
|
9
|
+
overlay: 'http://purl.imsglobal.org/vocab/lti/v2/lti#overlay',
|
10
|
+
popup: 'http://purl.imsglobal.org/vocab/lti/v2/lti#popup',
|
11
|
+
window: 'http://purl.imsglobal.org/vocab/lti/v2/lti#window'
|
12
|
+
}
|
13
|
+
|
14
|
+
add_attributes :display_height, :display_width, :window_target
|
15
|
+
add_attribute :presentation_document_target
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module IMS::LTI::Models::ContentItems
|
2
|
+
class ContentItem < IMS::LTI::Models::LTIModel
|
3
|
+
|
4
|
+
add_attributes :media_type, :text, :title, :url
|
5
|
+
add_attribute :type, json_key: '@type'
|
6
|
+
add_attribute :id, json_key: '@id'
|
7
|
+
add_attribute :icon, relation: 'IMS::LTI::Models::Image'
|
8
|
+
add_attribute :placement_advice, relation: 'IMS::LTI::Models::ContentItemPlacement'
|
9
|
+
add_attribute :thumbnail, relation: 'IMS::LTI::Models::Image'
|
10
|
+
|
11
|
+
|
12
|
+
def self.from_json(json)
|
13
|
+
data = json.is_a?(String) ? JSON.parse(json) : json
|
14
|
+
case data['@type']
|
15
|
+
when 'ContentItem'
|
16
|
+
ContentItem.new.from_json(data)
|
17
|
+
when 'FileItem'
|
18
|
+
FileItem.new.from_json(data)
|
19
|
+
when 'LtiLink'
|
20
|
+
LtiLink.new.from_json(data)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -48,7 +48,7 @@ module IMS::LTI::Models
|
|
48
48
|
def attributes=(attrs)
|
49
49
|
attrs.each do |k, v|
|
50
50
|
if self.class.attributes.include?(k.to_sym)
|
51
|
-
|
51
|
+
send(("#{k}=").to_sym, v)
|
52
52
|
elsif k.to_s =~ /^ext_/
|
53
53
|
@ext_attributes[k.to_sym] = v
|
54
54
|
else
|
@@ -62,7 +62,11 @@ module IMS::LTI::Models
|
|
62
62
|
serialization_attrs_for(:json_key).each { |attr| json_hash.delete(attr.to_s) }
|
63
63
|
serialization_attrs_for(:relation).each do |attr|
|
64
64
|
val = attributes[attr.to_s]
|
65
|
-
|
65
|
+
if val && val.is_a?(Array)
|
66
|
+
json_hash[json_key(attr)] = val.map {|v| v.as_json }
|
67
|
+
elsif val
|
68
|
+
json_hash[json_key(attr)] = val.as_json
|
69
|
+
end
|
66
70
|
end
|
67
71
|
json_hash = @ext_attributes.merge(json_hash)
|
68
72
|
json_hash.merge! to_json_conversions
|
@@ -120,7 +124,8 @@ module IMS::LTI::Models
|
|
120
124
|
result = {}
|
121
125
|
if attrs = serialization_attrs_for(:json_key)
|
122
126
|
conversion_attrs = serialization_attrs_for(:json_converter)
|
123
|
-
|
127
|
+
relation_attrs = serialization_attrs_for(:relation)
|
128
|
+
attrs.each { |attr| result[json_key(attr)] = attributes[attr.to_s] unless (conversion_attrs | relation_attrs).include?(attr) || attributes[attr.to_s].nil? }
|
124
129
|
end
|
125
130
|
result
|
126
131
|
end
|
@@ -171,8 +176,12 @@ module IMS::LTI::Models
|
|
171
176
|
@attributes = attribs
|
172
177
|
end
|
173
178
|
|
174
|
-
def self.serialization_options
|
175
|
-
|
179
|
+
def self.serialization_options()
|
180
|
+
if name == "IMS::LTI::Models::LTIModel"
|
181
|
+
@serialization_options || {}
|
182
|
+
else
|
183
|
+
superclass.send(:serialization_options).merge(@serialization_options || {})
|
184
|
+
end
|
176
185
|
end
|
177
186
|
|
178
187
|
def serialization_options
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module IMS::LTI::Models
|
2
2
|
module Messages
|
3
3
|
require_relative 'messages/message'
|
4
|
+
require_relative 'messages/request_message'
|
4
5
|
require_relative 'messages/registration_request'
|
5
6
|
require_relative 'messages/basic_lti_launch_request'
|
7
|
+
require_relative 'messages/content_item_selection_request'
|
8
|
+
require_relative 'messages/content_item_selection'
|
6
9
|
end
|
7
10
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module IMS::LTI::Models::Messages
|
2
|
+
class ContentItemSelection < Message
|
3
|
+
add_optional_params :content_items, :data, :lti_msg, :lti_log, :lti_errormsg, :lti_errorlog
|
4
|
+
|
5
|
+
def content_items=(ci)
|
6
|
+
if ci.instance_of? String
|
7
|
+
container = IMS::LTI::Models::ContentItemContainer.from_json ci
|
8
|
+
@content_items = container.graph
|
9
|
+
else
|
10
|
+
@content_items = ci
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def parameters
|
15
|
+
if content_items
|
16
|
+
params = self.class.send("parameters")
|
17
|
+
params.delete('content_items')
|
18
|
+
collect_attributes(params).merge({'content_items' => IMS::LTI::Models::ContentItemContainer.new(graph: content_items).to_json})
|
19
|
+
else
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module IMS::LTI::Models::Messages
|
2
|
+
class ContentItemSelectionRequest < RequestMessage
|
3
|
+
|
4
|
+
add_required_params :accept_media_types, :accept_presentation_document_targets, :content_item_return_url
|
5
|
+
add_recommended_params :context_id, :tool_consumer_instance_guid
|
6
|
+
add_optional_params :context_type, :role_scope_mentor, :user_image, :accept_unsigned, :accept_multiple,
|
7
|
+
:accept_copy_advice, :text, :title, :data
|
8
|
+
add_deprecated_params :context_title, :context_label,
|
9
|
+
:lis_person_name_given, :lis_person_name_family, :lis_person_name_full,
|
10
|
+
:lis_person_contact_email_primary, :user_image, :lis_person_sourcedid,
|
11
|
+
:lis_course_offering_sourcedid, :lis_course_section_sourcedid,
|
12
|
+
:tool_consumer_info_product_family_code, :tool_consumer_info_product_family_version,
|
13
|
+
:tool_consumer_instance_name, :tool_consumer_instance_description,
|
14
|
+
:tool_consumer_instance_url, :tool_consumer_instance_contact_email,
|
15
|
+
:tool_consumer_info_version
|
16
|
+
|
17
|
+
MESSAGE_TYPE = 'ContentItemSelectionRequest'
|
18
|
+
|
19
|
+
def initialize(attrs = {})
|
20
|
+
super(attrs)
|
21
|
+
self.lti_message_type = MESSAGE_TYPE
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module IMS::LTI::Models::Messages
|
2
2
|
class Message
|
3
|
+
|
3
4
|
class << self
|
4
5
|
|
5
6
|
def required_params
|
@@ -48,7 +49,11 @@ module IMS::LTI::Models::Messages
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def supers_params(instance_variable)
|
51
|
-
|
52
|
+
if name == "IMS::LTI::Models::Messages::Message"
|
53
|
+
[]
|
54
|
+
else
|
55
|
+
(superclass.instance_variable_get(instance_variable) || []) | superclass.send(:supers_params, instance_variable)
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
59
|
end
|
@@ -66,8 +71,6 @@ module IMS::LTI::Models::Messages
|
|
66
71
|
attr_reader :unknown_params, :custom_params, :ext_params
|
67
72
|
|
68
73
|
add_required_params :lti_message_type, :lti_version
|
69
|
-
add_recommended_params :user_id, :roles, :launch_presentation_document_target, :launch_presentation_width, :launch_presentation_height
|
70
|
-
add_optional_params :launch_presentation_locale, :launch_presentation_css_url
|
71
74
|
|
72
75
|
def self.generate(params)
|
73
76
|
case params['lti_message_type']
|
@@ -75,6 +78,8 @@ module IMS::LTI::Models::Messages
|
|
75
78
|
BasicLTILaunchRequest.new(params)
|
76
79
|
when RegistrationRequest::MESSAGE_TYPE
|
77
80
|
RegistrationRequest.new(params)
|
81
|
+
when ContentItemSelectionRequest::MESSAGE_TYPE
|
82
|
+
ContentItemSelectionRequest.new(params)
|
78
83
|
else
|
79
84
|
self.new(params)
|
80
85
|
end
|
@@ -93,7 +98,8 @@ module IMS::LTI::Models::Messages
|
|
93
98
|
elsif str_key.start_with?(CUSTOM_PREFIX)
|
94
99
|
@custom_params[str_key] = v
|
95
100
|
elsif !v.nil? && self.respond_to?(k.to_sym)
|
96
|
-
|
101
|
+
send(("#{k}=").to_sym, v)
|
102
|
+
|
97
103
|
else
|
98
104
|
warn "Unknown parameter #{k}"
|
99
105
|
@unknown_params[str_key] = v
|
@@ -120,6 +126,7 @@ module IMS::LTI::Models::Messages
|
|
120
126
|
end
|
121
127
|
|
122
128
|
def valid_signature?(secret)
|
129
|
+
params = collect_attributes(OAUTH_KEYS)
|
123
130
|
params = OAUTH_KEYS.inject({}) do |hash, k|
|
124
131
|
value = instance_variable_get("@#{k}")
|
125
132
|
hash[k] = value if value
|
@@ -152,6 +159,10 @@ module IMS::LTI::Models::Messages
|
|
152
159
|
collect_attributes(self.class.deprecated_params)
|
153
160
|
end
|
154
161
|
|
162
|
+
def oauth_params
|
163
|
+
collect_attributes(OAUTH_KEYS)
|
164
|
+
end
|
165
|
+
|
155
166
|
def method_missing(meth, *args, &block)
|
156
167
|
if match = /^(custom|ext)_([^=$]*)/.match(meth)
|
157
168
|
param_type, key = match.captures
|
@@ -178,8 +189,8 @@ module IMS::LTI::Models::Messages
|
|
178
189
|
|
179
190
|
def collect_attributes(attributes)
|
180
191
|
attributes.inject({}) do |h, param|
|
181
|
-
value = instance_variable_get("@#{param
|
182
|
-
h[param.to_s] = value
|
192
|
+
value = instance_variable_get("@#{param}")
|
193
|
+
h[param.to_s] = value if value
|
183
194
|
h
|
184
195
|
end
|
185
196
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module IMS::LTI::Models::Messages
|
2
|
+
class RequestMessage < Message
|
3
|
+
|
4
|
+
add_recommended_params :user_id, :roles, :launch_presentation_document_target, :launch_presentation_width, :launch_presentation_height
|
5
|
+
add_optional_params :launch_presentation_locale, :launch_presentation_css_url
|
6
|
+
|
7
|
+
def initialize(attrs = {})
|
8
|
+
super(attrs)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -6,8 +6,8 @@ module IMS::LTI::Models
|
|
6
6
|
TOOL_SETTING_CONTAINER_CONTEXT = 'http://purl.imsglobal.org/ctx/lti/v2/ToolSettings'
|
7
7
|
|
8
8
|
def initialize(opts = {})
|
9
|
-
self.context = TOOL_SETTING_CONTAINER_CONTEXT
|
10
9
|
super(opts)
|
10
|
+
self.context = TOOL_SETTING_CONTAINER_CONTEXT
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ims-lti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_oauth
|
@@ -72,42 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 10.4.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 10.4.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 3.2.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
96
|
+
version: 3.2.0
|
111
97
|
description:
|
112
98
|
email:
|
113
99
|
executables: []
|
@@ -127,16 +113,26 @@ files:
|
|
127
113
|
- lib/ims/lti/models/base_url_choice.rb
|
128
114
|
- lib/ims/lti/models/base_url_selector.rb
|
129
115
|
- lib/ims/lti/models/contact.rb
|
116
|
+
- lib/ims/lti/models/content_item_container.rb
|
117
|
+
- lib/ims/lti/models/content_item_placement.rb
|
118
|
+
- lib/ims/lti/models/content_items.rb
|
119
|
+
- lib/ims/lti/models/content_items/content_item.rb
|
120
|
+
- lib/ims/lti/models/content_items/file_item.rb
|
121
|
+
- lib/ims/lti/models/content_items/lti_link.rb
|
130
122
|
- lib/ims/lti/models/icon_endpoint.rb
|
131
123
|
- lib/ims/lti/models/icon_info.rb
|
124
|
+
- lib/ims/lti/models/image.rb
|
132
125
|
- lib/ims/lti/models/localized_name.rb
|
133
126
|
- lib/ims/lti/models/localized_text.rb
|
134
127
|
- lib/ims/lti/models/lti_model.rb
|
135
128
|
- lib/ims/lti/models/message_handler.rb
|
136
129
|
- lib/ims/lti/models/messages.rb
|
137
130
|
- lib/ims/lti/models/messages/basic_lti_launch_request.rb
|
131
|
+
- lib/ims/lti/models/messages/content_item_selection.rb
|
132
|
+
- lib/ims/lti/models/messages/content_item_selection_request.rb
|
138
133
|
- lib/ims/lti/models/messages/message.rb
|
139
134
|
- lib/ims/lti/models/messages/registration_request.rb
|
135
|
+
- lib/ims/lti/models/messages/request_message.rb
|
140
136
|
- lib/ims/lti/models/parameter.rb
|
141
137
|
- lib/ims/lti/models/product_family.rb
|
142
138
|
- lib/ims/lti/models/product_info.rb
|