Skip to content

Commit

Permalink
Merge pull request #793 from edx/alangsto/fix_reset_bug
Browse files Browse the repository at this point in the history
Fix bug to allow course staff to reset
  • Loading branch information
alangsto committed Feb 24, 2021
2 parents f3a1ed9 + 6c767f7 commit 0df1431
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
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,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
32 changes: 32 additions & 0 deletions edx_proctoring/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion edx_proctoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0df1431

Please sign in to comment.