ims-lti 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +3 -0
- data/README.md +9 -9
- data/lib/ims/lti/extensions/outcome_data.rb +48 -8
- data/lib/ims/lti/outcome_request.rb +4 -4
- data/lib/ims/lti/outcome_response.rb +2 -1
- data/lib/ims/lti/tool_base.rb +8 -1
- data/lib/ims/lti/tool_consumer.rb +1 -9
- data/lib/ims/lti/tool_provider.rb +1 -9
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c0efa0ce7f96bcb4ef189cfd60206dada68fa6
|
4
|
+
data.tar.gz: 1a788b9cef77da96a66b68426fb8ca3c5bbc29f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe08421395b4c2de12200c3e981ea0e62a5dac27d6c505360605693b2da7fb7e1a64f48b665136edb1aaec0e1ee31f14c0ce35ac42ad9c3b71d1ed3f88782c6f
|
7
|
+
data.tar.gz: b795c096542903e7306631f97c4d441316db70e13edbec0413c9f3b3d2d8334db8e0bbb6d13488525aae62be65550ed41276e3ba5019fe24e2a3f01d4ac44e0c
|
data/Changelog
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ To require the library in your project:
|
|
16
16
|
To validate the OAuth signatures you need to require the appropriate request
|
17
17
|
proxy for your application. For example:
|
18
18
|
|
19
|
-
# For a Sinatra or a Rails 3 app:
|
19
|
+
# For a Sinatra or a Rails 3 or 4 app:
|
20
20
|
require 'oauth/request_proxy/rack_request'
|
21
21
|
# You also need to explicitly enable OAuth 1 support in the environment.rb or an initializer:
|
22
22
|
OAUTH_10_SUPPORT = true
|
@@ -32,20 +32,20 @@ very helpful to read the [LTI documentation](http://www.imsglobal.org/lti/index.
|
|
32
32
|
|
33
33
|
In LTI there are Tool Providers (TP) and Tool Consumers (TC), this library is
|
34
34
|
useful for implementing both. Here is an overview of the communication process:
|
35
|
-
[LTI 1.1 Introduction](http://www.imsglobal.org/
|
35
|
+
[LTI 1.1 Introduction](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560461)
|
36
36
|
|
37
37
|
This library doesn't help you manage the consumer keys and secrets. The POST
|
38
38
|
headers/parameters will contain the `oauth_consumer_key` and your app can use
|
39
39
|
that to look up the appropriate `oauth_consumer_secret`.
|
40
40
|
|
41
41
|
Your app will also need to manage the OAuth nonce to make sure the same nonce
|
42
|
-
isn't used twice with the same timestamp. [Read the LTI documentation on OAuth](http://www.imsglobal.org/LTI/
|
42
|
+
isn't used twice with the same timestamp. [Read the LTI documentation on OAuth](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560468).
|
43
43
|
|
44
44
|
### Tool Provider
|
45
45
|
As a TP your app will receive a POST request with a bunch of
|
46
|
-
[LTI launch data](http://www.imsglobal.org/
|
46
|
+
[LTI launch data](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560465)
|
47
47
|
and it will be signed with OAuth using a key/secret that both the TP and TC share.
|
48
|
-
This is covered in the [LTI security model](http://www.imsglobal.org/
|
48
|
+
This is covered in the [LTI security model](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560466)
|
49
49
|
|
50
50
|
Here is an example of a simple TP Sinatra app using this gem:
|
51
51
|
[LTI Tool Provider](https://github.com/instructure/lti_tool_provider_example)
|
@@ -66,13 +66,13 @@ end
|
|
66
66
|
```
|
67
67
|
|
68
68
|
Once your TP object is initialized and verified you can load your tool. All of the
|
69
|
-
[launch data](http://www.imsglobal.org/
|
69
|
+
[launch data](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560465)
|
70
70
|
is available in the TP object along with some convenience methods like `provider.username`
|
71
71
|
which will try to find the name from the 3 potential name launch data attributes.
|
72
72
|
|
73
73
|
#### Returning Results of a Quiz/Assignment
|
74
74
|
If your TP provides some kind of assessment service you can write grades back to
|
75
|
-
the TC. This is documented in the LTI docs [here](http://www.imsglobal.org/
|
75
|
+
the TC. This is documented in the LTI docs [here](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560471).
|
76
76
|
|
77
77
|
You can check whether the TC is expecting a grade write-back:
|
78
78
|
|
@@ -105,8 +105,8 @@ You can see the error code documentation
|
|
105
105
|
|
106
106
|
### Tool Consumer
|
107
107
|
As a Tool Consumer your app will POST an OAuth-signed launch requests to TPs with the necessary
|
108
|
-
[LTI launch data](http://www.imsglobal.org/
|
109
|
-
This is covered in the [LTI security model](http://www.imsglobal.org/
|
108
|
+
[LTI launch data](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560465).
|
109
|
+
This is covered in the [LTI security model](http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560466)
|
110
110
|
|
111
111
|
Here is an example of a simple TC Sinatra app using this gem:
|
112
112
|
[LTI Tool Consumer](https://github.com/instructure/lti_tool_consumer_example)
|
@@ -67,6 +67,10 @@ module IMS::LTI
|
|
67
67
|
accepted_outcome_types.member?("url")
|
68
68
|
end
|
69
69
|
|
70
|
+
def accepts_outcome_result_total_score?
|
71
|
+
!!@ext_params["outcome_result_total_score_accepted"]
|
72
|
+
end
|
73
|
+
|
70
74
|
# POSTs the given score to the Tool Consumer with a replaceResult and
|
71
75
|
# adds the specified data. The data hash can have the keys "text", "cdata_text", or "url"
|
72
76
|
#
|
@@ -77,6 +81,7 @@ module IMS::LTI
|
|
77
81
|
# Creates a new OutcomeRequest object and stores it in @outcome_requests
|
78
82
|
#
|
79
83
|
# @return [OutcomeResponse] the response from the Tool Consumer
|
84
|
+
# @deprecated Use #post_extended_replace_result! instead
|
80
85
|
def post_replace_result_with_data!(score = nil, data={})
|
81
86
|
req = new_request
|
82
87
|
if data["cdata_text"]
|
@@ -87,6 +92,29 @@ module IMS::LTI
|
|
87
92
|
req.outcome_url = data["url"] if data["url"]
|
88
93
|
req.post_replace_result!(score)
|
89
94
|
end
|
95
|
+
|
96
|
+
# POSTs the given score to the Tool Consumer with a replaceResult and
|
97
|
+
# adds the specified data. The options hash can have the keys
|
98
|
+
# :text, :cdata_text, :url, :score, or :total_score
|
99
|
+
#
|
100
|
+
# If both cdata_text and text are sent, cdata_text will be used
|
101
|
+
# If both total_score and score are sent, total_score will be used
|
102
|
+
# If score is nil, the replace result XML will not contain a resultScore node
|
103
|
+
#
|
104
|
+
# Creates a new OutcomeRequest object and stores it in @outcome_requests
|
105
|
+
#
|
106
|
+
# @return [OutcomeResponse] the response from the Tool Consumer
|
107
|
+
def post_extended_replace_result!(options = {})
|
108
|
+
opts = {}
|
109
|
+
options.each {|k,v| opts[k.to_sym] = v}
|
110
|
+
|
111
|
+
req = new_request
|
112
|
+
req.outcome_cdata_text = opts[:cdata_text]
|
113
|
+
req.outcome_text = opts[:text]
|
114
|
+
req.outcome_url = opts[:url]
|
115
|
+
req.total_score = opts[:total_score]
|
116
|
+
req.post_replace_result!(opts[:score])
|
117
|
+
end
|
90
118
|
end
|
91
119
|
|
92
120
|
module ToolConsumer
|
@@ -123,26 +151,38 @@ module IMS::LTI
|
|
123
151
|
include IMS::LTI::Extensions::ExtensionBase
|
124
152
|
include Base
|
125
153
|
|
126
|
-
attr_accessor :outcome_text, :outcome_url, :outcome_cdata_text
|
154
|
+
attr_accessor :outcome_text, :outcome_url, :outcome_cdata_text, :total_score
|
127
155
|
|
128
156
|
def result_values(node)
|
129
157
|
super
|
130
|
-
|
158
|
+
|
159
|
+
if total_score
|
160
|
+
node.resultTotalScore do |res_total_score|
|
161
|
+
res_total_score.language "en" # 'en' represents the format of the number
|
162
|
+
res_total_score.textString total_score.to_s
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
if outcome_text || outcome_url || outcome_cdata_text
|
131
167
|
node.resultData do |res_data|
|
132
|
-
if
|
168
|
+
if outcome_cdata_text
|
133
169
|
res_data.text {
|
134
|
-
res_data.cdata!
|
170
|
+
res_data.cdata! outcome_cdata_text
|
135
171
|
}
|
136
|
-
elsif
|
137
|
-
res_data.text
|
172
|
+
elsif outcome_text
|
173
|
+
res_data.text outcome_text
|
138
174
|
end
|
139
|
-
res_data.url
|
175
|
+
res_data.url outcome_url if outcome_url
|
140
176
|
end
|
141
177
|
end
|
142
178
|
end
|
143
179
|
|
180
|
+
def score
|
181
|
+
total_score ? nil : @score
|
182
|
+
end
|
183
|
+
|
144
184
|
def has_result_data?
|
145
|
-
|
185
|
+
!!outcome_text || !!outcome_url || !!outcome_cdata_text || !!total_score || super
|
146
186
|
end
|
147
187
|
|
148
188
|
def extention_process_xml(doc)
|
@@ -154,7 +154,7 @@ module IMS::LTI
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def has_result_data?
|
157
|
-
|
157
|
+
!!score
|
158
158
|
end
|
159
159
|
|
160
160
|
def results(node)
|
@@ -166,10 +166,10 @@ module IMS::LTI
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def result_values(node)
|
169
|
-
if
|
169
|
+
if score
|
170
170
|
node.resultScore do |res_score|
|
171
171
|
res_score.language "en" # 'en' represents the format of the number
|
172
|
-
res_score.textString
|
172
|
+
res_score.textString score.to_s
|
173
173
|
end
|
174
174
|
end
|
175
175
|
end
|
@@ -182,7 +182,7 @@ module IMS::LTI
|
|
182
182
|
builder = Builder::XmlMarkup.new #(:indent=>2)
|
183
183
|
builder.instruct!
|
184
184
|
|
185
|
-
builder.imsx_POXEnvelopeRequest("xmlns" => "http://www.imsglobal.org/
|
185
|
+
builder.imsx_POXEnvelopeRequest("xmlns" => "http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0") do |env|
|
186
186
|
env.imsx_POXHeader do |header|
|
187
187
|
header.imsx_POXRequestHeaderInfo do |info|
|
188
188
|
info.imsx_version "V1.0"
|
@@ -125,7 +125,8 @@ module IMS::LTI
|
|
125
125
|
builder = Builder::XmlMarkup.new
|
126
126
|
builder.instruct!
|
127
127
|
|
128
|
-
builder.imsx_POXEnvelopeResponse("xmlns" => "http://www.imsglobal.org/lis/oms1p0/pox") do |env|
|
128
|
+
# builder.imsx_POXEnvelopeResponse("xmlns" => "http://www.imsglobal.org/lis/oms1p0/pox") do |env|
|
129
|
+
builder.imsx_POXEnvelopeResponse("xmlns" => "http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0") do |env|
|
129
130
|
env.imsx_POXHeader do |header|
|
130
131
|
header.imsx_POXResponseHeaderInfo do |info|
|
131
132
|
info.imsx_version "V1.0"
|
data/lib/ims/lti/tool_base.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
module IMS::LTI
|
2
2
|
class ToolBase
|
3
|
+
include IMS::LTI::Extensions::Base
|
4
|
+
include IMS::LTI::LaunchParams
|
5
|
+
include IMS::LTI::RequestValidator
|
3
6
|
|
4
7
|
# OAuth credentials
|
5
8
|
attr_accessor :consumer_key, :consumer_secret
|
6
9
|
|
7
|
-
def initialize(consumer_key, consumer_secret)
|
10
|
+
def initialize(consumer_key, consumer_secret, params={})
|
8
11
|
@consumer_key = consumer_key
|
9
12
|
@consumer_secret = consumer_secret
|
13
|
+
@custom_params = {}
|
14
|
+
@ext_params = {}
|
15
|
+
@non_spec_params = {}
|
16
|
+
process_params(params)
|
10
17
|
end
|
11
18
|
|
12
19
|
# Convenience method for doing oauth signed requests to services that
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module IMS::LTI
|
2
2
|
# Class for implementing an LTI Tool Consumer
|
3
3
|
class ToolConsumer < ToolBase
|
4
|
-
include IMS::LTI::Extensions::Base
|
5
|
-
include IMS::LTI::LaunchParams
|
6
|
-
include IMS::LTI::RequestValidator
|
7
|
-
|
8
4
|
attr_accessor :launch_url, :timestamp, :nonce
|
9
5
|
|
10
6
|
# Create a new ToolConsumer
|
@@ -13,12 +9,8 @@ module IMS::LTI
|
|
13
9
|
# @param consumer_secret [String] The OAuth consumer secret
|
14
10
|
# @param params [Hash] Set the launch parameters as described in LaunchParams
|
15
11
|
def initialize(consumer_key, consumer_secret, params={})
|
16
|
-
super(consumer_key, consumer_secret)
|
17
|
-
@custom_params = {}
|
18
|
-
@ext_params = {}
|
19
|
-
@non_spec_params = {}
|
12
|
+
super(consumer_key, consumer_secret, params)
|
20
13
|
@launch_url = params['launch_url']
|
21
|
-
process_params(params)
|
22
14
|
end
|
23
15
|
|
24
16
|
def process_post_request(post_request)
|
@@ -34,10 +34,6 @@ module IMS::LTI
|
|
34
34
|
# end
|
35
35
|
|
36
36
|
class ToolProvider < ToolBase
|
37
|
-
include IMS::LTI::Extensions::Base
|
38
|
-
include IMS::LTI::LaunchParams
|
39
|
-
include IMS::LTI::RequestValidator
|
40
|
-
|
41
37
|
# List of outcome requests made through this instance
|
42
38
|
attr_accessor :outcome_requests
|
43
39
|
# Message to be sent back to the ToolConsumer when the user returns
|
@@ -49,12 +45,8 @@ module IMS::LTI
|
|
49
45
|
# @param consumer_secret [String] The OAuth consumer secret
|
50
46
|
# @param params [Hash] Set the launch parameters as described in LaunchParams
|
51
47
|
def initialize(consumer_key, consumer_secret, params={})
|
52
|
-
super(consumer_key, consumer_secret)
|
53
|
-
@custom_params = {}
|
54
|
-
@ext_params = {}
|
55
|
-
@non_spec_params = {}
|
48
|
+
super(consumer_key, consumer_secret, params)
|
56
49
|
@outcome_requests = []
|
57
|
-
process_params(params)
|
58
50
|
end
|
59
51
|
|
60
52
|
# Check whether the Launch Parameters have a role
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ims-lti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: oauth
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.4.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.4.5
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: uuid
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ruby-debug
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
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
82
|
version: '0'
|
83
83
|
description:
|
@@ -87,10 +87,15 @@ extensions: []
|
|
87
87
|
extra_rdoc_files:
|
88
88
|
- LICENSE
|
89
89
|
files:
|
90
|
+
- Changelog
|
91
|
+
- LICENSE
|
92
|
+
- README.md
|
93
|
+
- lib/ims.rb
|
94
|
+
- lib/ims/lti.rb
|
95
|
+
- lib/ims/lti/extensions.rb
|
90
96
|
- lib/ims/lti/extensions/canvas.rb
|
91
97
|
- lib/ims/lti/extensions/content.rb
|
92
98
|
- lib/ims/lti/extensions/outcome_data.rb
|
93
|
-
- lib/ims/lti/extensions.rb
|
94
99
|
- lib/ims/lti/launch_params.rb
|
95
100
|
- lib/ims/lti/outcome_request.rb
|
96
101
|
- lib/ims/lti/outcome_response.rb
|
@@ -99,11 +104,6 @@ files:
|
|
99
104
|
- lib/ims/lti/tool_config.rb
|
100
105
|
- lib/ims/lti/tool_consumer.rb
|
101
106
|
- lib/ims/lti/tool_provider.rb
|
102
|
-
- lib/ims/lti.rb
|
103
|
-
- lib/ims.rb
|
104
|
-
- LICENSE
|
105
|
-
- README.md
|
106
|
-
- Changelog
|
107
107
|
homepage: http://github.com/instructure/ims-lti
|
108
108
|
licenses:
|
109
109
|
- MIT
|
@@ -114,17 +114,17 @@ require_paths:
|
|
114
114
|
- lib
|
115
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.2.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Ruby library for creating IMS LTI tool providers and consumers
|