From 68409f0c7afadba6a2a6646d4d408b9fab9a709c Mon Sep 17 00:00:00 2001 From: Alexander Kryklia <kryklia@gmail.com> Date: Wed, 11 Sep 2013 19:16:46 +0300 Subject: [PATCH] Add default launch url for lti. --- common/lib/xmodule/xmodule/js/src/lti/lti.js | 4 ++-- common/lib/xmodule/xmodule/lti_module.py | 6 ++++-- lms/djangoapps/courseware/tests/test_lti.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/lti/lti.js b/common/lib/xmodule/xmodule/js/src/lti/lti.js index e5b6885e1bb..7d5b183f216 100644 --- a/common/lib/xmodule/xmodule/js/src/lti/lti.js +++ b/common/lib/xmodule/xmodule/js/src/lti/lti.js @@ -16,9 +16,9 @@ window.LTI = (function () { // If the Form's action attribute is set (i.e. we can perform a normal // submit), then we submit the form and make the frame shown. - if (form.attr('action')) { + if (form.attr('action') && form.attr('action') !== 'http://www.example.com') { form.submit(); - element.find('.lti').addClass('rendered') + element.find('.lti').addClass('rendered'); } } diff --git a/common/lib/xmodule/xmodule/lti_module.py b/common/lib/xmodule/xmodule/lti_module.py index 939190840ae..0144071a190 100644 --- a/common/lib/xmodule/xmodule/lti_module.py +++ b/common/lib/xmodule/xmodule/lti_module.py @@ -38,9 +38,12 @@ class LTIFields(object): vbid=put_book_id_here book_location=page/put_page_number_here + Default non-empty url for `launch_url` is needed due to oauthlib demand (url scheme should be presented):: + + https://github.com/idan/oauthlib/blob/master/oauthlib/oauth1/rfc5849/signature.py#L136 """ lti_id = String(help="Id of the tool", default='', scope=Scope.settings) - launch_url = String(help="URL of the tool", default='', scope=Scope.settings) + launch_url = String(help="URL of the tool", default='http://www.example.com', scope=Scope.settings) custom_parameters = List(help="Custom parameters (vbid, book_location, etc..)", scope=Scope.settings) @@ -213,7 +216,6 @@ class LTIModule(LTIFields, XModule): body.update(custom_parameters) headers = { - 'Host': self.system.HOSTNAME, # This is needed for body encoding: 'Content-Type': 'application/x-www-form-urlencoded', } diff --git a/lms/djangoapps/courseware/tests/test_lti.py b/lms/djangoapps/courseware/tests/test_lti.py index 71b5a1c3bb9..596ec2dd9a1 100644 --- a/lms/djangoapps/courseware/tests/test_lti.py +++ b/lms/djangoapps/courseware/tests/test_lti.py @@ -75,6 +75,6 @@ class TestLTI(BaseTestXmodule): 'input_fields': self.correct_headers, 'element_class': self.item_module.location.category, 'element_id': self.item_module.location.html_id(), - 'launch_url': '', # default value + 'launch_url': 'http://www.example.com', # default value } self.assertDictEqual(generated_context, expected_context) -- GitLab