diff --git a/lti_consumer/lti_xblock.py b/lti_consumer/lti_xblock.py index 2c85e8cc17213b13057345f613596dcae2ae1eec..ea5d3fe49951a84339777a86d59fd1514ccc7698 100644 --- a/lti_consumer/lti_xblock.py +++ b/lti_consumer/lti_xblock.py @@ -1471,3 +1471,26 @@ class LtiConsumerXBlock(StudioEditableXBlockMixin, XBlock): 'lti_2_0_result_rest_handler': 'result_service_url' } return getattr(self, mapping[service_name]) + + def index_dictionary(self): + """ + Return dictionary prepared with module content and type for indexing. + """ + # return key/value fields in a Python dict object + # values may be numeric / string or dict + # default implementation is an empty dict + xblock_body = super(LtiConsumerXBlock, self).index_dictionary() + + index_body = { + "display_name": self.display_name, + "description": self.description, + } + + if "content" in xblock_body: + xblock_body["content"].update(index_body) + else: + xblock_body["content"] = index_body + + xblock_body["content_type"] = "LTI Consumer" + + return xblock_body diff --git a/lti_consumer/tests/unit/test_lti_xblock.py b/lti_consumer/tests/unit/test_lti_xblock.py index 4eca4990145ca335a5c81d315a01a9d67353bfe2..29124a9d79e977ae690c1517ec12ca0cc9ce1713 100644 --- a/lti_consumer/tests/unit/test_lti_xblock.py +++ b/lti_consumer/tests/unit/test_lti_xblock.py @@ -42,6 +42,32 @@ class TestLtiConsumerXBlock(TestCase): self.xblock = make_xblock('lti_consumer', LtiConsumerXBlock, self.xblock_attributes) +class TestIndexibility(TestCase): + """ + Test indexibility of Lti Consumer XBlock + """ + def setUp(self): + super(TestIndexibility, self).setUp() + self.xblock_attributes = { + 'launch_url': 'http://www.example.com', + 'display_name': 'Example LTI Consumer Application', + 'description': 'An example application to demonstrate LTI Consumer' + } + self.xblock = make_xblock('lti_consumer', LtiConsumerXBlock, self.xblock_attributes) + + def test_indexibility(self): + self.assertEqual( + self.xblock.index_dictionary(), + { + 'content_type': 'LTI Consumer', + 'content': { + 'display_name': 'Example LTI Consumer Application', + 'description': 'An example application to demonstrate LTI Consumer' + } + } + ) + + class TestProperties(TestLtiConsumerXBlock): """ Unit tests for LtiConsumerXBlock properties diff --git a/setup.py b/setup.py index 0940c91402f13e7c67730852b3599f13f1475fdb..74ec21a39624ee97191d27f3349cfc88860dfb76 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ with open('README.rst') as _f: setup( name='lti-consumer-xblock', - version='2.0.3', + version='2.1.0', description='This XBlock implements the consumer side of the LTI specification.', long_description=long_description, long_description_content_type='text/markdown',