This commit is contained in:
Ross
2021-08-17 18:13:25 +01:00
parent afaae40e48
commit 1bcfa722af
+58 -56
View File
@@ -15,8 +15,8 @@
class="help-text">[When checked the exam will be available to take in the test system]</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" Publish results: <input type="checkbox" id="exam-publish-results-switch" {% if exam.publish_results %}checked{%
{% if exam.publish_results %}checked{% endif %}> <span class="help-text">[When checked the exam results will endif %}> <span class="help-text">[When checked the exam results will
be available on this site]</span> be available on this site]</span>
</div> </div>
{% endif %} {% endif %}
@@ -26,11 +26,21 @@
{% for question in questions.all %} {% for question in questions.all %}
<li data-question_pk={{question.pk}}> <li data-question_pk={{question.pk}}>
Description: {{ question.description}} <span>
<br /> Description: {{ question.description}}
History: {{ question.history}} <br />
<br /> History: {{ question.history}}
{% for series in question.series.all %} <br />
{% for series in question.series.all %}
<div>
Author(s): {{question.get_authors}}
</div>
<div>
<a href="{% url 'longs:exam_question_detail' exam.id forloop.counter0 %}"
title="View the question">View</a> / <a href="{% url 'longs:long_update' question.id %}"
title="Edit the question">Edit</a>
</div>
</span>
<div class="series-block"> <div class="series-block">
Series {{forloop.counter }}:<br /> Series {{forloop.counter }}:<br />
{{series.get_block}} {{series.get_block}}
@@ -38,14 +48,6 @@
{% empty %} {% empty %}
No series No series
{% endfor %} {% endfor %}
<div>
Author(s): {{question.get_authors}}
</div>
<div>
<a href="{% url 'longs:exam_question_detail' exam.id forloop.counter0 %}"
title="View the question">View</a> / <a href="{% url 'longs:long_update' question.id %}"
title="Edit the question">Edit</a>
</div>
</li> </li>
{% endfor %} {% endfor %}
</ol> </ol>
@@ -63,7 +65,7 @@
<a href="{% url 'longs:exam_json' pk=exam.pk %}">JSON</a> <a href="{% url 'longs:exam_json' pk=exam.pk %}">JSON</a>
<a href="{% url 'longs:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a> <a href="{% url 'longs:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a>
<a href="{% url 'longs:refresh_exam_question_json' pk=exam.pk %}">Refresh Question JSON cache</a> <a href="{% url 'longs:refresh_exam_question_json' pk=exam.pk %}">Refresh Question JSON cache</a>
<button id='button-open-access'>Make questions open access</button> <button id='button-open-access'>Make questions open access</button>
<button id='button-closed-access'>Make questions closed access</button> <button id='button-closed-access'>Make questions closed access</button>
@@ -73,14 +75,14 @@
// 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 'longs:exam_toggle_active' pk=exam.pk %}", url: "{% url 'longs: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);
@@ -97,14 +99,14 @@
}) })
$("#exam-publish-results-switch").on("change", function () { $("#exam-publish-results-switch").on("change", function () {
$.ajax({ $.ajax({
url: "{% url 'longs:exam_toggle_results_published' pk=exam.pk %}", url: "{% url 'longs: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);
@@ -121,14 +123,14 @@
}) })
$("#button-open-access").click(function () { $("#button-open-access").click(function () {
$.ajax({ $.ajax({
url: "{% url 'longs:exam_json_edit' pk=exam.pk %}", url: "{% url 'longs:exam_json_edit' pk=exam.pk %}",
data: { data: {
csrfmiddlewaretoken: "{{ csrf_token }}", csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: true, set_open_access: true,
}, },
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);
@@ -143,14 +145,14 @@
}) })
$("#button-closed-access").click(function () { $("#button-closed-access").click(function () {
$.ajax({ $.ajax({
url: "{% url 'longs:exam_json_edit' pk=exam.pk %}", url: "{% url 'longs:exam_json_edit' pk=exam.pk %}",
data: { data: {
csrfmiddlewaretoken: "{{ csrf_token }}", csrfmiddlewaretoken: "{{ csrf_token }}",
set_open_access: false, set_open_access: 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);
@@ -173,14 +175,14 @@
new_order.push(el.dataset.question_pk) new_order.push(el.dataset.question_pk)
}) })
$.ajax({ $.ajax({
url: "{% url 'longs:exam_json_edit' pk=exam.pk %}", url: "{% url 'longs:exam_json_edit' pk=exam.pk %}",
data: { data: {
csrfmiddlewaretoken: "{{ csrf_token }}", csrfmiddlewaretoken: "{{ csrf_token }}",
set_exam_order: JSON.stringify(new_order), set_exam_order: JSON.stringify(new_order),
}, },
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);