This commit is contained in:
Ross
2021-10-17 11:56:20 +01:00
parent 1b94bf6a9b
commit 70a26fcb51
+14 -15
View File
@@ -33,7 +33,7 @@
</div>
{% if exam.exam_mode %}
<div class="parent-help" title="Click to enable / disable the exam results">
Publish results: <input type="checkbox" id="exam-publish-results-switch"
Publish results: <input type="checkbox" id="exam-publish-results-switch" data-posturl="{% url 'rapids: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 on this site]</span>
</div>
@@ -72,7 +72,7 @@
{{ author }},
{% endfor %}
</div>
<p><button id='button-edit-order' title='click and drag questions to change order'>Edit question order / Delete questions</button></p>
<p><button id='button-edit-order' title='click and drag questions to change order' data-posturl="{% url 'rapids:exam_json_edit' pk=exam.pk %}">Edit question order / Delete questions</button></p>
<div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
JSON creation id: {{exam.exam_json_id}}
@@ -80,17 +80,16 @@
<a href="{% url 'rapids:exam_json' pk=exam.pk %}">JSON</a>
<a href="{% url 'rapids:exam_json_unbased' pk=exam.pk %}">JSON (unbased)</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>
<button id='button-open-access' data-posturl="{% url 'rapids:exam_json_edit' pk=exam.pk %}">Make questions open access</button>
<button id='button-closed-access' data-posturl="{% url 'rapids:exam_json_edit' pk=exam.pk %}">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 (el) {
console.log(el)
$("#exam-active-switch").on("change", function (evt) {
$.ajax({
url: "{% url 'rapids:exam_toggle_active' pk=exam.pk %}",
url: evt.currentTarget.dataset.posturl,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
active: this.checked // true if checked else false
@@ -112,9 +111,9 @@
console.log('[Done]');
})
})
$("#exam-publish-results-switch").on("change", function () {
$("#exam-publish-results-switch").on("change", function (evt) {
$.ajax({
url: "{% url 'rapids:exam_toggle_results_published' pk=exam.pk %}",
url: evt.currentTarget.dataset.posturl,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
publish_results: this.checked // true if checked else false
@@ -136,9 +135,9 @@
console.log('[Done]');
})
})
$("#button-open-access").click(function () {
$("#button-open-access").click(function (evt) {
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
url: evt.currentTarget.dataset.posturl,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: true,
@@ -164,9 +163,9 @@
console.log('[Done]');
})
})
$("#button-closed-access").click(function () {
$("#button-closed-access").click(function (evt) {
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
url: evt.currentTarget.dataset.posturl,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: false,
@@ -192,7 +191,7 @@
console.log('[Done]');
})
})
$("#button-edit-order").click(function () {
$("#button-edit-order").click(function (evt) {
$(this).remove();
sortable('.sortable');
@@ -204,7 +203,7 @@
new_order.push(el.dataset.question_pk)
})
$.ajax({
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
url: evt.currentTarget.dataset.posturl,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
set_exam_order: JSON.stringify(new_order),