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