Skip to content

Commit

Permalink
fix: handle case where backend provider no longer exists for timed exams
Browse files Browse the repository at this point in the history
  • Loading branch information
alangsto committed Oct 2, 2024
1 parent f4d81e5 commit 5325ae7
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ Change Log
Unreleased
~~~~~~~~~~
* fix timed exam bug for provider that no longer exists
* fix timed exam reset bug for provider that no longer exists
* fix instructor dashboard view for provider that no longer exists

[4.17.0]
~~~~~~~~~~~~~~~~~~~~~
* Add support for Python 3.11 & 3.12

[4.16.1] - 2023-08-8
~~~~~~~~~~~~~~~~~~~~~
* Updated django-simple-history package to 3.3.0
* Updated django-simple-history package to 3.3.0
* Created no-op migrations needed for new django-simple-history package version

[4.16.0] - 2023-06-22
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""

# Be sure to update the version number in edx_proctoring/package.json
__version__ = '4.18.1'
__version__ = '4.18.2'
22 changes: 20 additions & 2 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,7 +2943,16 @@ def get_student_view(user_id, course_id, content_id,
is_proctored_exam = exam['is_proctored'] and not exam['is_practice_exam']
is_timed_exam = not exam['is_proctored'] and not exam['is_practice_exam']

<<<<<<< HEAD
<<<<<<< HEAD
exam_backend = get_backend_provider(name=exam['backend'])
=======
# exam_backend = get_backend_provider(name=exam['backend'])
exam_backend = get_backend_provider(exam=exam)
>>>>>>> 3591678b69 (fix: handle case where backend provider no longer exists for timed exams)
=======
exam_backend = get_backend_provider(exam=exam)
>>>>>>> d2511db8eb (fix: allow timed exams for providers that are no longer valid)

sub_view_func = None
if is_timed_exam:
Expand Down Expand Up @@ -3019,8 +3028,17 @@ def is_backend_dashboard_available(course_id):
active_only=True
)
for exam in exams:
if get_backend_provider(name=exam.backend).has_dashboard:
return True
try:
if get_backend_provider(name=exam.backend).has_dashboard:
return True
except NotImplementedError:
log.exception(
'No proctoring backend configured for backend=%(backend)s',
{
'backend': exam.backend,
}
)

return False


Expand Down
19 changes: 10 additions & 9 deletions edx_proctoring/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ def on_attempt_changed(sender, instance, signal, **kwargs):
else:
# remove the attempt on the backend
# timed exams have no backend
backend = get_backend_provider(name=instance.proctored_exam.backend)
if backend:
result = backend.remove_exam_attempt(instance.proctored_exam.external_id, instance.external_id)
if not result:
log.error(
'Failed to remove attempt_id=%s from backend=%s',
instance.id,
instance.proctored_exam.backend,
)
if instance.proctored_exam.is_proctored:
backend = get_backend_provider(name=instance.proctored_exam.backend)
if backend:
result = backend.remove_exam_attempt(instance.proctored_exam.external_id, instance.external_id)
if not result:
log.error(
'Failed to remove attempt_id=%s from backend=%s',
instance.id,
instance.proctored_exam.backend,
)


@receiver(post_delete, sender=models.ProctoredExamStudentAttempt)
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setUp(self):
self.proctored_exam = ProctoredExam.objects.create(
course_id='x/y/z', content_id=self.content_id, exam_name=self.exam_name,
time_limit_mins=self.default_time_limit, external_id=self.external_id,
backend=self.backend_name
backend=self.backend_name, is_proctored=True,
)
self.attempt = ProctoredExamStudentAttempt.objects.create(
proctored_exam=self.proctored_exam, user=self.user, attempt_code='12345',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@edx/edx-proctoring",
"//": "Note that the version format is slightly different than that of the Python version when using prereleases.",
"version": "4.18.1",
"version": "4.18.2",
"main": "edx_proctoring/static/index.js",
"scripts": {
"test": "gulp test"
Expand Down

0 comments on commit 5325ae7

Please sign in to comment.