@@ -108,116 +108,26 @@ def noop(text):
108
108
109
109
_ = noop
110
110
111
- @XBlock .needs ("i18n" )
112
- @XBlock .needs ("user" )
113
- @XBlock .needs ("rebind_user" )
114
- class LTIBlock (
115
- LTI20BlockMixin ,
116
- StudioEditableXBlockMixin ,
117
- XBlock ,
118
- ): # pylint: disable=abstract-method
111
+ class LTIFields :
119
112
"""
120
- THIS MODULE IS DEPRECATED IN FAVOR OF https://github.com/openedx/xblock-lti-consumer
121
-
122
- Module provides LTI integration to course.
123
-
124
- Except usual Xmodule structure it proceeds with OAuth signing.
125
- How it works::
126
-
127
- 1. Get credentials from course settings.
128
-
129
- 2. There is minimal set of parameters need to be signed (presented for Vitalsource)::
130
-
131
- user_id
132
- oauth_callback
133
- lis_outcome_service_url
134
- lis_result_sourcedid
135
- launch_presentation_return_url
136
- lti_message_type
137
- lti_version
138
- roles
139
- *+ all custom parameters*
140
-
141
- These parameters should be encoded and signed by *OAuth1* together with
142
- `launch_url` and *POST* request type.
143
-
144
- 3. Signing proceeds with client key/secret pair obtained from course settings.
145
- That pair should be obtained from LTI provider and set into course settings by course author.
146
- After that signature and other OAuth data are generated.
147
-
148
- OAuth data which is generated after signing is usual::
149
-
150
- oauth_callback
151
- oauth_nonce
152
- oauth_consumer_key
153
- oauth_signature_method
154
- oauth_timestamp
155
- oauth_version
156
-
157
-
158
- 4. All that data is passed to form and sent to LTI provider server by browser via
159
- autosubmit via JavaScript.
113
+ Fields to define and obtain LTI tool from provider are set here,
114
+ except credentials, which should be set in course settings::
160
115
161
- Form example::
116
+ `lti_id` is id to connect tool with credentials in course settings. It should not contain :: (double semicolon)
117
+ `launch_url` is launch URL of tool.
118
+ `custom_parameters` are additional parameters to navigate to proper book and book page.
162
119
163
- <form
164
- action="${launch_url}"
165
- name="ltiLaunchForm-${element_id}"
166
- class="ltiLaunchForm"
167
- method="post"
168
- target="ltiLaunchFrame-${element_id}"
169
- encType="application/x-www-form-urlencoded"
170
- >
171
- <input name="launch_presentation_return_url" value="" />
172
- <input name="lis_outcome_service_url" value="" />
173
- <input name="lis_result_sourcedid" value="" />
174
- <input name="lti_message_type" value="basic-lti-launch-request" />
175
- <input name="lti_version" value="LTI-1p0" />
176
- <input name="oauth_callback" value="about:blank" />
177
- <input name="oauth_consumer_key" value="${oauth_consumer_key}" />
178
- <input name="oauth_nonce" value="${oauth_nonce}" />
179
- <input name="oauth_signature_method" value="HMAC-SHA1" />
180
- <input name="oauth_timestamp" value="${oauth_timestamp}" />
181
- <input name="oauth_version" value="1.0" />
182
- <input name="user_id" value="${user_id}" />
183
- <input name="role" value="student" />
184
- <input name="oauth_signature" value="${oauth_signature}" />
120
+ For example, for Vitalsource provider, `launch_url` should be
121
+ *https://bc-staging.vitalsource.com/books/book*,
122
+ and to get to proper book and book page, you should set custom parameters as::
185
123
186
- <input name="custom_1" value="${custom_param_1_value}" />
187
- <input name="custom_2" value="${custom_param_2_value}" />
188
- <input name="custom_..." value="${custom_param_..._value}" />
189
-
190
- <input type="submit" value="Press to Launch" />
191
- </form>
124
+ vbid=put_book_id_here
125
+ book_location=page/put_page_number_here
192
126
193
- 5. LTI provider has same secret key and it signs data string via *OAuth1* and compares signatures.
194
-
195
- If signatures are correct, LTI provider redirects iframe source to LTI tool web page,
196
- and LTI tool is rendered to iframe inside course.
127
+ Default non-empty URL for `launch_url` is needed due to oauthlib demand (URL scheme should be presented)::
197
128
198
- Otherwise error message from LTI provider is generated.
129
+ https://github.com/idan/oauthlib/blob/master/oauthlib/oauth1/rfc5849/signature.py#L136
199
130
"""
200
-
201
- # Indicates that this XBlock has been extracted from edx-platform.
202
- is_extracted = True
203
-
204
- ######################################
205
- # LTI FIELDS #
206
- ######################################
207
- # `lti_id` is id to connect tool with credentials in course settings. It should not contain :: (double semicolon)
208
- # `launch_url` is launch URL of tool.
209
- # `custom_parameters` are additional parameters to navigate to proper book and book page.
210
-
211
- # For example, for Vitalsource provider, `launch_url` should be
212
- # *https://bc-staging.vitalsource.com/books/book*,
213
- # and to get to proper book and book page, you should set custom parameters as::
214
-
215
- # vbid=put_book_id_here
216
- # book_location=page/put_page_number_here
217
-
218
- # Default non-empty URL for `launch_url` is needed due to oauthlib demand (URL scheme should be presented)::
219
-
220
- # https://github.com/idan/oauthlib/blob/master/oauthlib/oauth1/rfc5849/signature.py#L136
221
131
display_name = String (
222
132
display_name = _ ("Display Name" ),
223
133
help = _ (
@@ -256,7 +166,8 @@ class LTIBlock(
256
166
anchor_close = markupsafe .Markup ("</a>" )
257
167
),
258
168
default = 'http://www.example.com' ,
259
- scope = Scope .settings )
169
+ scope = Scope .settings
170
+ )
260
171
261
172
custom_parameters = List (
262
173
display_name = _ ("Custom Parameters" ),
@@ -269,7 +180,8 @@ class LTIBlock(
269
180
docs_anchor_open = markupsafe .Markup (DOCS_ANCHOR_TAG_OPEN ),
270
181
anchor_close = markupsafe .Markup ("</a>" )
271
182
),
272
- scope = Scope .settings )
183
+ scope = Scope .settings
184
+ )
273
185
274
186
open_in_a_new_page = Boolean (
275
187
display_name = _ ("Open in New Page" ),
@@ -376,6 +288,101 @@ class LTIBlock(
376
288
"launch_url" , "lti_id" , "open_in_a_new_page" , "weight" ,
377
289
)
378
290
291
+
292
+ @XBlock .needs ("i18n" )
293
+ @XBlock .needs ("user" )
294
+ @XBlock .needs ("rebind_user" )
295
+ class LTIBlock (
296
+ LTIFields ,
297
+ LTI20BlockMixin ,
298
+ StudioEditableXBlockMixin ,
299
+ XBlock ,
300
+ ): # pylint: disable=abstract-method
301
+ """
302
+ THIS MODULE IS DEPRECATED IN FAVOR OF https://github.com/openedx/xblock-lti-consumer
303
+
304
+ Module provides LTI integration to course.
305
+
306
+ Except usual Xmodule structure it proceeds with OAuth signing.
307
+ How it works::
308
+
309
+ 1. Get credentials from course settings.
310
+
311
+ 2. There is minimal set of parameters need to be signed (presented for Vitalsource)::
312
+
313
+ user_id
314
+ oauth_callback
315
+ lis_outcome_service_url
316
+ lis_result_sourcedid
317
+ launch_presentation_return_url
318
+ lti_message_type
319
+ lti_version
320
+ roles
321
+ *+ all custom parameters*
322
+
323
+ These parameters should be encoded and signed by *OAuth1* together with
324
+ `launch_url` and *POST* request type.
325
+
326
+ 3. Signing proceeds with client key/secret pair obtained from course settings.
327
+ That pair should be obtained from LTI provider and set into course settings by course author.
328
+ After that signature and other OAuth data are generated.
329
+
330
+ OAuth data which is generated after signing is usual::
331
+
332
+ oauth_callback
333
+ oauth_nonce
334
+ oauth_consumer_key
335
+ oauth_signature_method
336
+ oauth_timestamp
337
+ oauth_version
338
+
339
+
340
+ 4. All that data is passed to form and sent to LTI provider server by browser via
341
+ autosubmit via JavaScript.
342
+
343
+ Form example::
344
+
345
+ <form
346
+ action="${launch_url}"
347
+ name="ltiLaunchForm-${element_id}"
348
+ class="ltiLaunchForm"
349
+ method="post"
350
+ target="ltiLaunchFrame-${element_id}"
351
+ encType="application/x-www-form-urlencoded"
352
+ >
353
+ <input name="launch_presentation_return_url" value="" />
354
+ <input name="lis_outcome_service_url" value="" />
355
+ <input name="lis_result_sourcedid" value="" />
356
+ <input name="lti_message_type" value="basic-lti-launch-request" />
357
+ <input name="lti_version" value="LTI-1p0" />
358
+ <input name="oauth_callback" value="about:blank" />
359
+ <input name="oauth_consumer_key" value="${oauth_consumer_key}" />
360
+ <input name="oauth_nonce" value="${oauth_nonce}" />
361
+ <input name="oauth_signature_method" value="HMAC-SHA1" />
362
+ <input name="oauth_timestamp" value="${oauth_timestamp}" />
363
+ <input name="oauth_version" value="1.0" />
364
+ <input name="user_id" value="${user_id}" />
365
+ <input name="role" value="student" />
366
+ <input name="oauth_signature" value="${oauth_signature}" />
367
+
368
+ <input name="custom_1" value="${custom_param_1_value}" />
369
+ <input name="custom_2" value="${custom_param_2_value}" />
370
+ <input name="custom_..." value="${custom_param_..._value}" />
371
+
372
+ <input type="submit" value="Press to Launch" />
373
+ </form>
374
+
375
+ 5. LTI provider has same secret key and it signs data string via *OAuth1* and compares signatures.
376
+
377
+ If signatures are correct, LTI provider redirects iframe source to LTI tool web page,
378
+ and LTI tool is rendered to iframe inside course.
379
+
380
+ Otherwise error message from LTI provider is generated.
381
+ """
382
+
383
+ # Indicates that this XBlock has been extracted from edx-platform.
384
+ is_extracted = True
385
+
379
386
@property
380
387
def location (self ):
381
388
return self .scope_ids .usage_id
0 commit comments