This commit is contained in:
Ross
2021-08-21 09:16:15 +01:00
parent 12d6ae1bf3
commit df381ea0ad
+33 -38
View File
@@ -8,10 +8,13 @@
This exam has {{question_number}} questions. This exam has {{question_number}} questions.
<div class="parent-help" title="Click to enable / disable the exam"> <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> 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>
<div class="parent-help" title="Click to enable / disable the exam results"> <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> 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> </div>
<!--<p><button><a href="{% url 'anatomy:exam_take' pk=exam.pk sk=0 %}">Click here to start</a></button></p>--> <!--<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).
@@ -21,26 +24,18 @@
{% for question in questions.all %} {% for question in questions.all %}
<li> <li>
<span>
{{ question.stem|safe }} {{ question.stem|safe }}
<ol type="a" class="abcde"> <ol type="a" class="abcde">
<li> <li> {{ question.a_answer|safe }} </li>
{{ question.a_answer|safe }} <li> {{ question.b_answer|safe }} </li>
</li> <li> {{ question.c_answer|safe }} </li>
<li> <li> {{ question.d_answer|safe }} </li>
{{ question.b_answer|safe }} <li> {{ question.e_answer|safe }} </li> Best answer : {{question.best_answer}}
</li> </ol>
<li> </span>
{{ question.c_answer|safe }} Category: {{ question.category }}, <a href="{% url 'sbas:question_detail' pk=question.pk %}">View</a> <a
</li> href="{% url 'admin:sbas_question_change' question.id %}">Edit</a>
<li>
{{ question.d_answer|safe }}
</li>
<li>
{{ question.e_answer|safe }}
</li>
Best answer : {{question.best_answer}}
</ol>
Category: {{ question.category }}, <a href="{% url 'sbas:question_detail' pk=question.pk %}">View</a> <a href="{% url 'admin:sbas_question_change' question.id %}">Edit</a>
</li> </li>
{% endfor %} {% endfor %}
@@ -53,20 +48,20 @@
// send request to change the is_private state on customSwitches toggle // send request to change the is_private state on customSwitches toggle
$("#exam-active-switch").on("change", function () { $("#exam-active-switch").on("change", function () {
$.ajax({ $.ajax({
url: "{% url 'sbas:exam_toggle_active' pk=exam.pk %}", url: "{% url 'sbas:exam_toggle_active' pk=exam.pk %}",
data: { data: {
csrfmiddlewaretoken: "{{ csrf_token }}", csrfmiddlewaretoken: "{{ csrf_token }}",
active: this.checked // true if checked else false active: this.checked // true if checked else false
}, },
type: "POST", type: "POST",
dataType: "json", dataType: "json",
}) })
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) { .done(function (data) {
console.log(data); console.log(data);
if (data.status == "success") { if (data.status == "success") {
toastr.info('Exam state changed.') toastr.info('Exam state changed.')
} }
// show some message according to the response. // show some message according to the response.
// For eg. A message box showing that the status has been changed // For eg. A message box showing that the status has been changed
@@ -77,20 +72,20 @@
}) })
$("#exam-publish-results-switch").on("change", function () { $("#exam-publish-results-switch").on("change", function () {
$.ajax({ $.ajax({
url: "{% url 'sbas:exam_toggle_results_published' pk=exam.pk %}", url: "{% url 'sbas:exam_toggle_results_published' pk=exam.pk %}",
data: { data: {
csrfmiddlewaretoken: "{{ csrf_token }}", csrfmiddlewaretoken: "{{ csrf_token }}",
publish_results: this.checked // true if checked else false publish_results: this.checked // true if checked else false
}, },
type: "POST", type: "POST",
dataType: "json", dataType: "json",
}) })
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) { .done(function (data) {
console.log(data); console.log(data);
if (data.status == "success") { if (data.status == "success") {
toastr.info('Publish results state changed.') toastr.info('Publish results state changed.')
} }
// show some message according to the response. // show some message according to the response.
// For eg. A message box showing that the status has been changed // For eg. A message box showing that the status has been changed