Skip to content

Commit 364e582

Browse files
authored
feat: redirect to exam on tab (#382)
1 parent 98ed45f commit 364e582

5 files changed

Lines changed: 23 additions & 7 deletions

File tree

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Please See the `releases tab <https://github.com/openedx/xblock-lti-consumer/rel
1616
Unreleased
1717
~~~~~~~~~~
1818

19+
9.5.3 - 2023-06-09
20+
------------------
21+
* Redirect to exam on same LTI proctoring launch tab once ready to start.
1922
* Show a warning in Studio if an LTI 1.1 consumer has an invalid `lti_id`.
2023

2124
9.5.2 - 2023-05-24

lti_consumer/plugin/views.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import urllib
66

7+
from django.conf import settings
78
from django.contrib.auth import get_user_model
89
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied, ValidationError
910
from django.db import transaction
@@ -835,4 +836,12 @@ def start_proctoring_assessment_endpoint(request):
835836
user_id=request.user.id,
836837
)
837838

838-
return render(request, 'html/lti_start_assessment.html', status=HTTP_200_OK)
839+
context_url = "/".join([settings.LEARNING_MICROFRONTEND_URL, "course",
840+
launch_data.context_id,
841+
launch_data.context_label])
842+
context = {}
843+
context.update({
844+
"context_url": context_url,
845+
})
846+
847+
return render(request, 'html/lti_start_assessment.html', context, status=HTTP_200_OK)

lti_consumer/templates/html/lti_start_assessment.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
{% load i18n %}
2+
23
<!DOCTYPE html>
34
<html>
45
<head>
5-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
6+
<meta http-equiv="refresh" content="5; url='{{ context_url }}'" >
67
<title>LTI</title>
78
</head>
89
<body>
910
<p>
1011
<b>{% trans "Sending you back to your exam." %}</b>
1112
</p>
12-
<script>
13-
setTimeout(function () {window.close()}, 5000);
14-
</script>
1513
<p>
16-
<a href="javascript:window.close();">
14+
<a href="{{ context_url }}">
1715
{% trans "Return to exam." %}
1816
</a>
1917
</p>

lti_consumer/tests/unit/plugin/test_proctoring.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def _setup_cached_data(self):
8585
config_id=self.lti_config.config_id,
8686
resource_link_id="resource_link_id",
8787
proctoring_launch_data=proctoring_launch_data,
88+
context_id="course-v1:testU+DemoX+Demo_Course",
89+
context_title="http://localhost:2000",
90+
context_label="block-v1:testU+DemoX+Demo_Course+type@sequential+block@1234",
8891
)
8992

9093
self.launch_data_key = get_cache_key(
@@ -293,4 +296,4 @@ def test_start_assessment_endpoint_returns_valid_html(self):
293296
)
294297

295298
self.assertEqual(response.status_code, 200)
296-
self.assertIn('window.close', response.content.decode('utf-8'))
299+
self.assertIn('Return to exam', response.content.decode('utf-8'))

test_settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828

2929
# Platform name for LTI 1.1 and 1.3 claims testing
3030
PLATFORM_NAME = "Your platform name here"
31+
32+
# Learning MFE URL for start assessment testing
33+
LEARNING_MICROFRONTEND_URL = 'http://test.learning:2000'

0 commit comments

Comments
 (0)