Commit d66e6cbc by Oleg Marshev

Merge pull request #3052 from edx/oleg/add-context-id

LTI context_id. BLD-584.
parents be4e9cb5 8a202424
......@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.
Blades: Add LTI context_id parameter. BLD-584.
Blades: Update LTI resource_link_id parameter. BLD-768.
Blades: Transcript translations should be displayed in their source language (BLD-935).
......
......@@ -28,6 +28,7 @@
<input name="oauth_signature" value="89ru3289r3ry283y3r82ryr38yr" />
<input name="lti_message_type" value="basic-lti-launch-request" />
<input name="oauth_callback" value="about:blank" />
<input name="context_id" value="testorg/testcoursename/2014" />
<input type="submit" value="Press to Launch" />
</form>
......
......@@ -338,13 +338,9 @@ class LTIModule(LTIFields, XModule):
This value may change for a particular resource_link_id / user_id from one launch to the next.
The TP should only retain the most recent value for this field for a particular resource_link_id / user_id.
This field is generally optional, but is required for grading.
context_id is - is an opaque identifier that uniquely identifies the context that contains
the link being launched.
lti_id should be context_id by meaning.
"""
return "{id}:{resource_link}:{user_id}".format(
id=urllib.quote(self.lti_id),
return "{context}:{resource_link}:{user_id}".format(
context=urllib.quote(self.context_id),
resource_link=urllib.quote(self.get_resource_link_id()),
user_id=urllib.quote(self.get_user_id())
)
......@@ -358,6 +354,16 @@ class LTIModule(LTIFields, XModule):
return course
@property
def context_id(self):
"""
Return context_id.
context_id is an opaque identifier that uniquely identifies the context (e.g., a course)
that contains the link being launched.
"""
return self.course_id
@property
def role(self):
"""
Get system user role and convert it to LTI role.
......@@ -397,6 +403,7 @@ class LTIModule(LTIFields, XModule):
u'resource_link_id': self.get_resource_link_id(),
u'lis_result_sourcedid': self.get_lis_result_sourcedid(),
u'context_id': self.context_id,
}
if self.has_score:
......
......@@ -131,7 +131,7 @@ class LogicTest(unittest.TestCase):
url_name = ''
category = 'test'
self.system = get_test_system()
self.system = get_test_system(course_id='test/course/id')
self.descriptor = EmptyClass()
self.xmodule_class = self.descriptor_class.module_class
......
......@@ -265,7 +265,7 @@ class LTIModuleTest(LogicTest):
with patch('xmodule.lti_module.LTIModule.location', new_callable=PropertyMock) as mock_location:
self.xmodule.location.html_id = lambda: 'i4x-2-3-lti-31de800015cf4afb973356dbe81496df'
expected_sourcedId = u':'.join(urllib.quote(i) for i in (
self.lti_id,
self.system.course_id,
urllib.quote(self.unquoted_resource_link_id),
self.user_id
))
......@@ -407,4 +407,8 @@ class LTIModuleTest(LogicTest):
self.xmodule.graded = False
self.assertEqual(self.xmodule.max_score(), 100.0)
def test_context_id(self):
"""
Tests that LTI parameter context_id is equal to course_id.
"""
self.assertEqual(self.system.course_id, self.xmodule.context_id)
......@@ -27,13 +27,13 @@ class TestLTI(BaseTestXmodule):
mocked_signature_after_sign = u'my_signature%3D'
mocked_decoded_signature = u'my_signature='
lti_id = self.item_descriptor.lti_id
context_id = self.item_descriptor.course_id
user_id = unicode(self.item_descriptor.xmodule_runtime.anonymous_student_id)
hostname = self.item_descriptor.xmodule_runtime.hostname
resource_link_id = unicode(urllib.quote('{}-{}'.format(hostname, self.item_descriptor.location.html_id())))
sourcedId = "{id}:{resource_link}:{user_id}".format(
id=urllib.quote(lti_id),
sourcedId = "{context}:{resource_link}:{user_id}".format(
context=urllib.quote(context_id),
resource_link=urllib.quote(resource_link_id),
user_id=urllib.quote(user_id)
)
......@@ -49,6 +49,7 @@ class TestLTI(BaseTestXmodule):
u'lti_message_type': u'basic-lti-launch-request',
u'lti_version': 'LTI-1p0',
u'roles': u'Student',
u'context_id': context_id,
u'resource_link_id': resource_link_id,
u'lis_result_sourcedid': sourcedId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment