This commit is contained in:
Ross
2021-05-14 20:15:45 +01:00
parent de0792cb54
commit 77ddc7b4b1
2 changed files with 13 additions and 12 deletions
@@ -62,14 +62,15 @@
// send request to change the is_private state on customSwitches toggle
$(".proposed-answer").each((n, el) => {
$(el).append("<span>SAVE</span>").on("click", function () {
$(el).append("<span class='confirm'>[Confirm]</span>").on("click", function () {
$.ajax({
url: "{% url 'answer_suggestion_confirm' %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
//active: this.checked // true if checked else false
question_type: "rapid",
aid: el.dataset.aid
},
body: JSON.stringify({ question_type: "rapid", aid: el.dataset.aid}),
type: "POST",
dataType: "json",
})
@@ -77,8 +78,10 @@
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Exam state changed.')
if (data.success) {
toastr.info('Answer saved')
$(el).find(".confirm").remove()
$(el).removeClass("proposed-answer")
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed