diff --git a/lti_consumer/lti_xblock.py b/lti_consumer/lti_xblock.py index 1670555bf872962e716a993d5d1430af00ce3a31..726ab9c94a6c087286c94cc27160808d30fc9fcd 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 c6c56b2ad02404d9f936e8e9659f2102facf9cd3..ec1ec8c4246c425590e8dfe5e891308da4af810f 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 477ed52ad72037dc8e476fca8ca42ee3f5535f3e..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.4', + 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',