This commit is contained in:
Ross
2022-04-01 19:12:35 +01:00
parent f7f662ec83
commit 0686bb33e3
4 changed files with 51 additions and 27 deletions
@@ -16,8 +16,50 @@
{% endif %}
</li>
{% if take %}
<h1>TAKE</h1>
{% if collection.collection_type == "REV" %}
<h2>Start: {{exam.name}}</h2>
Enter your CID and passcode in the below boxes.<br />
<p><input id="cid-box" type="text" value="Candidate ID"></p>
<p><input id="passcode-box" type="text" value="Passcode"></p>
<button>Start</button>
<script type="text/javascript">
$(document).ready(function () {
window.location.search.substr(1).split("&").forEach((item) =>
{
s = item.split("=");
if (s[0] == "cid") {
$("#cid-box").val(s[1]);
}
if (s[0] == "passcode") {
$("#passcode-box").val(s[1]);
}
});
$("#cid-box, #passcode-box").keypress(function(e) {
// Enter pressed?
console.log(e)
if(e.which == 10 || e.which == 13) {
$("button").click();
}
});
$("button").click(() => {
let cid = $("#cid-box").val();
let passcode = $("#passcode-box").val();
if (Number.isInteger(parseInt(cid))) {
window.location.replace("{% url 'atlas:collection_case_view_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).")
}
});
});
</script>
{% endif %}
+1 -1
View File
@@ -18,7 +18,7 @@ urlpatterns = [
path("collection/<int:pk>/delete", views.CaseCollectionDelete.as_view(), name="collection_delete"),
path("collection/<int:pk>/update", views.CaseCollectionUpdate.as_view(), name="collection_update"),
path("collection/<int:pk>", views.collection_detail_view, name="collection_detail_view"),
path("collection/<int:pk>/take/<int:cid>/<str:passcode>", views.collection_detail_view_take, name="collection_detail_view_take"),
#path("collection/<int:pk>/take/<int:cid>/<str:passcode>", views.collection_detail_view_take, name="collection_detail_view_take"),
path("collection/<int:pk>/<int:case_number>", views.collection_case_view, name="collection_case_view"),
path("collection/<int:pk>/<int:case_number>/take/<int:cid>/<str:passcode>", views.collection_case_view_take, name="collection_case_view_take"),
path("condition/", views.ConditionView.as_view(), name="condition_view"),
+6 -6
View File
@@ -1050,12 +1050,12 @@ def collection_detail_view(request, pk):
request, "atlas/collection_detail_view.html", {"collection": collection}
)
def collection_detail_view_take(request, pk, cid, passcode):
collection = get_object_or_404(CaseCollection, pk=pk)
return render(
request, "atlas/collection_detail_view.html", {"collection": collection}
)
#def collection_detail_view_take(request, pk, cid, passcode):
# collection = get_object_or_404(CaseCollection, pk=pk)
#
# return render(
# request, "atlas/collection_detail_view.html", {"collection": collection}
# )
def collection_case_view_take(request, pk, case_number, cid, passcode):
return collection_case_view(request, pk, case_number, True, cid, passcode)