From 6c767f7b1cb2641ac19e09f775b8cebab310672c Mon Sep 17 00:00:00 2001 From: Alie Langston Date: Tue, 23 Feb 2021 18:48:59 -0500 Subject: [PATCH] Fix bug to allow course staff to reset updated version Update __init__.py Update package.json Update CHANGELOG.rst --- CHANGELOG.rst | 6 +++++- edx_proctoring/__init__.py | 2 +- edx_proctoring/tests/test_views.py | 32 ++++++++++++++++++++++++++++++ edx_proctoring/views.py | 2 +- package.json | 2 +- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 963488286ba..1fb98fbca5a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,10 @@ Change Log Unreleased ~~~~~~~~~~ +[3.6.5] - 2021-02-23 +~~~~~~~~~~~~~~~~~~~~ +* Bug fix to allow course staff to reset attempts + [3.6.4] - 2021-02-24 ~~~~~~~~~~~~~~~~~~~~ * Switched from jsonfield2 to jsonfield as the earlier one has archived and merged back in the latter one. @@ -31,7 +35,7 @@ Unreleased [3.6.1] - 2021-02-19 ~~~~~~~~~~~~~~~~~~~~ -* Add time_remaining_seconds field of ProctoredExamStudentAttempt model to readonly_fields in +* Add time_remaining_seconds field of ProctoredExamStudentAttempt model to readonly_fields in Django admin page so it is not required when editing the model. * Update reference to Exception.message to use string representation of the exception, as message is no longer an attribute of the Exception class. diff --git a/edx_proctoring/__init__.py b/edx_proctoring/__init__.py index 8b631b93b2d..1c7e21f248d 100644 --- a/edx_proctoring/__init__.py +++ b/edx_proctoring/__init__.py @@ -3,6 +3,6 @@ """ # Be sure to update the version number in edx_proctoring/package.json -__version__ = '3.6.4' +__version__ = '3.6.5' default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name diff --git a/edx_proctoring/tests/test_views.py b/edx_proctoring/tests/test_views.py index 8359cd99c47..356f6188414 100644 --- a/edx_proctoring/tests/test_views.py +++ b/edx_proctoring/tests/test_views.py @@ -4452,6 +4452,38 @@ def test_deletes_all_attempts(self): attempts = ProctoredExamStudentAttempt.objects.filter(user_id=self.user.id, proctored_exam_id=self.exam_id) assert len(attempts) == 0 + def test_course_staff_can_delete(self): + """ + Tests that course staff can delete attempts + """ + + attempt_data = { + 'exam_id': self.exam_id, + 'start_clock': True, + } + response = self.client.post( + reverse('edx_proctoring:proctored_exam.attempt.collection'), + attempt_data + ) + + self.assertEqual(response.status_code, 200) + response_data = json.loads(response.content.decode('utf-8')) + attempt_id = response_data['exam_attempt_id'] + self.assertGreater(attempt_id, 0) + + # now set the user is_staff to False + # and also user is a course staff + self.user.is_staff = False + self.user.save() + set_runtime_service('instructor', MockInstructorService(is_user_course_staff=True)) + + response = self.client.delete( + reverse('edx_proctoring:proctored_exam.attempts.reset', + kwargs={'exam_id': self.exam_id, 'user_id': self.user.id}) + ) + + self.assertEqual(response.status_code, 200) + class TestStudentProctoredGroupedExamAttemptsByCourse(LoggedInTestCase): """ diff --git a/edx_proctoring/views.py b/edx_proctoring/views.py index f20410fa034..d6cf0560dd8 100644 --- a/edx_proctoring/views.py +++ b/edx_proctoring/views.py @@ -102,7 +102,7 @@ def require_course_or_global_staff(func): def wrapped(request, *args, **kwargs): # pylint: disable=missing-docstring instructor_service = get_runtime_service('instructor') course_id = kwargs.get('course_id', None) - exam_id = request.data.get('exam_id', None) + exam_id = request.data.get('exam_id') or kwargs.get('exam_id', None) attempt_id = kwargs.get('attempt_id', None) if request.user.is_staff: return func(request, *args, **kwargs) diff --git a/package.json b/package.json index 4d391c9ba2f..cbb96391211 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@edx/edx-proctoring", "//": "Be sure to update the version number in edx_proctoring/__init__.py", "//": "Note that the version format is slightly different than that of the Python version when using prereleases.", - "version": "3.6.4", + "version": "3.6.5", "main": "edx_proctoring/static/index.js", "repository": { "type": "git",