Skip to content

Commit

Permalink
Merge pull request #877 from edx/alangsto/call_backend_start_once
Browse files Browse the repository at this point in the history
fix: only request backend status update to started once
  • Loading branch information
alangsto authored Jun 9, 2021
2 parents c5419dc + 41766c2 commit b462d4c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
15 changes: 10 additions & 5 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ Change Log
Unreleased
~~~~~~~~~~

[3.13.1] - 2021-06-08
~~~~~~~~~~~~~~~~~~~~~
* If an attempt transitions from `ready_to_submit` back to `started`, the proctoring provider
backend function `start_exam_attempt` will not be called.

[3.13.0] - 2021-06-07
~~~~~~~~~~~~~~~~~~~~~
* If the Django setting `PROCTORED_EXAM_VIEWABLE_PAST_DUE` is false, exam content will not be viewable past
an exam's due date, even if a learner has acknowledged their status.
* Extend exam attempt API to return exam type and to check if
user has satisfied prerequisites before taking proctored exam.
* Extend proctoring settings API to return additional data about proctoring
provider.
* Add API endpoint which provides exam review policy for specific exam.
Usage case is to provide required data for the learning app MFE.

[3.13.0] - 2021-06-07
~~~~~~~~~~~~~~~~~~~~~
* If the Django setting `PROCTORED_EXAM_VIEWABLE_PAST_DUE` is false, exam content will not be viewable past
an exam's due date, even if a learner has acknowledged their status.

[3.12.0] - 2021-06-04
~~~~~~~~~~~~~~~~~~~~~
* If the `is_integrity_signature_enabled` waffle flag is turned on, do not render the ID verification
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.13.0'
__version__ = '3.13.1'

default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name
6 changes: 5 additions & 1 deletion edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,11 @@ def update_attempt_status(attempt_id, to_status,
# only proctored/practice exams have a backend
# timed exams have no backend
backend_method = None
if to_status == ProctoredExamStudentAttemptStatus.started:

# add_start_time will only have a value of true if this is the first time an
# attempt is transitioning to started. We only want to notify the backend
# for the first time an attempt is transitioned to a started status (MST-862).
if to_status == ProctoredExamStudentAttemptStatus.started and add_start_time:
backend_method = backend.start_exam_attempt
elif to_status == ProctoredExamStudentAttemptStatus.submitted:
backend_method = backend.stop_exam_attempt
Expand Down
28 changes: 28 additions & 0 deletions edx_proctoring/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
update_exam_attempt,
update_review_policy
)
from edx_proctoring.backends.tests.test_backend import TestBackendProvider
from edx_proctoring.constants import DEFAULT_CONTACT_EMAIL
from edx_proctoring.exceptions import (
AllowanceValueNotAllowedException,
Expand Down Expand Up @@ -1635,6 +1636,33 @@ def test_update_attempt_without_credit_state(self):

self.assertEqual(new_attempt, exam_attempt.id)

@patch.object(TestBackendProvider, 'start_exam_attempt')
def test_update_attempt_multiple_starts(self, mock_backend_start):
"""
Test that updating an attempt status to `started` more than once
will only call the backend's start_exam_attempt once
"""
exam_attempt = self._create_exam_attempt(self.proctored_exam_id)
update_attempt_status(
exam_attempt.id,
ProctoredExamStudentAttemptStatus.started
)
mock_backend_start.assert_called_once()

# move status to ready to submit
update_attempt_status(
exam_attempt.id,
ProctoredExamStudentAttemptStatus.ready_to_submit
)
# move status to started
update_attempt_status(
exam_attempt.id,
ProctoredExamStudentAttemptStatus.started
)

# make sure that method was not called again
mock_backend_start.assert_called_once()

@ddt.data(
(
ProctoredExamStudentAttemptStatus.eligible, {
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.13.0",
"version": "3.13.1",
"main": "edx_proctoring/static/index.js",
"scripts": {
"test": "gulp test"
Expand Down

0 comments on commit b462d4c

Please sign in to comment.