Commit 6545e04f by chrisndodge

Merge pull request #207 from edx/cdodge/add-allownaces-to-timed-exams

fix allowances for timed exams
parents 0a22ce62 fec6608d
...@@ -1292,15 +1292,12 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id): ...@@ -1292,15 +1292,12 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
# time limit, including any accommodations # time limit, including any accommodations
allowed_time_limit_mins = exam['time_limit_mins'] allowed_time_limit_mins = exam['time_limit_mins']
allowance = ProctoredExamStudentAllowance.get_allowance_for_user( allowance_extra_mins = ProctoredExamStudentAllowance.get_additional_time_granted(exam_id, user_id)
exam_id,
user_id,
"Additional time (minutes)"
)
if allowance: if allowance_extra_mins:
allowed_time_limit_mins += int(allowance.value) allowed_time_limit_mins += int(allowance_extra_mins)
# apply any cut off times according to due dates
allowed_time_limit_mins, _ = _calculate_allowed_mins( allowed_time_limit_mins, _ = _calculate_allowed_mins(
exam['due_date'], exam['due_date'],
allowed_time_limit_mins allowed_time_limit_mins
...@@ -1322,6 +1319,7 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id): ...@@ -1322,6 +1319,7 @@ def _get_timed_exam_view(exam, context, exam_id, user_id, course_id):
django_context.update({ django_context.update({
'total_time': total_time, 'total_time': total_time,
'exam_id': exam_id, 'exam_id': exam_id,
'exam_name': exam['exam_name'],
'progress_page_url': progress_page_url, 'progress_page_url': progress_page_url,
'does_time_remain': _does_time_remain(attempt), 'does_time_remain': _does_time_remain(attempt),
'enter_exam_endpoint': reverse('edx_proctoring.proctored_exam.attempt.collection'), 'enter_exam_endpoint': reverse('edx_proctoring.proctored_exam.attempt.collection'),
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="sequence timed-exam entrance" data-exam-id="{{exam_id}}"> <div class="sequence timed-exam entrance" data-exam-id="{{exam_id}}">
<h3> <h3>
{% blocktrans %} {% blocktrans %}
{{ display_name }} is a Timed Exam ({{total_time}}) {{ exam_name }} is a Timed Exam ({{total_time}})
{% endblocktrans %} {% endblocktrans %}
</h3> </h3>
<p> <p>
......
...@@ -94,7 +94,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -94,7 +94,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
self.value = 'Test Value' self.value = 'Test Value'
self.external_id = 'test_external_id' self.external_id = 'test_external_id'
self.proctored_exam_id = self._create_proctored_exam() self.proctored_exam_id = self._create_proctored_exam()
self.timed_exam = self._create_timed_exam() self.timed_exam_id = self._create_timed_exam()
self.practice_exam_id = self._create_practice_exam() self.practice_exam_id = self._create_practice_exam()
self.disabled_exam_id = self._create_disabled_exam() self.disabled_exam_id = self._create_disabled_exam()
...@@ -262,7 +262,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -262,7 +262,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
else: else:
exam_id = self.proctored_exam_id exam_id = self.proctored_exam_id
else: else:
exam_id = self.timed_exam exam_id = self.timed_exam_id
return ProctoredExamStudentAttempt.objects.create( return ProctoredExamStudentAttempt.objects.create(
proctored_exam_id=exam_id, proctored_exam_id=exam_id,
...@@ -277,7 +277,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -277,7 +277,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
Creates the ProctoredExamStudentAttempt object. Creates the ProctoredExamStudentAttempt object.
""" """
return ProctoredExamStudentAttempt.objects.create( return ProctoredExamStudentAttempt.objects.create(
proctored_exam_id=self.proctored_exam_id if is_proctored else self.timed_exam, proctored_exam_id=self.proctored_exam_id if is_proctored else self.timed_exam_id,
user_id=self.user_id, user_id=self.user_id,
external_id=self.external_id, external_id=self.external_id,
started_at=started_at if started_at else datetime.now(pytz.UTC), started_at=started_at if started_at else datetime.now(pytz.UTC),
...@@ -400,7 +400,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -400,7 +400,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
test to get the exam by the exam_id and test to get the exam by the exam_id and
then compare their values. then compare their values.
""" """
timed_exam = get_exam_by_id(self.timed_exam) timed_exam = get_exam_by_id(self.timed_exam_id)
self.assertEqual(timed_exam['course_id'], self.course_id) self.assertEqual(timed_exam['course_id'], self.course_id)
self.assertEqual(timed_exam['content_id'], self.content_id_timed) self.assertEqual(timed_exam['content_id'], self.content_id_timed)
self.assertEqual(timed_exam['exam_name'], self.exam_name) self.assertEqual(timed_exam['exam_name'], self.exam_name)
...@@ -1594,29 +1594,26 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -1594,29 +1594,26 @@ class ProctoredExamApiTests(LoggedInTestCase):
But user has an allowance But user has an allowance
""" """
ProctoredExamStudentAllowance.objects.create( allowed_extra_time = 10
proctored_exam_id=self.timed_exam, add_allowance_for_user(
user_id=self.user_id, self.timed_exam_id,
key='Additional time (minutes)', self.user.username,
value=15 ProctoredExamStudentAllowance.ADDITIONAL_TIME_GRANTED,
str(allowed_extra_time)
) )
rendered_response = get_student_view( rendered_response = get_student_view(
user_id=self.user_id, user_id=self.user_id,
course_id=self.course_id, course_id=self.course_id,
content_id=self.content_id_timed, content_id=self.content_id_timed,
context={ context={}
'is_proctored': False,
'display_name': self.exam_name,
'default_time_limit_mins': 90
}
) )
self.assertNotIn( self.assertNotIn(
'data-exam-id="{proctored_exam_id}"'.format(proctored_exam_id=self.proctored_exam_id), 'data-exam-id="{proctored_exam_id}"'.format(proctored_exam_id=self.proctored_exam_id),
rendered_response rendered_response
) )
self.assertIn(self.timed_exam_msg.format(exam_name=self.exam_name), rendered_response) self.assertIn(self.timed_exam_msg.format(exam_name=self.exam_name), rendered_response)
self.assertIn('36 minutes', rendered_response) self.assertIn('31 minutes', rendered_response)
self.assertNotIn(self.start_an_exam_msg.format(exam_name=self.exam_name), rendered_response) self.assertNotIn(self.start_an_exam_msg.format(exam_name=self.exam_name), rendered_response)
@ddt.data( @ddt.data(
...@@ -1643,9 +1640,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -1643,9 +1640,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
course_id=self.course_id, course_id=self.course_id,
content_id=self.content_id_timed, content_id=self.content_id_timed,
context={ context={
'is_proctored': False,
'display_name': self.exam_name, 'display_name': self.exam_name,
'default_time_limit_mins': 90
} }
) )
self.assertIn(expected_content, rendered_response) self.assertIn(expected_content, rendered_response)
...@@ -2049,7 +2044,7 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -2049,7 +2044,7 @@ class ProctoredExamApiTests(LoggedInTestCase):
Assert that we get the expected status summaries Assert that we get the expected status summaries
for the timed exams. for the timed exams.
""" """
timed_exam = get_exam_by_id(self.timed_exam) timed_exam = get_exam_by_id(self.timed_exam_id)
summary = get_attempt_status_summary( summary = get_attempt_status_summary(
self.user.id, self.user.id,
timed_exam['course_id'], timed_exam['course_id'],
......
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