Skip to content

Commit

Permalink
feat: ProctoringConsumer basic launch request (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 authored Jun 28, 2023
1 parent cb33ae5 commit d82a697
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Please See the `releases tab <https://github.com/openedx/xblock-lti-consumer/rel
Unreleased
~~~~~~~~~~

9.5.4 - 2023-06-28
------------------
* Allow basic LtiResourceLink launch for an LtiProctoringConsumer

9.5.3 - 2023-06-09
------------------
* Redirect to exam on same LTI proctoring launch tab once ready to start.
Expand Down
2 changes: 1 addition & 1 deletion lti_consumer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .apps import LTIConsumerApp
from .lti_xblock import LtiConsumerXBlock

__version__ = '9.5.3'
__version__ = '9.5.4'
7 changes: 6 additions & 1 deletion lti_consumer/lti_1p3/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,13 @@ def generate_launch_request(
self.set_extra_claim(self.get_assessment_control_claim())
elif launch_data.message_type == "LtiEndAssessment":
proctoring_claims = self.get_end_assessment_claims()
elif launch_data.message_type == "LtiResourceLinkRequest":
proctoring_claims = {}
else:
raise ValueError('lti_message_hint must \"LtiStartProctoring\" or \"LtiEndAssessment\".')
raise ValueError(
'lti_message_hint must be \"LtiStartProctoring\" or \"LtiEndAssessment\"'
'or \"LtiResourceLinkRequest\"'
)

self.set_extra_claim(proctoring_claims)

Expand Down
19 changes: 16 additions & 3 deletions lti_consumer/lti_1p3/tests/test_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,19 @@ def test_generate_launch_request(self, message_type, mock_get_data_from_cache):
for claim in expected_claims.items():
self.assertIn(claim, decoded_token_claims)

@patch('lti_consumer.lti_1p3.consumer.get_data_from_cache')
def test_generate_basic_launch_request(self, mock_get_data_from_cache):
mock_launch_data = self.get_launch_data(message_type="LtiResourceLinkRequest")
mock_get_data_from_cache.return_value = mock_launch_data

self._setup_proctoring()
token = self.lti_consumer.generate_launch_request(
self.preflight_response,
)['id_token']

# just check token is valid
self.lti_consumer.key_handler.validate_and_decode(token)

@patch('lti_consumer.lti_1p3.consumer.get_data_from_cache')
def test_enable_assessment_control(self, mock_get_data_from_cache):
"""
Expand Down Expand Up @@ -1120,11 +1133,11 @@ def test_enable_assessment_control(self, mock_get_data_from_cache):
@patch('lti_consumer.lti_1p3.consumer.get_data_from_cache')
def test_generate_launch_request_invalid_message(self, mock_get_data_from_cache):
"""
Ensures that a ValueError is raised if the launch_data.message_type is not LtiStartProctoring or
LtiEndAssessment.
Ensures that a ValueError is raised if the launch_data.message_type is not LtiStartProctoring,
LtiEndAssessment, or LtiResourceLinkRequest.
"""

mock_launch_data = self.get_launch_data(message_type="LtiResourceLinkRequest")
mock_launch_data = self.get_launch_data(message_type="LtiDeepLinkingRequest")
mock_get_data_from_cache.return_value = mock_launch_data

self._setup_proctoring()
Expand Down

0 comments on commit d82a697

Please sign in to comment.