Commit 95042b75 by Chris Dodge

better handle accessible remaining time when under one minute

parent 68904231
...@@ -505,6 +505,17 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -505,6 +505,17 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
# make sure we have the accessible human string # make sure we have the accessible human string
self.assertEqual(response_data['accessibility_time_string'], 'you have 1 hour and 30 minutes remaining') self.assertEqual(response_data['accessibility_time_string'], 'you have 1 hour and 30 minutes remaining')
# check the special casing of the human string when under a minute
reset_time = datetime.now(pytz.UTC) + timedelta(minutes=90, seconds=30)
with freeze_time(reset_time):
response = self.client.get(
reverse('edx_proctoring.proctored_exam.attempt', args=[attempt_id])
)
self.assertEqual(response.status_code, 200)
response_data = json.loads(response.content)
self.assertEqual(response_data['accessibility_time_string'], 'you have less than a minute remaining')
def test_attempt_ready_to_start(self): def test_attempt_ready_to_start(self):
""" """
Test to get an attempt with ready_to_start status Test to get an attempt with ready_to_start status
......
...@@ -296,9 +296,16 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView): ...@@ -296,9 +296,16 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
time_remaining_seconds = get_time_remaining_for_attempt(attempt) time_remaining_seconds = get_time_remaining_for_attempt(attempt)
attempt['time_remaining_seconds'] = time_remaining_seconds attempt['time_remaining_seconds'] = time_remaining_seconds
attempt['accessibility_time_string'] = _('you have {remaining_time} remaining').format(
remaining_time=humanized_time(int(round(time_remaining_seconds / 60.0, 0))) accessibility_time_string = _('you have {remaining_time} remaining').format(
) remaining_time=humanized_time(int(round(time_remaining_seconds / 60.0, 0))))
# special case if we are less than a minute, since we don't produce
# text translations of granularity at the seconds range
if time_remaining_seconds < 60:
accessibility_time_string = _('you have less than a minute remaining')
attempt['accessibility_time_string'] = accessibility_time_string
return Response( return Response(
data=attempt, data=attempt,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment