Skip to content

Commit

Permalink
Merge ab79cd7 into 1faad3a
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-armstrong committed Sep 23, 2016
2 parents 1faad3a + ab79cd7 commit b695980
Show file tree
Hide file tree
Showing 5 changed files with 1,173 additions and 0 deletions.
3 changes: 3 additions & 0 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,7 @@ def _get_proctored_exam_view(exam, context, exam_id, user_id, course_id):
student_view_template = None

credit_state = context.get('credit_state')
verification_status = context.get('verification_status')

# see if only 'verified' track students should see this *except* if it is a practice exam
check_mode = (
Expand Down Expand Up @@ -1720,6 +1721,8 @@ def _get_proctored_exam_view(exam, context, exam_id, user_id, course_id):
prerequisite_status['pending_prerequisites']
)
student_view_template = 'proctored_exam/pending-prerequisites.html'
elif verification_status is not 'approved':
student_view_template = 'proctored_exam/id_verification.html'
else:
student_view_template = 'proctored_exam/entrance.html'
# emit an event that the user was presented with the option
Expand Down
61 changes: 61 additions & 0 deletions edx_proctoring/templates/proctored_exam/id_verification.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% load i18n %}
<div class="sequence proctored-exam instructions message-left-bar" data-exam-id="{{exam_id}}" data-exam-started-poll-url="{{exam_started_poll_url}}">

<div class="">
<h3>
{% blocktrans %}
Complete verification prior to starting your proctored exam.
{% endblocktrans %}
</h3>
<p>
{% blocktrans %}
In order to start your proctored exam, you must successfully complete identity verification.
{% endblocktrans %}
</p>
{% if verification_status == 'pending' %}
<p>
{% blocktrans %}
Your verification is currently pending. You should expect to hear back in 2-3 days
from submitting your verification.
{% endblocktrans %}
</p>
{% elif verification_status == 'must_reverify' %}
<p>
{% blocktrans %}
Your verification attempt failed. Please retry verification after reading
our guidelines to ensure you successfully complete verification.
{% endblocktrans %}
</p>
<div>
<a href="{{ reverify_url }}" class="reverify-url btn-pl-primary">
{% trans "Retry Verification" %}
</a>
</div>
{% elif verification_status == 'expired' %}
<p>
{% blocktrans %}
Your verification has expired. Please retry verification after reading
our guidelines to ensure you successfully complete verification.
{% endblocktrans %}
</p>
<div>
<a href="{{ reverify_url }}" class="reverify-url btn-pl-primary">
{% trans "Retry Verification" %}
</a>
</div>
{% else %}
<p>
{% blocktrans %}
Make sure you have valid photo identification, such as a driver's license
or passport, before you continue.
{% endblocktrans %}
</p>
<div>
<a href="{{ reverify_url }}" class="reverify-url btn-pl-primary">
{% trans "Continue to Verification" %}
</a>
</div>
{% endif %}
</div>
</div>
{% include 'proctored_exam/footer.html' %}
40 changes: 40 additions & 0 deletions edx_proctoring/tests/test_student_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def test_get_student_view(self):
'display_name': self.exam_name,
'default_time_limit_mins': 90,
'hide_after_due': False,
'verification_status': 'approved',
'verification_url': '/reverify',
}
)
self.assertIn(
Expand Down Expand Up @@ -148,6 +150,42 @@ def test_get_honor_view(self):
)
self.assertIsNone(rendered_response)

@ddt.data(
(None, 'Make sure you have valid photo identification'),
('pending', 'Your verification is currently pending'),
('must_reverify', 'Your verification attempt failed. Please retry verification'),
('expired', 'Your verification has expired'),
)
@ddt.unpack
def test_verification_status(self, verification_status, expected_message):
"""
This test asserts that the correct id verification message is shown
to the user for their current status.
"""

exam = get_exam_by_id(self.proctored_exam_id)

rendered_response = get_student_view(
user_id=self.user_id,
course_id=exam['course_id'],
content_id=exam['content_id'],
context={
'is_proctored': True,
'display_name': self.exam_name,
'default_time_limit_mins': 90,
'is_practice_exam': False,
'credit_state': {
'enrollment_mode': 'verified',
'credit_requirement_status': [
]
},
'verification_status': verification_status,
'verification_url': '/reverify',
}
)

self.assertIn(expected_message, rendered_response)

@ddt.data(
('reverification', None, 'The following prerequisites are in a <strong>pending</strong> state', True),
('reverification', 'pending', 'The following prerequisites are in a <strong>pending</strong> state', True),
Expand Down Expand Up @@ -196,6 +234,8 @@ def test_prereq_scenarios(self, namespace, req_status, expected_content, should_
}
]
},
'verification_status': 'approved',
'verification_url': '/reverify',
}
)

Expand Down
1 change: 1 addition & 0 deletions edx_proctoring/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def setUp(self):
self.student_taking_exam = User()
self.student_taking_exam.save()

set_runtime_service('credit', MockCreditService())
set_runtime_service('instructor', MockInstructorService(is_user_course_staff=True))

def _create_exam_attempt(self):
Expand Down

0 comments on commit b695980

Please sign in to comment.