qalam_ims_lti 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/Changelog.txt +0 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +39 -0
  5. data/lib/ims/lis/context_type/handles.rb +10 -0
  6. data/lib/ims/lis/context_type/urns.rb +10 -0
  7. data/lib/ims/lis/roles/context/handles.rb +60 -0
  8. data/lib/ims/lis/roles/context/urns.rb +60 -0
  9. data/lib/ims/lis/roles/institution/handles.rb +22 -0
  10. data/lib/ims/lis/roles/institution/urns.rb +22 -0
  11. data/lib/ims/lis/roles/system/handles.rb +15 -0
  12. data/lib/ims/lis/roles/system/urns.rb +15 -0
  13. data/lib/ims/lis/statuses/simple_names.rb +9 -0
  14. data/lib/ims/lis/statuses/uris.rb +9 -0
  15. data/lib/ims/lis.rb +14 -0
  16. data/lib/ims/lti/converters/time_json_converter.rb +13 -0
  17. data/lib/ims/lti/converters.rb +5 -0
  18. data/lib/ims/lti/deprecated_role_checks.rb +52 -0
  19. data/lib/ims/lti/errors/authentication_failed_error.rb +11 -0
  20. data/lib/ims/lti/errors/invalid_lti_config_error.rb +4 -0
  21. data/lib/ims/lti/errors/invalid_tool_consumer_profile.rb +4 -0
  22. data/lib/ims/lti/errors/tool_proxy_registration_error.rb +15 -0
  23. data/lib/ims/lti/errors.rb +8 -0
  24. data/lib/ims/lti/extensions/canvas.rb +125 -0
  25. data/lib/ims/lti/extensions/content.rb +209 -0
  26. data/lib/ims/lti/extensions/outcome_data.rb +216 -0
  27. data/lib/ims/lti/extensions.rb +45 -0
  28. data/lib/ims/lti/launch_params.rb +166 -0
  29. data/lib/ims/lti/models/base_url_choice.rb +15 -0
  30. data/lib/ims/lti/models/base_url_selector.rb +5 -0
  31. data/lib/ims/lti/models/contact.rb +5 -0
  32. data/lib/ims/lti/models/content_item_container.rb +14 -0
  33. data/lib/ims/lti/models/content_item_placement.rb +20 -0
  34. data/lib/ims/lti/models/content_items/content_item.rb +32 -0
  35. data/lib/ims/lti/models/content_items/file_item.rb +15 -0
  36. data/lib/ims/lti/models/content_items/lti_link_item.rb +14 -0
  37. data/lib/ims/lti/models/content_items.rb +7 -0
  38. data/lib/ims/lti/models/icon_endpoint.rb +5 -0
  39. data/lib/ims/lti/models/icon_info.rb +6 -0
  40. data/lib/ims/lti/models/image.rb +7 -0
  41. data/lib/ims/lti/models/localized_name.rb +12 -0
  42. data/lib/ims/lti/models/localized_text.rb +12 -0
  43. data/lib/ims/lti/models/lti_model.rb +227 -0
  44. data/lib/ims/lti/models/membership_service/agent.rb +11 -0
  45. data/lib/ims/lti/models/membership_service/container.rb +11 -0
  46. data/lib/ims/lti/models/membership_service/context.rb +11 -0
  47. data/lib/ims/lti/models/membership_service/lis_membership_container.rb +13 -0
  48. data/lib/ims/lti/models/membership_service/lis_person.rb +14 -0
  49. data/lib/ims/lti/models/membership_service/membership.rb +14 -0
  50. data/lib/ims/lti/models/membership_service/organization.rb +14 -0
  51. data/lib/ims/lti/models/membership_service/page.rb +16 -0
  52. data/lib/ims/lti/models/membership_service/person.rb +13 -0
  53. data/lib/ims/lti/models/membership_service.rb +16 -0
  54. data/lib/ims/lti/models/message_handler.rb +14 -0
  55. data/lib/ims/lti/models/messages/basic_lti_launch_request.rb +24 -0
  56. data/lib/ims/lti/models/messages/content_item_selection.rb +32 -0
  57. data/lib/ims/lti/models/messages/content_item_selection_request.rb +26 -0
  58. data/lib/ims/lti/models/messages/message.rb +222 -0
  59. data/lib/ims/lti/models/messages/registration_request.rb +20 -0
  60. data/lib/ims/lti/models/messages/request_message.rb +12 -0
  61. data/lib/ims/lti/models/messages/tool_proxy_update_request.rb +15 -0
  62. data/lib/ims/lti/models/messages.rb +11 -0
  63. data/lib/ims/lti/models/parameter.rb +28 -0
  64. data/lib/ims/lti/models/product_family.rb +8 -0
  65. data/lib/ims/lti/models/product_info.rb +26 -0
  66. data/lib/ims/lti/models/product_instance.rb +10 -0
  67. data/lib/ims/lti/models/resource_handler.rb +22 -0
  68. data/lib/ims/lti/models/resource_type.rb +6 -0
  69. data/lib/ims/lti/models/rest_service.rb +30 -0
  70. data/lib/ims/lti/models/rest_service_profile.rb +15 -0
  71. data/lib/ims/lti/models/security_contract.rb +21 -0
  72. data/lib/ims/lti/models/security_profile.rb +10 -0
  73. data/lib/ims/lti/models/serializable.rb +12 -0
  74. data/lib/ims/lti/models/service_owner.rb +26 -0
  75. data/lib/ims/lti/models/service_provider.rb +11 -0
  76. data/lib/ims/lti/models/tool_consumer_profile.rb +45 -0
  77. data/lib/ims/lti/models/tool_profile.rb +35 -0
  78. data/lib/ims/lti/models/tool_proxy.rb +21 -0
  79. data/lib/ims/lti/models/tool_setting.rb +12 -0
  80. data/lib/ims/lti/models/tool_setting_container.rb +14 -0
  81. data/lib/ims/lti/models/vendor.rb +28 -0
  82. data/lib/ims/lti/models.rb +38 -0
  83. data/lib/ims/lti/outcome_request.rb +225 -0
  84. data/lib/ims/lti/outcome_response.rb +166 -0
  85. data/lib/ims/lti/request_validator.rb +56 -0
  86. data/lib/ims/lti/role_checks.rb +101 -0
  87. data/lib/ims/lti/serializers/base.rb +125 -0
  88. data/lib/ims/lti/serializers/membership_service/agent_serializer.rb +5 -0
  89. data/lib/ims/lti/serializers/membership_service/container_serializer.rb +6 -0
  90. data/lib/ims/lti/serializers/membership_service/context_serializer.rb +9 -0
  91. data/lib/ims/lti/serializers/membership_service/lis_membership_container_serializer.rb +9 -0
  92. data/lib/ims/lti/serializers/membership_service/lis_person_serializer.rb +12 -0
  93. data/lib/ims/lti/serializers/membership_service/membership_serializer.rb +7 -0
  94. data/lib/ims/lti/serializers/membership_service/organization_serializer.rb +8 -0
  95. data/lib/ims/lti/serializers/membership_service/page_serializer.rb +10 -0
  96. data/lib/ims/lti/serializers/membership_service/person_serializer.rb +8 -0
  97. data/lib/ims/lti/serializers/membership_service.rb +13 -0
  98. data/lib/ims/lti/serializers.rb +6 -0
  99. data/lib/ims/lti/services/authentication_service.rb +67 -0
  100. data/lib/ims/lti/services/message_authenticator.rb +80 -0
  101. data/lib/ims/lti/services/oauth2_client.rb +18 -0
  102. data/lib/ims/lti/services/tool_config.rb +223 -0
  103. data/lib/ims/lti/services/tool_consumer_profile_service.rb +16 -0
  104. data/lib/ims/lti/services/tool_proxy_registration_service.rb +84 -0
  105. data/lib/ims/lti/services/tool_proxy_validator.rb +182 -0
  106. data/lib/ims/lti/services.rb +11 -0
  107. data/lib/ims/lti/tool_base.rb +29 -0
  108. data/lib/ims/lti/tool_config.rb +231 -0
  109. data/lib/ims/lti/tool_consumer.rb +86 -0
  110. data/lib/ims/lti/tool_provider.rb +143 -0
  111. data/lib/ims/lti/version.rb +5 -0
  112. data/lib/ims/lti.rb +61 -0
  113. data/lib/ims.rb +4 -0
  114. metadata +379 -0
@@ -0,0 +1,32 @@
1
+ module IMS::LTI::Models::ContentItems
2
+ class ContentItem < IMS::LTI::Models::LTIModel
3
+
4
+ add_attributes :text, :title, :url, :confirmUrl
5
+ add_attribute :media_type, json_key: 'mediaType'
6
+ add_attribute :type, json_key: '@type'
7
+ add_attribute :id, json_key: '@id'
8
+ add_attribute :icon, relation: 'IMS::LTI::Models::Image'
9
+ add_attribute :placement_advice, json_key:'placementAdvice', relation: 'IMS::LTI::Models::ContentItemPlacement'
10
+ add_attribute :thumbnail, relation: 'IMS::LTI::Models::Image'
11
+
12
+ TYPE = "ContentItem"
13
+
14
+ def initialize(attributes = {})
15
+ super(attributes)
16
+ self.type = TYPE
17
+ end
18
+
19
+ def self.from_json(json)
20
+ data = json.is_a?(String) ? JSON.parse(json) : json
21
+ case data['@type']
22
+ when 'FileItem'
23
+ FileItem.new.from_json(data)
24
+ when 'LtiLinkItem', 'LtiLink'
25
+ LtiLinkItem.new.from_json(data)
26
+ else
27
+ ContentItem.new.from_json(data)
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ module IMS::LTI::Models::ContentItems
2
+ class FileItem < ContentItem
3
+
4
+ add_attribute :copy_advice, json_key: 'copyAdvice'
5
+ add_attribute :expires_at, json_key: 'expiresAt'
6
+
7
+ TYPE = "FileItem"
8
+
9
+ def initialize(attributes = {})
10
+ super(attributes)
11
+ self.type = TYPE
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module IMS::LTI::Models::ContentItems
2
+ class LtiLinkItem < ContentItem
3
+
4
+ add_attributes :custom
5
+
6
+ TYPE = "LtiLinkItem"
7
+
8
+ def initialize(attributes = {})
9
+ super(attributes)
10
+ self.type = TYPE
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ module IMS::LTI::Models
2
+ module ContentItems
3
+ require_relative 'content_items/content_item'
4
+ require_relative 'content_items/file_item'
5
+ require_relative 'content_items/lti_link_item'
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module IMS::LTI::Models
2
+ class IconEndpoint < LTIModel
3
+ add_attribute :path
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module IMS::LTI::Models
2
+ class IconInfo < LTIModel
3
+ add_attributes :key, :icon_style
4
+ add_attribute :default_location, relation: 'IMS::LTI::Models::IconEndpoint'
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module IMS::LTI::Models
2
+ class Image < LTIModel
3
+ add_attribute :id, json_key: '@id'
4
+ add_attributes :height, :width
5
+
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module IMS::LTI::Models
2
+ class LocalizedName < LTIModel
3
+ add_attributes :default_value, :key
4
+
5
+ def initialize(default_value = nil, key = nil)
6
+ @default_value = default_value
7
+ @key = key
8
+ super()
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module IMS::LTI::Models
2
+ class LocalizedText < LTIModel
3
+ add_attributes :default_value, :key
4
+
5
+ def initialize(default_value = nil, key = nil)
6
+ super()
7
+ @default_value = default_value
8
+ @key = key
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,227 @@
1
+ module IMS::LTI::Models
2
+ require 'uri'
3
+
4
+ class LTIModel
5
+ LTI_VERSION_2P0 = 'LTI-2p0'.freeze
6
+ LTI_VERSION_2P1 = 'LTI-2p1'.freeze
7
+
8
+ def initialize(attributes = {})
9
+ @ext_attributes = {}
10
+ @unknown_attributes = {}
11
+ self.attributes = attributes
12
+ end
13
+
14
+ def self.add_attributes(attribute, *attrs)
15
+ attrs.unshift(attribute)
16
+ attrs -= self.attributes
17
+ if attrs.size > 0
18
+ self.attributes += attrs
19
+ attr_accessor(attrs.shift, *attrs)
20
+ end
21
+ end
22
+
23
+ def self.add_attribute(attribute, options = {})
24
+ @serialization_options ||= {}
25
+ keys = @serialization_options.keys + options.keys
26
+ keys.each do |k|
27
+ @serialization_options[k] ||= {}
28
+ options.has_key?(k) ? @serialization_options[k][attribute] = options[k] : @serialization_options[k].delete(attribute)
29
+ end
30
+ unless self.attributes.include? attribute
31
+ self.attributes += [attribute]
32
+ attr_accessor(attribute)
33
+ end
34
+ end
35
+
36
+ def self.inherit_attributes(attrs)
37
+ attributes ||= []
38
+ self.attributes += attrs
39
+ end
40
+
41
+ def self.inherited(subclass)
42
+ subclass.inherit_attributes(self.attributes)
43
+ super
44
+ end
45
+
46
+ def self.from_json(json)
47
+ new.from_json(json)
48
+ end
49
+
50
+ def attributes
51
+ attrs = {}
52
+ self.class.attributes.each do |a|
53
+ value = instance_variable_get("@#{a.to_s}")
54
+ attrs[a.to_s] = value unless value == nil
55
+ end
56
+ attrs
57
+ end
58
+
59
+ def attributes=(attrs)
60
+ attrs.each do |k, v|
61
+ if self.class.attributes.include?(k.to_sym)
62
+ send(("#{k}=").to_sym, v)
63
+ elsif k.to_s =~ /^ext_/
64
+ @ext_attributes[k.to_sym] = v
65
+ else
66
+ warn("Unknown attribute '#{k}'")
67
+ @unknown_attributes[k.to_sym] = v
68
+ end
69
+ end
70
+ end
71
+
72
+ def as_json(options = {})
73
+ json_hash = attributes
74
+ serialization_attrs_for(:json_key).each { |attr| json_hash.delete(attr.to_s) }
75
+ serialization_attrs_for(:relation).each do |attr|
76
+ val = attributes[attr.to_s]
77
+ if val && val.is_a?(Array)
78
+ json_hash[json_key(attr)] = val.map { |v| v.as_json }
79
+ elsif val
80
+ json_hash[json_key(attr)] = val.as_json
81
+ end
82
+ end
83
+ json_hash = @unknown_attributes.merge(json_hash)
84
+ json_hash = @ext_attributes.merge(json_hash)
85
+ json_hash.merge! to_json_conversions
86
+ json_hash.merge! to_json_keys
87
+ json_hash
88
+ end
89
+
90
+ def to_json
91
+ self.as_json.to_json
92
+ end
93
+
94
+ def from_json(json)
95
+ json = json.to_json unless json.is_a?(String)
96
+ begin
97
+ data = JSON.parse(json)
98
+ rescue
99
+ data = JSON.parse(URI.unescape(json))
100
+ end
101
+
102
+ if data.is_a? Array
103
+ data.map { |hash| self.class.from_json(hash.to_json) }
104
+ else
105
+ process_json_hash(data)
106
+ end
107
+ end
108
+
109
+ def method_missing(meth, *args, &block)
110
+ proc = ->(attr, hash) {meth =~ /=$/ ? hash[attr] = args[0] : hash[attr] }
111
+ if (match = /^ext_([^=$]*)/.match(meth))
112
+ proc.call(match.to_s.to_sym, @ext_attributes)
113
+ elsif (match = /([^=$]*)/.match(meth))
114
+ proc.call(match.to_s.to_sym, @unknown_attributes)
115
+ else
116
+ super
117
+ end
118
+ end
119
+
120
+ private
121
+
122
+ def process_json_hash(hash)
123
+ change_json_keys_to_attrs!(hash)
124
+ hash.merge! from_json_conversions(hash)
125
+ deserialize_json_relations!(hash)
126
+ self.attributes=(hash)
127
+ self
128
+ end
129
+
130
+ def serialization_attrs_for(*keys)
131
+ Array.new(serialization_options.keys & keys).map { |opt| serialization_options[opt].keys }.flatten.uniq
132
+ end
133
+
134
+ def to_json_conversions
135
+ result = {}
136
+ if converters = serialization_options[:json_converter]
137
+ converters.each do |attr, converter|
138
+ value = attributes[attr.to_s]
139
+ result[json_key(attr)] = get_constant(converter).to_json_value(value) if value
140
+ end
141
+ end
142
+ result
143
+ end
144
+
145
+ def to_json_keys
146
+ result = {}
147
+ if attrs = serialization_attrs_for(:json_key)
148
+ conversion_attrs = serialization_attrs_for(:json_converter)
149
+ relation_attrs = serialization_attrs_for(:relation)
150
+ attrs.each { |attr| result[json_key(attr)] = attributes[attr.to_s] unless (conversion_attrs | relation_attrs).include?(attr) || attributes[attr.to_s].nil? }
151
+ end
152
+ result
153
+ end
154
+
155
+ def change_json_keys_to_attrs!(json_hash)
156
+ if attrs = serialization_attrs_for(:json_key)
157
+ attrs.each do |attr|
158
+ key = json_key(attr)
159
+ json_hash[attr.to_s] = json_hash.delete(key) if json_hash.has_key?(key)
160
+ end
161
+ end
162
+ end
163
+
164
+ def from_json_conversions(hash)
165
+ result = {}
166
+ if converters = serialization_options[:json_converter]
167
+ converters.each do |attr, converter|
168
+ result[attr] = get_constant(converter).from_json_value(hash[attr.to_s]) if hash[attr.to_s]
169
+ end
170
+ end
171
+ result
172
+ end
173
+
174
+ def deserialize_json_relations!(hash)
175
+ if relations = serialization_options[:relation]
176
+ attrs = {}
177
+ relations.each do |attr, relation|
178
+ hash_val = hash.delete(attr.to_s)
179
+ attrs[attr.to_s] = get_constant(relation).new.from_json(hash_val.to_json) if hash_val
180
+ end
181
+ self.attributes = attrs
182
+ end
183
+ end
184
+
185
+ def json_key(attr)
186
+ if json_keys = serialization_options[:json_key]
187
+ json_keys[attr] || attr
188
+ else
189
+ attr
190
+ end.to_s
191
+ end
192
+
193
+ def self.attributes
194
+ if self == LTIModel
195
+ @attributes || []
196
+ else
197
+ superclass.send(:attributes) | (@attributes || [])
198
+ end
199
+ end
200
+
201
+ def self.attributes=(attribs)
202
+ @attributes = attribs
203
+ end
204
+
205
+ def self.serialization_options()
206
+ @serialization_options ||= {}
207
+ if name == "IMS::LTI::Models::LTIModel"
208
+ @serialization_options
209
+ else
210
+ opts = superclass.send(:serialization_options) || {}
211
+ keys = opts.keys | @serialization_options.keys
212
+ keys.each_with_object({}) { |k, h| h[k] = (opts[k] || {}).merge(@serialization_options[k] || {}) }
213
+ end
214
+ end
215
+
216
+ def serialization_options
217
+ self.class.serialization_options
218
+ end
219
+
220
+ def get_constant(constant)
221
+ obj = Object
222
+ constant.split('::').each { |c| obj = obj.const_get(c) }
223
+ obj
224
+ end
225
+
226
+ end
227
+ end
@@ -0,0 +1,11 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class Agent
3
+ include IMS::LTI::Models::Serializable
4
+
5
+ attr_reader :id
6
+
7
+ def initialize(opts={})
8
+ @id = opts[:id]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class Container
3
+ include IMS::LTI::Models::Serializable
4
+
5
+ attr_reader :membership_predicate, :membership_subject
6
+
7
+ def initialize(opts={})
8
+ @membership_subject = opts[:membership_subject]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class Context < Organization
3
+ attr_reader :context_id
4
+
5
+ def initialize(opts={})
6
+ super(opts)
7
+ @type = 'Context'
8
+ @context_id = opts[:context_id]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class LISMembershipContainer < Container
3
+ attr_reader :context, :type, :id
4
+
5
+ def initialize(opts={})
6
+ super(opts)
7
+ @id = opts[:id]
8
+ @context = 'http://purl.imsglobal.org/ctx/lis/v2/MembershipContainer'
9
+ @type = 'LISMembershipContainer'
10
+ @membership_predicate = 'http://www.w3.org/ns/org#membership'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class LISPerson < Person
3
+ attr_reader :email, :result_sourced_id, :sourced_id, :user_id, :sis_id
4
+
5
+ def initialize(opts={})
6
+ super(opts)
7
+ @email = opts[:email]
8
+ @result_sourced_id = opts[:result_sourced_id]
9
+ @sourced_id = opts[:sourced_id]
10
+ @user_id = opts[:user_id]
11
+ @sis_id = opts[:sis_id]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class Membership
3
+ include IMS::LTI::Models::Serializable
4
+
5
+ attr_reader :id, :status, :member, :role
6
+
7
+ def initialize(opts={})
8
+ @id = opts[:id]
9
+ @status = opts[:status]
10
+ @member = opts[:member]
11
+ @role = opts[:role]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class Organization
3
+ include IMS::LTI::Models::Serializable
4
+
5
+ attr_reader :id, :membership, :name, :type
6
+
7
+ def initialize(opts={})
8
+ @id = opts[:id]
9
+ @membership = opts[:membership]
10
+ @name = opts[:name]
11
+ @type = 'Organization'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class Page
3
+ include IMS::LTI::Models::Serializable
4
+
5
+ attr_reader :id, :type, :context, :differences, :page_of, :next_page
6
+
7
+ def initialize(opts={})
8
+ @id = opts[:id]
9
+ @type = 'Page'
10
+ @context = 'http://purl.imsglobal.org/ctx/lis/v2/MembershipContainer'
11
+ @differences = opts[:differences]
12
+ @page_of = opts[:page_of]
13
+ @next_page = opts[:next_page]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module IMS::LTI::Models::MembershipService
2
+ class Person < Agent
3
+ attr_reader :family_name, :name, :img, :given_name
4
+
5
+ def initialize(opts={})
6
+ super(opts)
7
+ @family_name = opts[:family_name]
8
+ @name = opts[:name]
9
+ @img = opts[:img]
10
+ @given_name = opts[:given_name]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module IMS::LTI::Models
2
+ module MembershipService
3
+ require_relative 'membership_service/agent'
4
+ require_relative 'membership_service/person'
5
+ require_relative 'membership_service/lis_person'
6
+
7
+ require_relative 'membership_service/container'
8
+ require_relative 'membership_service/lis_membership_container'
9
+
10
+ require_relative 'membership_service/organization'
11
+ require_relative 'membership_service/context'
12
+
13
+ require_relative 'membership_service/membership'
14
+ require_relative 'membership_service/page'
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module IMS::LTI::Models
2
+ class MessageHandler < LTIModel
3
+ add_attributes :message_type, :path, :enabled_capability
4
+ add_attribute :parameter, relation:'IMS::LTI::Models::Parameter'
5
+
6
+ def enabled_capabilities
7
+ [*enabled_capability]
8
+ end
9
+
10
+ def parameters
11
+ [*parameter]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ module IMS::LTI::Models::Messages
2
+ class BasicLTILaunchRequest < RequestMessage
3
+
4
+ add_required_params :resource_link_id
5
+ add_recommended_params :context_id, :launch_presentation_return_url, :tool_consumer_instance_guid
6
+ add_optional_params :context_type, :role_scope_mentor, :user_image,
7
+ :lis_outcome_service_url, :lis_person_sourced_id, :lis_result_sourcedid
8
+ add_deprecated_params :context_title, :context_label, :resource_link_title, :resource_link_description,
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, :tool_consumer_instance_url,
14
+ :tool_consumer_instance_contact_email, :tool_consumer_info_version
15
+
16
+ MESSAGE_TYPE = 'basic-lti-launch-request'
17
+
18
+ def initialize(attrs = {})
19
+ super(attrs)
20
+ self.lti_message_type = MESSAGE_TYPE
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,32 @@
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
+ MESSAGE_TYPE = 'ContentItemSelection'
6
+
7
+ def initialize(attrs = {})
8
+ super(attrs)
9
+ self.lti_message_type = MESSAGE_TYPE
10
+ end
11
+
12
+ def content_items=(ci)
13
+ if ci.instance_of? String
14
+ container = IMS::LTI::Models::ContentItemContainer.from_json ci
15
+ @content_items = container.graph
16
+ else
17
+ @content_items = ci
18
+ end
19
+ end
20
+
21
+ def parameters
22
+ if content_items
23
+ params = self.class.send("parameters")
24
+ params.delete('content_items')
25
+ collect_attributes(params).merge({'content_items' => IMS::LTI::Models::ContentItemContainer.new(graph: content_items).to_json})
26
+ else
27
+ super
28
+ end
29
+ end
30
+
31
+ end
32
+ 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