This commit is contained in:
Ross
2021-12-12 12:47:49 +00:00
parent 0e26d641d8
commit 85b3030e38
5 changed files with 34 additions and 25 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ CID: {{cid}}
{{answer_count}} out of {{exam_length}} questions answered. Click to go to question. {{answer_count}} out of {{exam_length}} questions answered. Click to go to question.
<div class="sba-finish-list"> <div class="sba-finish-list">
{% for question, answer in question_answer_tuples %} {% for question, answer in question_answer_tuples %}
<a href="{% url 'sbas: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 'sbas: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 %} {% endfor %}
</div> </div>
-1
View File
@@ -28,7 +28,6 @@
{% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will {% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will
be available on this site]</span> be available on this site]</span>
</div> </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 'sbas:exam_start' pk=exam.pk %}">here</a> (when active). This exam will be available to take <a href="{% url 'sbas:exam_start' pk=exam.pk %}">here</a> (when active).
{% autoescape off %} {% autoescape off %}
+1 -1
View File
@@ -7,7 +7,7 @@
Answers: Answers:
<ul> <ul>
{% for question, a, score, correct_answer in answers_and_marks %} {% for question, a, score, correct_answer in answers_and_marks %}
<li class="user-answer-li"><a href="{% url 'sbas:exam_take' exam.pk forloop.counter0 cid %}">Question <li class="user-answer-li"><a href="{% url 'sbas:exam_take' exam.pk forloop.counter0 cid passcode %}">Question
{{forloop.counter}}</a> - {{ question.stem |safe}}</li> {{forloop.counter}}</a> - {{ question.stem |safe}}</li>
<span>Correct answer: {{correct_answer|safe}} <br />{{a}} <span class="answer-{{score}}">(Score: <span>Correct answer: {{correct_answer|safe}} <br />{{a}} <span class="answer-{{score}}">(Score:
{{score}})</span></span> {{score}})</span></span>
+14 -4
View File
@@ -2,20 +2,30 @@
{% block content %} {% block content %}
<h2>{{exam.name}}</h2> <h2>Start exam: {{exam.name}}</h2>
Enter your CID in the below box.<br /> Enter your CID and passcode in the below boxes.<br />
<input id="cid-box" type="text" value="Candidate ID"> <p><input id="cid-box" type="text" value="Candidate ID"></p>
<p><input id="passcode-box" type="text" value="Passcode"></p>
<button>Start exam</button> <button>Start exam</button>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$("#cid-box, #passcode-box").keypress(function(e) {
// Enter pressed?
console.log(e)
if(e.which == 10 || e.which == 13) {
$("button").click();
}
});
$("button").click(() => { $("button").click(() => {
let cid = $("#cid-box").val(); let cid = $("#cid-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' %}".replace("0000000", cid)); window.location.replace("{% url 'sbas:exam_take' pk=exam.pk sk=0 cid='0000000' passcode='ZZZZZZ' %}".replace("0000000", cid).replace("ZZZZZZ", passcode));
} else { } else {
alert("Please enter a valid Candidate ID (CID).") alert("Please enter a valid Candidate ID (CID).")
} }