Refactor exam start template for improved readability and URL handling
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h2>Start exam: {{exam}}</h2>
|
<h2>Start exam: {{ exam }}</h2>
|
||||||
|
|
||||||
{% if exam.time_limit %}
|
{% 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/>
|
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();
|
let passcode = $("#passcode-box").val();
|
||||||
|
|
||||||
if (Number.isInteger(parseInt(cid))) {
|
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 {
|
} else {
|
||||||
alert("Please enter a valid Candidate ID (CID).")
|
alert("Please enter a valid Candidate ID (CID).")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user