.
This commit is contained in:
@@ -9,7 +9,7 @@ CID: {{cid}}
|
||||
{{answer_count}} out of {{exam_length}} questions answered. Click to go to question.
|
||||
<div class="sba-finish-list">
|
||||
{% for question, answer in question_answer_tuples %}
|
||||
<a href="{% url 'physics:exam_take' pk=exam.id sk=forloop.counter0 cid=cid %}"><button {% if not answer %}class="unanswered"{% endif %}>{{forloop.counter}}: {{answer.answer}}</button></a>
|
||||
<a href="{% url 'physics:exam_take' pk=exam.id sk=forloop.counter0 cid=cid passcode=passcode %}"><button {% if not answer %}class="unanswered"{% endif %}>{{forloop.counter}}: {{answer.answer}}</button></a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
<div class="parent-help" title="Click to enable / disable the exam results">
|
||||
Publish results: <input type="checkbox" id="exam-publish-results-switch" {% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will be available on this site]</span>
|
||||
</div>
|
||||
<!--<p><button><a href="{% url 'anatomy:exam_take' pk=exam.pk sk=0 %}">Click here to start</a></button></p>-->
|
||||
This exam will be available to take <a href="{% url 'physics:exam_start' pk=exam.pk %}">here</a> (when active).
|
||||
|
||||
{% autoescape off %}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
Enter your CID in the below box.<br />
|
||||
<input id="cid-box" type="text" value="Candidate ID">
|
||||
<input id="passcode-box" type="text" value="Passcode">
|
||||
|
||||
<button>Start exam</button>
|
||||
|
||||
@@ -13,9 +14,10 @@ Enter your CID in the below box.<br />
|
||||
$(document).ready(function () {
|
||||
$("button").click(() => {
|
||||
let cid = $("#cid-box").val();
|
||||
let passcode = $("#passcode-box").val();
|
||||
|
||||
if (Number.isInteger(parseInt(cid))) {
|
||||
window.location.replace("{% url 'physics:exam_take' pk=exam.pk sk=0 cid='0000000' %}".replace("0000000", cid));
|
||||
window.location.replace("{% url 'physics:exam_take' pk=exam.pk sk=0 cid='0000000' passcode='ZZZZZZ' %}".replace("0000000", cid).replace("ZZZZZZ", passcode));
|
||||
} else {
|
||||
alert("Please enter a valid Candidate ID (CID).")
|
||||
}
|
||||
|
||||
+2
-3
@@ -14,10 +14,9 @@ urlpatterns = [
|
||||
#path("exam/<int:pk>/<int:sk>/mark", views.mark, name="mark"),
|
||||
#path("exam/<int:pk>/mark", views.mark_overview, name="mark_overview"),
|
||||
path("exam/<int:pk>/take_old", views.exam_take_old, name="exam_take_old"),
|
||||
path("exam/<int:pk>/<int:sk>/<str:cid>/take", views.exam_take, name="exam_take"),
|
||||
path("exam/<int:pk>/<int:sk>/<str:cid>/<str:passcode>/take", views.exam_take, name="exam_take_passcode"),
|
||||
path("exam/<int:pk>/<int:sk>/<str:cid>/<str:passcode>/take", views.exam_take, name="exam_take"),
|
||||
path("exam/<int:pk>/start", views.exam_start, name="exam_start"),
|
||||
path("exam/<int:pk>/<str:cid>/finish", views.exam_finish, name="exam_finish"),
|
||||
path("exam/<int:pk>/<str:cid>/<str:passcode>/finish", views.exam_finish, name="exam_finish"),
|
||||
path("exam/<int:pk>/", views.PhysicsExamViews.exam_overview, name="exam_overview"),
|
||||
path("exam/<int:pk>/scores", views.exam_scores_cid,
|
||||
name="exam_scores_cid"),
|
||||
|
||||
+11
-8
@@ -278,7 +278,7 @@ def exam_start(request, pk):
|
||||
)
|
||||
|
||||
|
||||
def exam_finish(request, pk, cid):
|
||||
def exam_finish(request, pk, cid, passcode=None):
|
||||
exam = get_object_or_404(Exam, pk=pk)
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
@@ -311,6 +311,7 @@ def exam_finish(request, pk, cid):
|
||||
"question_answer_tuples": question_answer_tuples,
|
||||
"answer_count": answer_count,
|
||||
"exam_length": len(questions),
|
||||
"passcode": passcode
|
||||
},
|
||||
)
|
||||
|
||||
@@ -353,20 +354,21 @@ def exam_take(request, pk, sk, cid, passcode=None):
|
||||
|
||||
kwargs = {
|
||||
"pk": pk,
|
||||
"cid" : cid
|
||||
"cid" : cid,
|
||||
"passcode" : passcode
|
||||
}
|
||||
if passcode is not None:
|
||||
kwargs["passcode"] = passcode
|
||||
take_url = "physics:exam_take"
|
||||
finish_url = "physics:exam_finish"
|
||||
|
||||
if "next" in request.POST:
|
||||
return redirect("physics:exam_take", sk=pos + 1, **kwargs)
|
||||
return redirect(take_url, sk=pos + 1, **kwargs)
|
||||
elif "previous" in request.POST:
|
||||
return redirect("physics:exam_take", sk=pos - 1, **kwargs)
|
||||
return redirect(take_url, sk=pos - 1, **kwargs)
|
||||
elif "finish" in request.POST:
|
||||
return redirect("physics:exam_finish", **kwargs)
|
||||
return redirect(finish_url, **kwargs)
|
||||
elif "goto" in request.POST:
|
||||
return redirect(
|
||||
"physics:exam_take", sk=int(request.POST.get("goto")), **kwargs
|
||||
take_url, sk=int(request.POST.get("goto")), **kwargs
|
||||
)
|
||||
else:
|
||||
form = CidUserAnswerForm(instance=answer)
|
||||
@@ -394,6 +396,7 @@ def exam_take(request, pk, sk, cid, passcode=None):
|
||||
"previous": previous,
|
||||
"exam_length": exam_length,
|
||||
"pos": pos,
|
||||
"passcode": passcode,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user