diff --git a/physics/templates/physics/exam_finish.html b/physics/templates/physics/exam_finish.html
index 5f88b574..0649a9ca 100644
--- a/physics/templates/physics/exam_finish.html
+++ b/physics/templates/physics/exam_finish.html
@@ -9,7 +9,7 @@ CID: {{cid}}
{{answer_count}} out of {{exam_length}} questions answered. Click to go to question.
diff --git a/physics/templates/physics/exam_overview.html b/physics/templates/physics/exam_overview.html
index 372eb659..8a877d4a 100644
--- a/physics/templates/physics/exam_overview.html
+++ b/physics/templates/physics/exam_overview.html
@@ -25,7 +25,6 @@
Publish results: [When checked the exam results will be available on this site]
-
This exam will be available to take here (when active).
{% autoescape off %}
diff --git a/physics/templates/physics/exam_start.html b/physics/templates/physics/exam_start.html
index f3d4027e..076dbb97 100755
--- a/physics/templates/physics/exam_start.html
+++ b/physics/templates/physics/exam_start.html
@@ -6,6 +6,7 @@
Enter your CID in the below box.
+
Start exam
@@ -13,9 +14,10 @@ Enter your CID in the below box.
$(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).")
}
diff --git a/physics/urls.py b/physics/urls.py
index 8dce05ec..9786fafe 100644
--- a/physics/urls.py
+++ b/physics/urls.py
@@ -14,10 +14,9 @@ urlpatterns = [
#path("exam///mark", views.mark, name="mark"),
#path("exam//mark", views.mark_overview, name="mark_overview"),
path("exam//take_old", views.exam_take_old, name="exam_take_old"),
- path("exam////take", views.exam_take, name="exam_take"),
- path("exam/////take", views.exam_take, name="exam_take_passcode"),
+ path("exam/////take", views.exam_take, name="exam_take"),
path("exam//start", views.exam_start, name="exam_start"),
- path("exam///finish", views.exam_finish, name="exam_finish"),
+ path("exam////finish", views.exam_finish, name="exam_finish"),
path("exam//", views.PhysicsExamViews.exam_overview, name="exam_overview"),
path("exam//scores", views.exam_scores_cid,
name="exam_scores_cid"),
diff --git a/physics/views.py b/physics/views.py
index aae4c58d..bd7a72e6 100644
--- a/physics/views.py
+++ b/physics/views.py
@@ -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,
},
)