This commit is contained in:
Ross
2021-08-19 12:51:07 +01:00
parent d666a3bf5c
commit 70069fc58d
+42 -3
View File
@@ -1,15 +1,22 @@
{% extends 'rapids/base.html' %}
{% block content %}
<div id="single-dicom-viewer" class="rapid-dicom-viewer" data-images="" data-annotations=''>
<div class="question-display-block">
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
</div>
<div>Answers: </div>
</div>
<div class="rapids">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Answers:
<ul>{% for ans, score, correct_answer in answers_and_marks %}
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span class="correct-answer">{{ correct_answer }}</span></li>
<span class="user-answer-score user-answer-score-{{score}} rapid-ans"><pre>{{ans}}</pre> ({{score}})</span>
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span class="correct-answer">{{
correct_answer }}</span></li>
<span class="user-answer-score user-answer-score-{{score}} rapid-ans">
<pre>{{ans}}</pre> ({{score}})
</span>
<span class="view-question-link" data-qn="{{forloop.counter0}}">View</span>
{% endfor %}
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
@@ -17,4 +24,36 @@
<a href="{% url 'cid_scores' cid %}">Other exams</a>
</div>
</div>
{% endblock %}
{% block js %}
<script>
$(document).ready(function () {
$(".view-question-link").on("click", function (e) {
question_number = e.currentTarget.dataset.qn;
$.ajax({
url: `{% url 'rapids:question_review' pk=exam.pk sk=${question_number} %}`,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
active: this.checked // true if checked else false
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Exam state changed.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
})
});
</script>
{% endblock %}