more fixes

This commit is contained in:
Ross
2020-12-27 11:41:40 +00:00
parent 57b05da029
commit ccf92c0632
5 changed files with 68 additions and 38 deletions
+4
View File
@@ -25,6 +25,10 @@
{% endfor %}
</ul>
<p>Active exams will be available to take at the below url:
<a href="{% url 'physics:active_exams' %}">Available exams</a>
</p>
</div>
{% endblock %}
+50 -33
View File
@@ -5,13 +5,25 @@
<div class="physics">
<h1>Exam: {{ exam.name }}</h1>
<div class="alert alert-info" role="alert">
<h3>Instructions</h3>
<p>
Please make sure you submit answers before closing or navigating from this page (as otherwise they will not
be saved). The submit button is at the bottom of the page.
</p>
<p>
Click on a question to toggle between true / false.
</p>
<p>
Ensure your candidate number is entered in the below box.
</p>
</div>
<div>
Candidate number: <input type="number" id="cid" name="cid" title="please enter your candidate number">
</div>
<p>
Please make sure you submit answers before closing or navigating from this page (as otherwise they will not be
saved)
</p>
<h2>Questions</h2>
{% autoescape off %}
<ol id="full-question-list-physics">
@@ -22,31 +34,36 @@
<ol type="a" class="abcde">
<li>
<span class="question-text">{{ question.a }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question a" id="{{question.pk}}-a-checkbox" data-q="{{question.pk}}" data-a="a">
type="checkbox" class="question a" id="{{question.pk}}-a-checkbox" data-q="{{question.pk}}"
data-a="a">
<div class="slider round a"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.b }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question b" id="{{question.pk}}-b-checkbox" data-q="{{question.pk}}" data-a="b">
type="checkbox" class="question b" id="{{question.pk}}-b-checkbox" data-q="{{question.pk}}"
data-a="b">
<div class="slider round b"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.c }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question c" id="{{question.pk}}-c-checkbox" data-q="{{question.pk}}" data-a="c">
type="checkbox" class="question c" id="{{question.pk}}-c-checkbox" data-q="{{question.pk}}"
data-a="c">
<div class="slider round c"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.d }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question d" id="{{question.pk}}-d-checkbox" data-q="{{question.pk}}" data-a="d">
type="checkbox" class="question d" id="{{question.pk}}-d-checkbox" data-q="{{question.pk}}"
data-a="d">
<div class="slider round d"></div>
</label>
</li>
<li>
<span class="question-text">{{ question.e }}:</span> <label class="truefalse-switch"> <input
type="checkbox" class="question e" id="{{question.pk}}-e-checkbox" data-q="{{question.pk}}" data-a="e">
type="checkbox" class="question e" id="{{question.pk}}-e-checkbox" data-q="{{question.pk}}"
data-a="e">
<div class="slider round e"></div>
</label>
</li>
@@ -71,7 +88,7 @@
$(evt.target).parent().find("input").click();
});
$("#submit").click(() =>{
$("#submit").click(() => {
let cid = $("#cid").val()
if (cid == "") {
alert("You need to enter a valid candidate number.");
@@ -106,31 +123,31 @@
}
}
function postAnswers(ans) {
console.log(ans);
$.post("{% url 'physics:exam_answers_submit' %}", JSON.stringify(ans)).done((data) => {
console.log(data);
if (data.success) {
let ret = confirm(
`Answers sucessfully submitted. Click OK to finish the exam.`
);
function postAnswers(ans) {
console.log(ans);
$.post("{% url 'physics:exam_answers_submit' %}", JSON.stringify(ans)).done((data) => {
console.log(data);
if (data.success) {
let ret = confirm(
`Answers sucessfully submitted. Click OK to finish the exam.`
);
if (ret) {
//window.saveSession();
$("#exams-button-link").remove();
$("#submit").after('<button id="exams-button-link">Return to exam list</button>');
$("#exams-button-link").click(() => {
window.location.href = "{% url 'physics:active_exams' %}";
})
window.answers_submitted = true;
} else {
}
} else {
alert(`Error submitting answers: ${data.error}`);
if (ret) {
//window.saveSession();
$("#exams-button-link").remove();
$("#submit").after('<button id="exams-button-link">Return to exam list</button>');
$("#exams-button-link").click(() => {
window.location.href = "{% url 'physics:active_exams' %}";
})
window.answers_submitted = true;
} else {
}
} else {
alert(`Error submitting answers: ${data.error}`);
}
});
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
}
});
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
}
</script>