Commit d23e5360 by Chris Dodge

Adjust content for practice exams

parent 16dd840b
......@@ -505,24 +505,6 @@ def get_student_view(user_id, course_id, content_id,
if user_role != 'student':
return None
# see if only 'verified' track students should see this
check_mode = (
settings.PROCTORING_SETTINGS.get('MUST_BE_VERIFIED_TRACK', True) and
'credit_state' in context and
context['credit_state']
)
if check_mode:
# Allow only the verified students to take the exam as a proctored exam
# Also make an exception for the honor students to take the "practice exam" as a proctored exam.
# For the rest of the enrollment modes, None is returned which shows the exam content
# to the student rather than the proctoring prompt.
if not (context['credit_state']['enrollment_mode'] == 'verified' or (
context['credit_state']['enrollment_mode'] == 'honor' and context['is_practice_exam'])):
return None
student_view_template = None
exam_id = None
......@@ -535,22 +517,38 @@ def get_student_view(user_id, course_id, content_id,
return None
exam_id = exam['id']
is_proctored = exam['is_proctored']
except ProctoredExamNotFoundException:
# This really shouldn't happen
# as Studio will be setting this up
is_proctored = context.get('is_proctored', False)
is_practice_exam = context.get('is_practice_exam', False)
exam_id = create_exam(
course_id=course_id,
content_id=unicode(content_id),
exam_name=context['display_name'],
time_limit_mins=context['default_time_limit_mins'],
is_proctored=is_proctored,
is_practice_exam=is_practice_exam
is_proctored=context.get('is_proctored', False),
is_practice_exam=context.get('is_practice_exam', False)
)
exam = get_exam_by_content_id(course_id, content_id)
is_proctored = exam['is_proctored']
# see if only 'verified' track students should see this *except* if it is a practice exam
check_mode = (
settings.PROCTORING_SETTINGS.get('MUST_BE_VERIFIED_TRACK', True) and
'credit_state' in context and
context['credit_state'] and not
exam['is_practice_exam']
)
if check_mode:
# Allow only the verified students to take the exam as a proctored exam
# Also make an exception for the honor students to take the "practice exam" as a proctored exam.
# For the rest of the enrollment modes, None is returned which shows the exam content
# to the student rather than the proctoring prompt.
if context['credit_state']['enrollment_mode'] != 'verified':
return None
attempt = get_exam_attempt(exam_id, user_id)
has_started_exam = attempt and attempt.get('started_at')
has_time_expired = False
......
{% load i18n %}
<p>{% blocktrans %} You can also retake the exam. {% endblocktrans %}</p>
<p>{% blocktrans %} You can also <a class="start-timed-exam" data-ajax-url="{{enter_exam_endpoint}}" data-exam-id="{{exam_id}}" data-attempt-proctored=true data-start-immediately=false>retake the exam</a>. {% endblocktrans %}</p>
<button type="button" name="submit-proctored-exam" class="start-timed-exam" data-ajax-url="{{enter_exam_endpoint}}" data-exam-id="{{exam_id}}" data-attempt-proctored=true data-start-immediately=false >
{% blocktrans %}
Re-run the Exam
{% endblocktrans %}
</button>
<script type="text/javascript">
$('.start-timed-exam').click(
function(event) {
var action_url = $(this).data('ajax-url');
var exam_id = $(this).data('exam-id');
var attempt_proctored = $(this).data('attempt-proctored');
var start_immediately = $(this).data('start-immediately');
if (typeof action_url === "undefined" ) {
return false;
}
$.post(
action_url,
{
"exam_id": exam_id,
"attempt_proctored": attempt_proctored,
"start_clock": start_immediately
},
function(data) {
// reload the page, because we've unlocked it
location.reload();
}
);
}
);
</script>
\ No newline at end of file
......@@ -4,6 +4,3 @@
{% trans "Your exam has been marked as failed due to an error." %}
</div>
</div>
{% if is_sample_attempt %}
{% include 'proctoring/rerun_practice_attempt.html' %}
{% endif %}
\ No newline at end of file
......@@ -7,7 +7,7 @@
</h3>
<p>
{% blocktrans %}
Since you're enrolled in this course as a verified student, you have the option practice taking a proctored exam. Online proctoring is one requirement towards being eligible for credit.
Since this course is offered for credit, there will be one or more proctored exams in this course. Before you encounter a proctored exam that will count towards your grade and credit eligibility. You now have the option to take a practice proctored exam. Online proctoring is one requirement towards being eligible for credit.
{% endblocktrans %}
</p>
<p>
......
......@@ -19,4 +19,35 @@
with the rest of your course
{% endblocktrans %}
</p>
<div class="gated-sequence">
<span><i class="fa fa-lock"></i></span>
<a class="start-timed-exam" data-ajax-url="{{enter_exam_endpoint}}" data-exam-id="{{exam_id}}" data-attempt-proctored=true data-start-immediately=false>
{% trans "You can also retry this practice exam" %}
</a>
</div>
</div>
<script type="text/javascript">
$('.start-timed-exam').click(
function(event) {
var action_url = $(this).data('ajax-url');
var exam_id = $(this).data('exam-id');
var attempt_proctored = $(this).data('attempt-proctored');
var start_immediately = $(this).data('start-immediately');
if (typeof action_url === "undefined" ) {
return false;
}
$.post(
action_url,
{
"exam_id": exam_id,
"attempt_proctored": attempt_proctored,
"start_clock": start_immediately
},
function(data) {
// reload the page, because we've unlocked it
location.reload();
}
);
}
);
</script>
......@@ -588,12 +588,13 @@ class ProctoredExamApiTests(LoggedInTestCase):
def test_get_honor_view_with_practice_exam(self): # pylint: disable=invalid-name
"""
Test for get_student_view prompting when the student is enrolled in non-verified
track for a practice exam, this should return not None
track for a practice exam, this should return not None, meaning
student will see proctored content
"""
rendered_response = get_student_view(
user_id=self.user_id,
course_id=self.course_id,
content_id=self.content_id,
content_id=self.content_id_practice,
context={
'is_proctored': True,
'display_name': self.exam_name,
......
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