This commit is contained in:
Ross
2022-01-03 16:47:31 +00:00
parent d5a0582572
commit 4a5083180f
2 changed files with 61 additions and 106 deletions
+4 -2
View File
@@ -22,11 +22,13 @@
Open access: {{ exam.open_access }}<br /> Open access: {{ exam.open_access }}<br />
<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 %} data-posturl="{% url 'anatomy:exam_toggle_active' pk=exam.pk %}"> <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 %} data-posturl="{% url 'anatomy:exam_toggle_active' pk=exam.pk %}">
<span class="help-text">[When checked the exam will be available to take in the test system]</span>
</div> </div>
{% if exam.exam_mode %} {% if exam.exam_mode %}
<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" data-posturl="{% url 'anatomy:exam_toggle_results_published' pk=exam.pk %}" Publish results: <input type="checkbox" id="exam-publish-results-switch" data-posturl="{% url 'anatomy:exam_toggle_results_published' pk=exam.pk %}"
{% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will be available to users on this site]</span> {% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will be available to users on this site]</span>
</div> </div>
<p><a href="{% url 'anatomy:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p> <p><a href="{% url 'anatomy:mark_overview' pk=exam.pk %}"><button>Mark exam</button></a></p>
+56 -103
View File
@@ -2,113 +2,66 @@
{% block content %} {% block content %}
{% load thumbnail %} {% load thumbnail %}
<div class="physics"> <div class="physics">
{% if can_edit %} {% if can_edit %}
<a href="{% url 'physics:exam_update' exam.id %}" title="Edit the Exam">Edit</a> <a href="{% url 'physics:exam_update' exam.id %}" title="Edit the Exam">Edit</a>
<a href="{% url 'physics:exam_delete' exam.id %}" title="Delete the Exam">Delete</a> <a href="{% url 'physics:exam_delete' exam.id %}" title="Delete the Exam">Delete</a>
<a href="{% url 'physics:exam_clone' exam.id %}" title="Clone the Exam">Clone</a> <a href="{% url 'physics:exam_clone' exam.id %}" title="Clone the Exam">Clone</a>
{% endif %} {% endif %}
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
<a href="{% url 'admin:physics_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin Edit</a> <a href="{% url 'admin:physics_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin
{% endif %} Edit</a>
<h1>Exam: {{ exam.name }}</h1> {% endif %}
<h1>Exam: {{ exam.name }}</h1>
{% include 'exam_notes.html' %} {% include 'exam_notes.html' %}
<p>This exam has {{question_number}} questions.</p> <p>This exam has {{question_number}} questions.</p>
Open access: {{ exam.open_access }}<br /> Open access: {{ exam.open_access }}<br />
<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>
This exam will be available to take <a href="{% url 'physics:exam_start' pk=exam.pk %}">here</a> (when active).
{% autoescape off %}
<ol id="full-question-list-physics">
{% for question in questions.all %}
<li>
{{ question.stem }}
<ol type="a" class="abcde">
<li>
{{ question.a }}: {{ question.a_answer }}
</li>
<li>
{{ question.b }}: {{ question.b_answer }}
</li>
<li>
{{ question.c }}: {{ question.c_answer }}
</li>
<li>
{{ question.d }}: {{ question.d_answer }}
</li>
<li>
{{ question.e }}: {{ question.e_answer }}
</li>
</ol>
Category: {{ question.category }}, <a href="{% url 'physics:question_detail' pk=question.pk %}">View</a> <a href="{% url 'admin:physics_question_change' question.id %}">Edit</a>
</li>
{% endfor %}
</ol>
{% endautoescape %}
<div class="parent-help" title="Click to enable / disable the exam">
Exam active: <input type="checkbox" id="exam-active-switch" data-posturl="{% url 'physics:exam_toggle_active' pk=exam.pk %}"
{% 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>
<script type="text/javascript"> <div class="parent-help" title="Click to enable / disable the exam results">
$(document).ready(function () { Publish results: <input type="checkbox" id="exam-publish-results-switch" data-posturl="{% url 'physics:exam_toggle_results_published' pk=exam.pk %}"
// send request to change the is_private state on customSwitches toggle {% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will
$("#exam-active-switch").on("change", function () { be available on this site]</span>
$.ajax({ </div>
url: "{% url 'physics:exam_toggle_active' pk=exam.pk %}", This exam will be available to take <a href="{% url 'physics:exam_start' pk=exam.pk %}">here</a> (when active).
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") { {% autoescape off %}
toastr.info('Exam state changed.') <ol id="full-question-list-physics">
} {% for question in questions.all %}
// 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 'physics: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") { <li>
toastr.info('Publish results state changed.') {{ question.stem }}
} <ol type="a" class="abcde">
// show some message according to the response. <li>
// For eg. A message box showing that the status has been changed {{ question.a }}: {{ question.a_answer }}
}) </li>
.always(function () { <li>
console.log('[Done]'); {{ question.b }}: {{ question.b_answer }}
}) </li>
}) <li>
}); {{ question.c }}: {{ question.c_answer }}
</script> </li>
<li>
{{ question.d }}: {{ question.d_answer }}
</li>
<li>
{{ question.e }}: {{ question.e_answer }}
</li>
</ol>
Category: {{ question.category }}, <a href="{% url 'physics:question_detail' pk=question.pk %}">View</a> <a
href="{% url 'admin:physics_question_change' question.id %}">Edit</a>
</li>
{% endfor %}
</ol>
{% endautoescape %}
</div>
{% endblock %} {% endblock %}