-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow timed exams for providers that are no longer valid #1237
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1669,7 +1669,7 @@ def update_attempt_status(attempt_id, to_status, | |
if email: | ||
try: | ||
email.send() | ||
except Exception as err: # pylint: disable=broad-except | ||
except Exception as err: | ||
log.exception( | ||
('Exception occurred while trying to send proctoring attempt ' | ||
'status email for user_id=%(user_id)s in course_id=%(course_id)s -- %(err)s'), | ||
|
@@ -2943,7 +2943,7 @@ 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'] | ||
|
||
exam_backend = get_backend_provider(name=exam['backend']) | ||
exam_backend = get_backend_provider(exam=exam) | ||
|
||
sub_view_func = None | ||
if is_timed_exam: | ||
|
@@ -3019,8 +3019,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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want this case to throw an error because we still want the instructor dashboard to load for courses that still have software secure chosen. |
||
return True | ||
except NotImplementedError: | ||
log.exception( | ||
'No proctoring backend configured for backend=%(backend)s', | ||
{ | ||
'backend': exam.backend, | ||
} | ||
) | ||
|
||
return False | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,16 @@ | |
exam = ProctoredExamJSONSafeSerializer(instance).data | ||
# from the perspective of the backend, the exam is now inactive. | ||
exam['is_active'] = False | ||
backend = get_backend_provider(name=exam['backend']) | ||
backend.on_exam_saved(exam) | ||
try: | ||
backend = get_backend_provider(name=exam['backend']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. courses with software secure should be allowed to switch from a proctored to a timed exam. We don't want this code to throw an error in that case |
||
backend.on_exam_saved(exam) | ||
except NotImplementedError: | ||
log.exception( | ||
'No proctoring backend configured for backend=%(backend)s', | ||
{ | ||
'backend': exam['backend'], | ||
} | ||
) | ||
|
||
|
||
@receiver(post_save, sender=models.ProctoredExamReviewPolicy) | ||
|
@@ -127,15 +135,16 @@ | |
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only remove from the backend if it is a proctored exam, so this does fix a bug where instructors wouldn't be able to delete a timed exam. [Question] For the case of PSI, do we care if removing attempts blows up? |
||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an exam is passed in, as opposed to the provider name, a timed exam will always return "None".