Refactor exam start template for improved readability and URL handling

This commit is contained in:
Ross
2026-02-02 16:51:56 +00:00
parent a0850c0030
commit 168a4126d3
+5 -2
View File
@@ -2,7 +2,7 @@
{% block content %}
<h2>Start exam: {{exam}}</h2>
<h2>Start exam: {{ exam }}</h2>
{% if exam.time_limit %}
This exam has a time limit of {{ exam.get_time_limit }}. The time will start when you click the Start Exam button below.<br/>
@@ -44,7 +44,10 @@
let passcode = $("#passcode-box").val();
if (Number.isInteger(parseInt(cid))) {
window.location.replace("{% url 'sbas:exam_take' pk=exam.pk sk=0 cid='0000000' passcode='ZZZZZZ' %}".replace("0000000", cid).replace("ZZZZZZ", passcode));
// reverse a URL with safe placeholders and replace them client-side
const template = "{% url 'sbas:exam_take' pk=exam.pk sk=0 cid=0 passcode='0' %}"; // e.g. /sbas/exam/1/0/0/0/take
const url = template.replace('/0/0/take', `/${cid}/${passcode}/take`);
window.location.replace(url);
} else {
alert("Please enter a valid Candidate ID (CID).")
}