141 lines
5.9 KiB
HTML
141 lines
5.9 KiB
HTML
{% extends 'rapids/exams.html' %}
|
|
|
|
{% block content %}
|
|
|
|
{% load thumbnail %}
|
|
<div class="rapids">
|
|
<a href="{% url 'admin:rapids_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin Edit</a>
|
|
<h1>Exam: {{ exam.name }}</h1>
|
|
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.
|
|
|
|
<div class="parent-help" title="Click to enable / disable the exam">
|
|
Exam active: <input type="checkbox" id="exam-active-switch" {% if exam.active %}checked{% endif %}> <span class="help-text">[When checked the exam will be available to take in the test system]</span>
|
|
</div>
|
|
<div class="parent-help" title="Click to enable / disable the exam results">
|
|
Publish results: <input type="checkbox" id="exam-publish-results-switch" {% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will be available on this site]</span>
|
|
</div>
|
|
<p><a href="{% url 'rapids:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
|
|
|
|
<ol id="full-question-list">
|
|
{% for question in questions.all %}
|
|
|
|
<li>
|
|
{% for image in question.GetImages %}
|
|
<img src="{{ image|thumbnail_url:'exam-list' }}" alt="thumbail" />
|
|
{% endfor %}
|
|
{% if not question.normal %}
|
|
<b>Abnormality:</b> {{ question.get_abnormalities }} <b>Region:</b> {{ question.get_regions }}
|
|
<br />
|
|
{{ question.GetPrimaryAnswer }}
|
|
{% else %}
|
|
<b>Normal</b>
|
|
{% endif %}
|
|
<br />
|
|
Examination: {{ question.get_examinations }}, <a href="{% url 'rapids:exam_question_detail' pk=exam.pk sk=forloop.counter0 %}">View</a>, <a href="{% url 'rapids:mark' pk=exam.pk sk=forloop.counter0 %}">Mark</a>
|
|
</li>
|
|
{% endfor %}
|
|
</ol>
|
|
<a href="{% url 'rapids:exam_json' pk=exam.pk %}">JSON</a>
|
|
<a href="{% url 'rapids:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a>
|
|
<button id='button-open-access'>Make questions open access</button>
|
|
<button id='button-closed-access'>Make questions closed access</button>
|
|
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
// send request to change the is_private state on customSwitches toggle
|
|
$("#exam-active-switch").on("change", function () {
|
|
$.ajax({
|
|
url: "{% url 'rapids:exam_toggle_active' pk=exam.pk %}",
|
|
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]');
|
|
})
|
|
})
|
|
$("#exam-publish-results-switch").on("change", function () {
|
|
$.ajax({
|
|
url: "{% url 'rapids:exam_toggle_results_published' pk=exam.pk %}",
|
|
data: {
|
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
|
publish_results: 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('Publish results 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]');
|
|
})
|
|
})
|
|
$("#button-open-access").click(function () {
|
|
$.ajax({
|
|
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
|
data: {
|
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
|
set_open_access: true,
|
|
},
|
|
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('Question access state changed.')
|
|
}
|
|
})
|
|
.always(function () {
|
|
console.log('[Done]');
|
|
})
|
|
})
|
|
$("#button-closed-access").click(function () {
|
|
$.ajax({
|
|
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
|
data: {
|
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
|
set_open_access: 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('Question access state changed.')
|
|
}
|
|
})
|
|
.always(function () {
|
|
console.log('[Done]');
|
|
})
|
|
})
|
|
});
|
|
</script>
|
|
{% endblock %} |