ims-lti 1.1.12 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  2. data/Changelog.txt +0 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +35 -86
  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/errors/authentication_failed_error.rb +11 -0
  19. data/lib/ims/lti/errors/invalid_lti_config_error.rb +4 -0
  20. data/lib/ims/lti/errors/invalid_tool_consumer_profile.rb +4 -0
  21. data/lib/ims/lti/errors/tool_proxy_registration_error.rb +15 -0
  22. data/lib/ims/lti/errors.rb +8 -0
  23. data/lib/ims/lti/models/base_url_choice.rb +15 -0
  24. data/lib/ims/lti/models/base_url_selector.rb +5 -0
  25. data/lib/ims/lti/models/contact.rb +5 -0
  26. data/lib/ims/lti/models/content_item_container.rb +14 -0
  27. data/lib/ims/lti/models/content_item_placement.rb +20 -0
  28. data/lib/ims/lti/models/content_items/content_item.rb +32 -0
  29. data/lib/ims/lti/models/content_items/file_item.rb +15 -0
  30. data/lib/ims/lti/models/content_items/lti_link_item.rb +14 -0
  31. data/lib/ims/lti/models/content_items.rb +7 -0
  32. data/lib/ims/lti/models/icon_endpoint.rb +5 -0
  33. data/lib/ims/lti/models/icon_info.rb +6 -0
  34. data/lib/ims/lti/models/image.rb +7 -0
  35. data/lib/ims/lti/models/localized_name.rb +12 -0
  36. data/lib/ims/lti/models/localized_text.rb +12 -0
  37. data/lib/ims/lti/models/lti_model.rb +227 -0
  38. data/lib/ims/lti/models/membership_service/agent.rb +11 -0
  39. data/lib/ims/lti/models/membership_service/container.rb +11 -0
  40. data/lib/ims/lti/models/membership_service/context.rb +11 -0
  41. data/lib/ims/lti/models/membership_service/lis_membership_container.rb +13 -0
  42. data/lib/ims/lti/models/membership_service/lis_person.rb +14 -0
  43. data/lib/ims/lti/models/membership_service/membership.rb +14 -0
  44. data/lib/ims/lti/models/membership_service/organization.rb +14 -0
  45. data/lib/ims/lti/models/membership_service/page.rb +16 -0
  46. data/lib/ims/lti/models/membership_service/person.rb +13 -0
  47. data/lib/ims/lti/models/membership_service.rb +16 -0
  48. data/lib/ims/lti/models/message_handler.rb +14 -0
  49. data/lib/ims/lti/models/messages/basic_lti_launch_request.rb +24 -0
  50. data/lib/ims/lti/models/messages/content_item_selection.rb +32 -0
  51. data/lib/ims/lti/models/messages/content_item_selection_request.rb +26 -0
  52. data/lib/ims/lti/models/messages/message.rb +239 -0
  53. data/lib/ims/lti/models/messages/registration_request.rb +20 -0
  54. data/lib/ims/lti/models/messages/request_message.rb +12 -0
  55. data/lib/ims/lti/models/messages/tool_proxy_update_request.rb +15 -0
  56. data/lib/ims/lti/models/messages.rb +11 -0
  57. data/lib/ims/lti/models/parameter.rb +28 -0
  58. data/lib/ims/lti/models/product_family.rb +8 -0
  59. data/lib/ims/lti/models/product_info.rb +26 -0
  60. data/lib/ims/lti/models/product_instance.rb +10 -0
  61. data/lib/ims/lti/models/resource_handler.rb +22 -0
  62. data/lib/ims/lti/models/resource_type.rb +6 -0
  63. data/lib/ims/lti/models/rest_service.rb +30 -0
  64. data/lib/ims/lti/models/rest_service_profile.rb +15 -0
  65. data/lib/ims/lti/models/security_contract.rb +21 -0
  66. data/lib/ims/lti/models/security_profile.rb +10 -0
  67. data/lib/ims/lti/models/serializable.rb +12 -0
  68. data/lib/ims/lti/models/service_owner.rb +26 -0
  69. data/lib/ims/lti/models/service_provider.rb +11 -0
  70. data/lib/ims/lti/models/tool_consumer_profile.rb +45 -0
  71. data/lib/ims/lti/models/tool_profile.rb +35 -0
  72. data/lib/ims/lti/models/tool_proxy.rb +21 -0
  73. data/lib/ims/lti/models/tool_setting.rb +12 -0
  74. data/lib/ims/lti/models/tool_setting_container.rb +14 -0
  75. data/lib/ims/lti/models/vendor.rb +28 -0
  76. data/lib/ims/lti/models.rb +38 -0
  77. data/lib/ims/lti/serializers/base.rb +125 -0
  78. data/lib/ims/lti/serializers/membership_service/agent_serializer.rb +5 -0
  79. data/lib/ims/lti/serializers/membership_service/container_serializer.rb +6 -0
  80. data/lib/ims/lti/serializers/membership_service/context_serializer.rb +9 -0
  81. data/lib/ims/lti/serializers/membership_service/lis_membership_container_serializer.rb +9 -0
  82. data/lib/ims/lti/serializers/membership_service/lis_person_serializer.rb +12 -0
  83. data/lib/ims/lti/serializers/membership_service/membership_serializer.rb +7 -0
  84. data/lib/ims/lti/serializers/membership_service/organization_serializer.rb +8 -0
  85. data/lib/ims/lti/serializers/membership_service/page_serializer.rb +10 -0
  86. data/lib/ims/lti/serializers/membership_service/person_serializer.rb +8 -0
  87. data/lib/ims/lti/serializers/membership_service.rb +13 -0
  88. data/lib/ims/lti/serializers.rb +6 -0
  89. data/lib/ims/lti/services/authentication_service.rb +67 -0
  90. data/lib/ims/lti/services/message_authenticator.rb +80 -0
  91. data/lib/ims/lti/services/oauth2_client.rb +22 -0
  92. data/lib/ims/lti/{tool_config.rb → services/tool_config.rb} +26 -34
  93. data/lib/ims/lti/services/tool_consumer_profile_service.rb +16 -0
  94. data/lib/ims/lti/services/tool_proxy_registration_service.rb +84 -0
  95. data/lib/ims/lti/services/tool_proxy_validator.rb +182 -0
  96. data/lib/ims/lti/services.rb +11 -0
  97. data/lib/ims/lti/version.rb +5 -0
  98. data/lib/ims/lti.rb +13 -60
  99. data/lib/ims.rb +4 -1
  100. metadata +245 -37
  101. data/Changelog +0 -44
  102. data/LICENSE +0 -18
  103. data/lib/ims/lti/deprecated_role_checks.rb +0 -52
  104. data/lib/ims/lti/extensions/canvas.rb +0 -122
  105. data/lib/ims/lti/extensions/content.rb +0 -209
  106. data/lib/ims/lti/extensions/outcome_data.rb +0 -199
  107. data/lib/ims/lti/extensions.rb +0 -45
  108. data/lib/ims/lti/launch_params.rb +0 -166
  109. data/lib/ims/lti/outcome_request.rb +0 -206
  110. data/lib/ims/lti/outcome_response.rb +0 -162
  111. data/lib/ims/lti/request_validator.rb +0 -50
  112. data/lib/ims/lti/role_checks.rb +0 -101
  113. data/lib/ims/lti/tool_base.rb +0 -29
  114. data/lib/ims/lti/tool_consumer.rb +0 -86
  115. data/lib/ims/lti/tool_provider.rb +0 -143
@@ -1,143 +0,0 @@
1
- module IMS::LTI
2
-
3
- # Class for implementing an LTI Tool Provider
4
- #
5
- # # Initialize TP object with OAuth creds and post parameters
6
- # provider = IMS::LTI::ToolProvider.new(consumer_key, consumer_secret, params)
7
- #
8
- # # Verify OAuth signature by passing the request object
9
- # if provider.valid_request?(request)
10
- # # success
11
- # else
12
- # # handle invalid OAuth
13
- # end
14
- #
15
- # if provider.outcome_service?
16
- # # ready for grade write-back
17
- # else
18
- # # normal tool launch without grade write-back
19
- # end
20
- #
21
- # If the tool was launch as an outcome service you can POST a score to the TC.
22
- # The POST calls all return an OutcomeResponse object which can be used to
23
- # handle the response appropriately.
24
- #
25
- # # post the score to the TC, score should be a float >= 0.0 and <= 1.0
26
- # # this returns an OutcomeResponse object
27
- # response = provider.post_replace_result!(score)
28
- # if response.success?
29
- # # grade write worked
30
- # elsif response.processing?
31
- # elsif response.unsupported?
32
- # else
33
- # # failed
34
- # end
35
-
36
- class ToolProvider < ToolBase
37
- # List of outcome requests made through this instance
38
-
39
- include DeprecatedRoleChecks
40
- include RoleChecks
41
- attr_accessor :outcome_requests
42
- # Message to be sent back to the ToolConsumer when the user returns
43
- attr_accessor :lti_errormsg, :lti_errorlog, :lti_msg, :lti_log
44
-
45
- # Create a new ToolProvider
46
- #
47
- # @param consumer_key [String] The OAuth consumer key
48
- # @param consumer_secret [String] The OAuth consumer secret
49
- # @param params [Hash] Set the launch parameters as described in LaunchParams
50
- def initialize(consumer_key, consumer_secret, params={})
51
- super(consumer_key, consumer_secret, params)
52
- @outcome_requests = []
53
- end
54
-
55
- # Check if the request was an LTI Launch Request
56
- def launch_request?
57
- lti_message_type == 'basic-lti-launch-request'
58
- end
59
-
60
- # Check if the Tool Launch expects an Outcome Result
61
- def outcome_service?
62
- !!(lis_outcome_service_url && lis_result_sourcedid)
63
- end
64
-
65
- # Return the full, given, or family name if set
66
- def username(default=nil)
67
- lis_person_name_given || lis_person_name_family || lis_person_name_full || default
68
- end
69
-
70
- # POSTs the given score to the Tool Consumer with a replaceResult
71
- #
72
- # Creates a new OutcomeRequest object and stores it in @outcome_requests
73
- #
74
- # @return [OutcomeResponse] the response from the Tool Consumer
75
- def post_replace_result!(score)
76
- new_request.post_replace_result!(score)
77
- end
78
-
79
- # POSTs a delete request to the Tool Consumer
80
- #
81
- # Creates a new OutcomeRequest object and stores it in @outcome_requests
82
- #
83
- # @return [OutcomeResponse] the response from the Tool Consumer
84
- def post_delete_result!
85
- new_request.post_delete_result!
86
- end
87
-
88
- # POSTs the given score to the Tool Consumer with a replaceResult, the
89
- # returned OutcomeResponse will have the score
90
- #
91
- # Creates a new OutcomeRequest object and stores it in @outcome_requests
92
- #
93
- # @return [OutcomeResponse] the response from the Tool Consumer
94
- def post_read_result!
95
- new_request.post_read_result!
96
- end
97
-
98
- # Returns the most recent OutcomeRequest
99
- def last_outcome_request
100
- @outcome_requests.last
101
- end
102
-
103
- # Convenience method for whether the last OutcomeRequest was successful
104
- def last_outcome_success?
105
- last_outcome_request && last_outcome_request.outcome_post_successful?
106
- end
107
-
108
- # If the Tool Consumer sent a URL for the user to return to this will add
109
- # any set messages to the URL.
110
- #
111
- # Example:
112
- #
113
- # tc = IMS::LTI::tc.new
114
- # tc.launch_presentation_return_url = "http://example.com/return"
115
- # tc.lti_msg = "hi there"
116
- # tc.lti_errorlog = "error happens"
117
- #
118
- # tc.build_return_url # => "http://example.com/return?lti_msg=hi%20there&lti_errorlog=error%20happens"
119
- def build_return_url
120
- return nil unless launch_presentation_return_url
121
- messages = []
122
- %w{lti_errormsg lti_errorlog lti_msg lti_log}.each do |m|
123
- if message = self.send(m)
124
- messages << "#{m}=#{URI.escape(message)}"
125
- end
126
- end
127
- q_string = messages.any? ? ("?" + messages.join("&")) : ''
128
- launch_presentation_return_url + q_string
129
- end
130
-
131
- private
132
-
133
- def new_request
134
- @outcome_requests << OutcomeRequest.new(:consumer_key => @consumer_key,
135
- :consumer_secret => @consumer_secret,
136
- :lis_outcome_service_url => lis_outcome_service_url,
137
- :lis_result_sourcedid =>lis_result_sourcedid)
138
-
139
- extend_outcome_request(@outcome_requests.last)
140
- end
141
-
142
- end
143
- end