diff --git a/lti_consumer/lti.py b/lti_consumer/lti.py index 83bcd799f94bb5b399bf353d032dcacba158ee6a..8ba30e40909ee11d3e6f4bcbfff6618cd3f645ae 100644 --- a/lti_consumer/lti.py +++ b/lti_consumer/lti.py @@ -128,8 +128,14 @@ class LtiConsumer(object): u'lis_result_sourcedid': self.xblock.lis_result_sourcedid, u'context_id': self.xblock.context_id, + u'custom_component_display_name': self.xblock.display_name, } + if self.xblock.due: + lti_parameters['custom_component_due_date'] = self.xblock.due.strftime('%Y-%m-%d %H:%M:%S') + if self.xblock.graceperiod: + lti_parameters['custom_component_graceperiod'] = str(self.xblock.graceperiod.total_seconds()) + if self.xblock.has_score: lti_parameters.update({ u'lis_outcome_service_url': self.xblock.outcome_service_url diff --git a/lti_consumer/lti_consumer.py b/lti_consumer/lti_consumer.py index e2b6dfa77508605133631f771f40b7caa0160b6e..2f769d08c003ed4087b417dfe8348324860fe9ee 100644 --- a/lti_consumer/lti_consumer.py +++ b/lti_consumer/lti_consumer.py @@ -119,6 +119,9 @@ LTI_PARAMETERS = [ 'tool_consumer_instance_description', 'tool_consumer_instance_url', 'tool_consumer_instance_contact_email', + 'custom_component_due_date', + 'custom_component_graceperiod', + 'custom_component_display_name' ] diff --git a/lti_consumer/tests/unit/test_lti.py b/lti_consumer/tests/unit/test_lti.py index c6452ebba02189032cc4ca2aaa1e05df45db22f1..0676028e2a558dd4ff974f7139e11b9317982cad 100644 --- a/lti_consumer/tests/unit/test_lti.py +++ b/lti_consumer/tests/unit/test_lti.py @@ -5,8 +5,11 @@ Unit tests for lti_consumer.lti module import unittest +from datetime import timedelta from mock import Mock, PropertyMock, patch +from django.utils import timezone + from lti_consumer.tests.unit.test_utils import FAKE_USER_ID, make_request from lti_consumer.tests.unit.test_lti_consumer import TestLtiConsumerXBlock @@ -146,6 +149,9 @@ class TestLtiConsumer(TestLtiConsumerXBlock): """ Test `get_signed_lti_parameters` returns the correct dict """ + self.lti_consumer.xblock.due = timezone.now() + self.lti_consumer.xblock.graceperiod = timedelta(days=1) + expected_lti_parameters = { u'user_id': self.lti_consumer.xblock.user_id, u'oauth_callback': u'about:blank', @@ -157,6 +163,9 @@ class TestLtiConsumer(TestLtiConsumerXBlock): u'lis_result_sourcedid': self.lti_consumer.xblock.lis_result_sourcedid, u'context_id': self.lti_consumer.xblock.context_id, u'lis_outcome_service_url': self.lti_consumer.xblock.outcome_service_url, + u'custom_component_display_name': self.lti_consumer.xblock.display_name, + u'custom_component_due_date': self.lti_consumer.xblock.due.strftime('%Y-%m-%d %H:%M:%S'), + u'custom_component_graceperiod': str(self.lti_consumer.xblock.graceperiod.total_seconds()), 'lis_person_sourcedid': 'edx', 'lis_person_contact_email_primary': 'edx@example.com', u'custom_param_1': 'custom1',