.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
{% extends 'rapids/exams.html' %}
|
{% extends 'rapids/exams.html' %}
|
||||||
{% extends 'exam_overview_js.html' %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
@@ -85,4 +84,5 @@
|
|||||||
<button id='button-closed-access' data-posturl="{% url 'rapids:exam_json_edit' pk=exam.pk %}">Make questions closed access</button>
|
<button id='button-closed-access' data-posturl="{% url 'rapids:exam_json_edit' pk=exam.pk %}">Make questions closed access</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{% includes 'exam_overview_js.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
{% block js %}
|
<script type="text/javascript">
|
||||||
<script type="text/javascript">
|
$(document).ready(function () {
|
||||||
$(document).ready(function () {
|
// 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 (evt) {
|
||||||
$("#exam-active-switch").on("change", function (evt) {
|
$.ajax({
|
||||||
$.ajax({
|
url: evt.currentTarget.dataset.posturl,
|
||||||
url: evt.currentTarget.dataset.posturl,
|
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") {
|
||||||
@@ -22,22 +21,22 @@
|
|||||||
// 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
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
$("#exam-publish-results-switch").on("change", function (evt) {
|
||||||
|
$.ajax({
|
||||||
|
url: evt.currentTarget.dataset.posturl,
|
||||||
|
data: {
|
||||||
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
|
publish_results: this.checked // true if checked else false
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
})
|
})
|
||||||
$("#exam-publish-results-switch").on("change", function (evt) {
|
|
||||||
$.ajax({
|
|
||||||
url: evt.currentTarget.dataset.posturl,
|
|
||||||
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
|
// $.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") {
|
||||||
@@ -46,22 +45,22 @@
|
|||||||
// 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
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
$("#button-open-access").click(function (evt) {
|
||||||
|
$.ajax({
|
||||||
|
url: evt.currentTarget.dataset.posturl,
|
||||||
|
data: {
|
||||||
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
|
set_open_access: true,
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
})
|
})
|
||||||
$("#button-open-access").click(function (evt) {
|
|
||||||
$.ajax({
|
|
||||||
url: evt.currentTarget.dataset.posturl,
|
|
||||||
data: {
|
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
|
||||||
set_open_access: true,
|
|
||||||
},
|
|
||||||
type: "POST",
|
|
||||||
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") {
|
||||||
@@ -71,25 +70,25 @@
|
|||||||
toastr.info(data.status);
|
toastr.info(data.status);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail((e) => {
|
.fail((e) => {
|
||||||
toastr.warning(`Error, ${e}`);
|
toastr.warning(`Error, ${e}`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
$("#button-closed-access").click(function (evt) {
|
||||||
|
$.ajax({
|
||||||
|
url: evt.currentTarget.dataset.posturl,
|
||||||
|
data: {
|
||||||
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
|
set_open_access: false,
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
})
|
})
|
||||||
$("#button-closed-access").click(function (evt) {
|
|
||||||
$.ajax({
|
|
||||||
url: evt.currentTarget.dataset.posturl,
|
|
||||||
data: {
|
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
|
||||||
set_open_access: false,
|
|
||||||
},
|
|
||||||
type: "POST",
|
|
||||||
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") {
|
||||||
@@ -99,49 +98,47 @@
|
|||||||
toastr.info(data.status);
|
toastr.info(data.status);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail((e) => {
|
.fail((e) => {
|
||||||
toastr.warning(`Error, ${e}`);
|
toastr.warning(`Error, ${e}`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
$("#button-edit-order").click(function (evt) {
|
$("#button-edit-order").click(function (evt) {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
sortable('.sortable');
|
sortable('.sortable');
|
||||||
|
|
||||||
$("#full-question-list").append($(
|
$("#full-question-list").append($(
|
||||||
"<button title='click and drag questions to change order'>Save exam order</button>"
|
"<button title='click and drag questions to change order'>Save exam order</button>"
|
||||||
).click(() => {
|
).click(() => {
|
||||||
new_order = [];
|
new_order = [];
|
||||||
$("#full-question-list li").each((n, el) => {
|
$("#full-question-list li").each((n, el) => {
|
||||||
new_order.push(el.dataset.question_pk)
|
new_order.push(el.dataset.question_pk)
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: evt.currentTarget.dataset.posturl,
|
url: evt.currentTarget.dataset.posturl,
|
||||||
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);
|
||||||
|
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
toastr.info('Exam order changed.')
|
toastr.info('Exam order changed.')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
{% endblock js %}
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user