Skip to content

Commit

Permalink
Merge pull request #1073 from open-craft/agrendalath/allow_submitting…
Browse files Browse the repository at this point in the history
…_timed_exams_after_course_end_date

fix: do not use course's due date when a timed exam has one specified
  • Loading branch information
ashultz0 committed Oct 26, 2022
2 parents 0588aad + 5de6d30 commit ab8b56c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Change Log
Unreleased
~~~~~~~~~~

[4.13.0] - 2022-10-26
~~~~~~~~~~~~~~~~~~~~~
* Do not use course's due date when a timed exam has one specified

[4.12.2] - 2022-10-19
~~~~~~~~~~~~~~~~~~~~~
* Return external id when requesting exam attempt
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__ = '4.12.2'
__version__ = '4.13.0'

default_app_config = 'edx_proctoring.apps.EdxProctoringConfig' # pylint: disable=invalid-name
11 changes: 8 additions & 3 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,11 +882,16 @@ def is_exam_passed_due(exam, user=None):
Return whether the due date has passed.
Uses edx_when to lookup the date for the subsection.
"""
due_date = get_exam_due_date(exam, user=user)
return (
has_due_date_passed(get_exam_due_date(exam, user=user))
# if the exam is timed and passed the course end date, it should also be considered passed due
has_due_date_passed(due_date)
# If the exam is timed and passed the course end date, it should also be considered passed due, unless
# it has a due date set. The exam's due date has a higher priority than the course's end date.
or (
not exam['is_proctored'] and not exam['is_practice_exam'] and has_end_date_passed(exam['course_id'])
not due_date
and not exam['is_proctored']
and not exam['is_practice_exam']
and has_end_date_passed(exam['course_id'])
)
)

Expand Down
27 changes: 27 additions & 0 deletions edx_proctoring/tests/test_student_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,33 @@ def test_timed_exam_attempt_with_past_due_datetime(self):
)
self.assertIn(self.exam_expired_msg, rendered_response)

@patch('edx_when.api.get_date_for_block')
@patch('edx_when.api.get_dates_for_course')
def test_timed_exam_attempt_with_past_course_due_date_and_future_exam_due_date(
self, mock_course_dates, mock_exam_due_date
):
"""
When the course due date is in the past, but the exam-specific due date is in the future, students should still
be able to start this exam.
"""
current_date = datetime.now(pytz.UTC)
course_end_date = current_date - timedelta(days=14)
exam_due_date = current_date + timedelta(days=14)

mock_course_dates.return_value = {('dummy', 'end'): course_end_date}
mock_exam_due_date.return_value = exam_due_date

self._create_exam_with_due_time(due_date=exam_due_date, is_proctored=False)

with freeze_time(current_date):
rendered_response = get_student_view(
user_id=self.user_id,
course_id=self.course_id,
content_id=self.content_id_for_exam_with_due_date,
context={},
)
self.assertIn(self.timed_footer_msg, rendered_response)

@patch.dict('django.conf.settings.PROCTORING_SETTINGS', {'ALLOW_TIMED_OUT_STATE': True})
def test_get_studentview_timedout(self):
"""
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.12.2",
"version": "4.13.0",
"main": "edx_proctoring/static/index.js",
"scripts": {
"test": "gulp test"
Expand Down

0 comments on commit ab8b56c

Please sign in to comment.