ims-lti 1.1.8 → 1.1.9
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 +4 -4
- data/lib/ims/lti.rb +2 -0
- data/lib/ims/lti/deprecated_role_checks.rb +52 -0
- data/lib/ims/lti/launch_params.rb +7 -0
- data/lib/ims/lti/outcome_response.rb +4 -3
- data/lib/ims/lti/role_checks.rb +96 -0
- data/lib/ims/lti/tool_provider.rb +3 -46
- metadata +4 -4
- data/lib/ims/lti/services/service_definition.rb +0 -10
- data/lib/ims/lti/services/service_lookup.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60aadf51a888ea3b20d4e01db315fa516b2391d5
|
4
|
+
data.tar.gz: a2de5ab6dc06de39360cc798d1eb084390cde810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b81bc2d944853f4aea17886035dd9c157fa5f98de1b33f6e24f4bc0b515ab3504df6542bdafe7345153816b008ece1ac92cf40686bb672e4afcd1acc46fa90c
|
7
|
+
data.tar.gz: c57d082100c2493e07d7d5a426303a6f7ea541f4b57b303febba34513ada770d7d37e639b78f241b31ef4703f1a331c4d04274ae111ac811819432a9fc83d18c
|
data/lib/ims/lti.rb
CHANGED
@@ -56,6 +56,8 @@ require 'ims/lti/extensions'
|
|
56
56
|
require 'ims/lti/launch_params'
|
57
57
|
require 'ims/lti/request_validator'
|
58
58
|
require 'ims/lti/tool_base'
|
59
|
+
require 'ims/lti/deprecated_role_checks'
|
60
|
+
require 'ims/lti/role_checks'
|
59
61
|
require 'ims/lti/tool_provider'
|
60
62
|
require 'ims/lti/tool_consumer'
|
61
63
|
require 'ims/lti/outcome_request'
|
@@ -0,0 +1,52 @@
|
|
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.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
|
@@ -7,6 +7,12 @@ module IMS::LTI
|
|
7
7
|
|
8
8
|
# List of the standard launch parameters for an LTI launch
|
9
9
|
LAUNCH_DATA_PARAMETERS = %w{
|
10
|
+
accept_media_types
|
11
|
+
accept_multiple
|
12
|
+
accept_presentation_document_targets
|
13
|
+
accept_unsigned
|
14
|
+
auto_create
|
15
|
+
content_item_return_url
|
10
16
|
context_id
|
11
17
|
context_label
|
12
18
|
context_title
|
@@ -39,6 +45,7 @@ module IMS::LTI
|
|
39
45
|
resource_link_id
|
40
46
|
resource_link_title
|
41
47
|
roles
|
48
|
+
role_scope_mentor
|
42
49
|
tool_consumer_info_product_family_code
|
43
50
|
tool_consumer_info_version
|
44
51
|
tool_consumer_instance_contact_email
|
@@ -125,7 +125,6 @@ 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|
|
129
128
|
builder.imsx_POXEnvelopeResponse("xmlns" => "http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0") do |env|
|
130
129
|
env.imsx_POXHeader do |header|
|
131
130
|
header.imsx_POXResponseHeaderInfo do |info|
|
@@ -142,8 +141,8 @@ module IMS::LTI
|
|
142
141
|
end #/header
|
143
142
|
env.imsx_POXBody do |body|
|
144
143
|
unless unsupported?
|
145
|
-
|
146
|
-
|
144
|
+
if @operation == OutcomeRequest::READ_REQUEST
|
145
|
+
body.tag!(@operation + 'Response') do |request|
|
147
146
|
request.result do |res|
|
148
147
|
res.resultScore do |res_score|
|
149
148
|
res_score.language "en" # 'en' represents the format of the number
|
@@ -151,6 +150,8 @@ module IMS::LTI
|
|
151
150
|
end
|
152
151
|
end #/result
|
153
152
|
end
|
153
|
+
else
|
154
|
+
body.tag!(@operation + 'Response')
|
154
155
|
end #/operationResponse
|
155
156
|
end
|
156
157
|
end #/body
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module IMS::LTI
|
2
|
+
# Some convenience methods for the most used roles
|
3
|
+
# Take care when using context_ helpers, as the context of an LTI launch
|
4
|
+
# determines the meaning of that role. For example, if the context is an
|
5
|
+
# institution context instead of a course context, then the short role of
|
6
|
+
# "Instructor" means they are a teacher at the institution, but not necessarily
|
7
|
+
# of the course you're working in.
|
8
|
+
#
|
9
|
+
# Also note that these only check for the base roles. So, asking context_student?
|
10
|
+
# only matches `urn:lti:role:ims/lis/Learner`, not `urn:lti:role:ims/lis/Learner/NonCreditLearner`
|
11
|
+
# If you make use of the more specific roles you'll need to ask specifically for those:
|
12
|
+
# @tool_provider.has_exact_role?("urn:lti:role:ims/lis/Learner/NonCreditLearner")
|
13
|
+
# Or you can use `has_base_role?`
|
14
|
+
module RoleChecks
|
15
|
+
|
16
|
+
# Check whether the Launch Parameters have a given role
|
17
|
+
def has_exact_role?(role)
|
18
|
+
role = role.downcase
|
19
|
+
@roles && @roles.any? { |r| r == role }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Check whether the Launch Parameters have a given role ignoring
|
23
|
+
# sub roles. So asking:
|
24
|
+
# @tool_provider.has_base_role?("urn:lti:role:ims/lis/Instructor/")
|
25
|
+
# will return true if the role is `urn:lti:role:ims/lis/Instructor/GuestInstructor`
|
26
|
+
def has_base_role?(role)
|
27
|
+
role = role.downcase
|
28
|
+
@roles && @roles.any? { |r| r.start_with?(role) }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Convenience method for checking if the user is the system administrator of the TC
|
32
|
+
def system_administrator?
|
33
|
+
has_exact_role?('urn:lti:sysrole:ims/lis/SysAdmin') ||
|
34
|
+
has_exact_role?('SysAdmin') ||
|
35
|
+
has_exact_role?('urn:lti:sysrole:ims/lis/Administrator')
|
36
|
+
end
|
37
|
+
|
38
|
+
### Institution-level roles
|
39
|
+
# Note, these only check if the role is explicitely an institution level role
|
40
|
+
# if the context of the LTI launch is the institution, the short names
|
41
|
+
# will apply, and you should use the context_x? helpers.
|
42
|
+
|
43
|
+
# Convenience method for checking if the user has 'student' or 'learner' roles at the institution
|
44
|
+
def institution_student?
|
45
|
+
has_exact_role?('urn:lti:instrole:ims/lis/Student') || has_exact_role?('urn:lti:instrole:ims/lis/Learner')
|
46
|
+
end
|
47
|
+
|
48
|
+
# Convenience method for checking if the user has 'Instructor' role at the institution
|
49
|
+
def institution_instructor?
|
50
|
+
has_exact_role?('urn:lti:instrole:ims/lis/Instructor')
|
51
|
+
end
|
52
|
+
|
53
|
+
# Convenience method for checking if the user has 'Administrator' role at the institution
|
54
|
+
def institution_admin?
|
55
|
+
has_exact_role?('urn:lti:instrole:ims/lis/Administrator')
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
### Context-level roles
|
60
|
+
# Note, the most common LTI context is a course, but that is not always the
|
61
|
+
# case. You should be aware of the context when using these helpers.
|
62
|
+
# The difference for the context_ helpers is that they check for the
|
63
|
+
# short version of the roles. So `Learner` and `urn:lti:role:ims/lis/Learner`
|
64
|
+
# are both valid.
|
65
|
+
|
66
|
+
# Convenience method for checking if the user has 'learner' role in the current launch context
|
67
|
+
def context_student?
|
68
|
+
has_exact_role?('Learner') || has_exact_role?('urn:lti:role:ims/lis/Learner')
|
69
|
+
end
|
70
|
+
|
71
|
+
# Convenience method for checking if the user has 'instructor' role in the current launch context
|
72
|
+
def context_instructor?
|
73
|
+
has_exact_role?('instructor') || has_exact_role?('urn:lti:role:ims/lis/Instructor')
|
74
|
+
end
|
75
|
+
|
76
|
+
# Convenience method for checking if the user has 'contentdeveloper' role in the current launch context
|
77
|
+
def context_content_developer?
|
78
|
+
has_exact_role?('ContentDeveloper') || has_exact_role?('urn:lti:role:ims/lis/ContentDeveloper')
|
79
|
+
end
|
80
|
+
|
81
|
+
# Convenience method for checking if the user has 'Mentor' role in the current launch context
|
82
|
+
def context_mentor?
|
83
|
+
has_exact_role?('Mentor') || has_exact_role?('urn:lti:role:ims/lis/Mentor')
|
84
|
+
end
|
85
|
+
|
86
|
+
# Convenience method for checking if the user has 'administrator' role in the current launch context
|
87
|
+
def context_admin?
|
88
|
+
has_exact_role?('Administrator') || has_exact_role?('urn:lti:role:ims/lis/Administrator')
|
89
|
+
end
|
90
|
+
|
91
|
+
# Convenience method for checking if the user has 'TeachingAssistant' role in the current launch context
|
92
|
+
def context_ta?
|
93
|
+
has_exact_role?('TeachingAssistant') || has_exact_role?('urn:lti:role:ims/lis/TeachingAssistant')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -35,6 +35,9 @@ module IMS::LTI
|
|
35
35
|
|
36
36
|
class ToolProvider < ToolBase
|
37
37
|
# List of outcome requests made through this instance
|
38
|
+
|
39
|
+
include DeprecatedRoleChecks
|
40
|
+
include RoleChecks
|
38
41
|
attr_accessor :outcome_requests
|
39
42
|
# Message to be sent back to the ToolConsumer when the user returns
|
40
43
|
attr_accessor :lti_errormsg, :lti_errorlog, :lti_msg, :lti_log
|
@@ -49,52 +52,6 @@ module IMS::LTI
|
|
49
52
|
@outcome_requests = []
|
50
53
|
end
|
51
54
|
|
52
|
-
# Check whether the Launch Parameters have a role
|
53
|
-
def has_role?(role)
|
54
|
-
role = role.downcase
|
55
|
-
@roles && @roles.any?{|r| r.index(role)}
|
56
|
-
end
|
57
|
-
|
58
|
-
# Convenience method for checking if the user has 'learner' or 'student' role
|
59
|
-
def student?
|
60
|
-
has_role?('learner') || has_role?('student')
|
61
|
-
end
|
62
|
-
|
63
|
-
# Convenience method for checking if the user has 'instructor' or 'faculty' or 'staff' role
|
64
|
-
def instructor?
|
65
|
-
has_role?('instructor') || has_role?('faculty') || has_role?('staff')
|
66
|
-
end
|
67
|
-
|
68
|
-
# Convenience method for checking if the user has 'contentdeveloper' role
|
69
|
-
def content_developer?
|
70
|
-
has_role?('ContentDeveloper')
|
71
|
-
end
|
72
|
-
|
73
|
-
# Convenience method for checking if the user has 'Member' role
|
74
|
-
def member?
|
75
|
-
has_role?('Member')
|
76
|
-
end
|
77
|
-
|
78
|
-
# Convenience method for checking if the user has 'Manager' role
|
79
|
-
def manager?
|
80
|
-
has_role?('Manager')
|
81
|
-
end
|
82
|
-
|
83
|
-
# Convenience method for checking if the user has 'Mentor' role
|
84
|
-
def mentor?
|
85
|
-
has_role?('Mentor')
|
86
|
-
end
|
87
|
-
|
88
|
-
# Convenience method for checking if the user has 'administrator' role
|
89
|
-
def admin?
|
90
|
-
has_role?('administrator')
|
91
|
-
end
|
92
|
-
|
93
|
-
# Convenience method for checking if the user has 'TeachingAssistant' role
|
94
|
-
def ta?
|
95
|
-
has_role?('TeachingAssistant')
|
96
|
-
end
|
97
|
-
|
98
55
|
# Check if the request was an LTI Launch Request
|
99
56
|
def launch_request?
|
100
57
|
lti_message_type == 'basic-lti-launch-request'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- README.md
|
79
79
|
- lib/ims.rb
|
80
80
|
- lib/ims/lti.rb
|
81
|
+
- lib/ims/lti/deprecated_role_checks.rb
|
81
82
|
- lib/ims/lti/extensions.rb
|
82
83
|
- lib/ims/lti/extensions/canvas.rb
|
83
84
|
- lib/ims/lti/extensions/content.rb
|
@@ -86,8 +87,7 @@ files:
|
|
86
87
|
- lib/ims/lti/outcome_request.rb
|
87
88
|
- lib/ims/lti/outcome_response.rb
|
88
89
|
- lib/ims/lti/request_validator.rb
|
89
|
-
- lib/ims/lti/
|
90
|
-
- lib/ims/lti/services/service_lookup.rb
|
90
|
+
- lib/ims/lti/role_checks.rb
|
91
91
|
- lib/ims/lti/tool_base.rb
|
92
92
|
- lib/ims/lti/tool_config.rb
|
93
93
|
- lib/ims/lti/tool_consumer.rb
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.4.5
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Ruby library for creating IMS LTI tool providers and consumers
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class ServiceLookup
|
2
|
-
|
3
|
-
TOOL_SETTING_SERVICE = ServiceDefinition.new(
|
4
|
-
'ToolSettingsContainer Service',
|
5
|
-
%w(application/vnd.ims.lti.v2.toolsettings+json application/vnd.ims.lti.v2.toolsettings.simple+json),
|
6
|
-
%w(LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url)
|
7
|
-
)
|
8
|
-
|
9
|
-
TOOL_CONSUMER_PROFILE_SERVICE = ServiceDefinition.new(
|
10
|
-
'ToolConsumerProfile Service',
|
11
|
-
%w(application/vnd.ims.lti.v2.toolconsumerprofile+json),
|
12
|
-
[]
|
13
|
-
)
|
14
|
-
|
15
|
-
TOOL_PROXY_SERVICE = ServiceDefinition.new(
|
16
|
-
'ToolProxy Service',
|
17
|
-
%w(application/vnd.ims.lti.v2.toolproxy+json),
|
18
|
-
[]
|
19
|
-
)
|
20
|
-
|
21
|
-
def self.services
|
22
|
-
[TOOL_SETTING_SERVICE, TOOL_CONSUMER_PROFILE_SERVICE, TOOL_PROXY_SERVICE]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.lookup(format)
|
26
|
-
services.select { |service| service.formats.include? format }
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
end
|