Date: Wed, 7 Jul 2021 17:10:31 +0100
Subject: [PATCH 17/53] .
---
rapids/templates/rapids/question_display_block.html | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index a09ce9b6..228477e3 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -31,8 +31,7 @@
Scrapped: {{ question.scrapped }} (toggle)
Answers (score): {% for answer in question.answers.all %}
-
+
{{ answer }} ({{answer.status}}),
{% endfor %}
From 1bfb480f52fcef9f7768b3a42bc3f89e017aea24 Mon Sep 17 00:00:00 2001
From: Ross
Date: Wed, 7 Jul 2021 17:14:02 +0100
Subject: [PATCH 18/53] .
---
rad/views.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/rad/views.py b/rad/views.py
index 1ae8df0e..ca9a57d1 100644
--- a/rad/views.py
+++ b/rad/views.py
@@ -251,11 +251,10 @@ def answer_suggestion_submit(request):
@login_required
def answer_submit(request):
if request.is_ajax and request.method == "POST":
- post_data = json.loads(request.body)
- qid = post_data["qid"]
- question_type = post_data["question_type"]
- answer_string = post_data["answer"]
- status = post_data["status"]
+ qid = request.POST.get("qid")
+ question_type = request.POST.get("question_type")
+ answer_string = request.POST.get("answer")
+ status = request.POST.get("status")
if str(status) not in "012":
return JsonResponse({"success": False, "error": "Invalid status"})
From d40fec3e6a14a9fb7ea33891af12c3addcceb611 Mon Sep 17 00:00:00 2001
From: Ross
Date: Wed, 7 Jul 2021 18:04:05 +0100
Subject: [PATCH 19/53] .
---
rad/views.py | 1 +
rapids/templates/rapids/question_display_block.html | 7 +++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/rad/views.py b/rad/views.py
index ca9a57d1..2b858214 100644
--- a/rad/views.py
+++ b/rad/views.py
@@ -275,6 +275,7 @@ def answer_submit(request):
a = AnswerModel(question=q, answer=answer_string, status=status)
a.save()
+ return JsonResponse({"success": True, "error": "Answer added"})
return JsonResponse({"success": False, "error": "Invalid data"})
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index 228477e3..7e486896 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -121,7 +121,7 @@
$(".proposed-answer").each((n, el) => {
// Add button to confirm answer is correct
- $(el).append($("[Correct]").on("click", function () {
+ $(el).append($("[Add Correct]").on("click", function () {
$.ajax({
url: "{% url 'answer_suggestion_confirm' %}",
data: {
@@ -139,9 +139,8 @@
console.log(data);
if (data.success) {
- toastr.info('Answer saved')
- $(el).find(".confirm").remove()
- $(el).removeClass("proposed-answer")
+ toastr.info('Answer added')
+ $(el).find(".correct").remove()
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
From 5181e4e20e967db8852cfc97318bc0bf40122e5d Mon Sep 17 00:00:00 2001
From: Ross
Date: Wed, 7 Jul 2021 18:11:30 +0100
Subject: [PATCH 20/53] .
---
rapids/models.py | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/rapids/models.py b/rapids/models.py
index b76ebd0b..f29c6934 100644
--- a/rapids/models.py
+++ b/rapids/models.py
@@ -307,12 +307,25 @@ class Rapid(models.Model):
#def GetNonFeedbackQuestionImages(self):
#return self.get_images()
+ def get_laterality_string(self):
+ if self.laterality == self.NONE:
+ s = ""
+ elif self.laterality == self.BILATERAL:
+ s = "bilateral "
+ elif self.laterality == self.RIGHT:
+ s = "right "
+ elif self.laterality == self.LEFT:
+ s = "left "
+
+ return s
+
def get_suggested_answers(self):
answers = []
for r in self.region.all():
+ laterality = self.get_laterality_string()
for a in self.abnormality.all():
- answers.append("{} {}".format(r.name, a.name))
- answers.append("{} {}".format(a.name, r.name))
+ answers.append("{}{} {}".format(laterality, r.name, a.name))
+ answers.append("{} {}{}".format(a.name, laterality, r.name))
compare_answers = self.get_compare_answers()
From 2c76fd7156fc168e9b0d7f646159269f93489a20 Mon Sep 17 00:00:00 2001
From: Ross
Date: Wed, 7 Jul 2021 18:13:52 +0100
Subject: [PATCH 21/53] .
---
rapids/templates/rapids/question_display_block.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index 7e486896..8e177e5b 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -84,7 +84,7 @@
$(document).ready(function () {
$(".suggested_answers li").each((n, el) => {
- $(el).append($("[Correct]").on("click", function () {
+ $(el).append($("[Add Correct]").on("click", function () {
$.ajax({
url: "{% url 'answer_submit' %}",
data: {
@@ -105,7 +105,6 @@
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
@@ -139,8 +138,9 @@
console.log(data);
if (data.success) {
- toastr.info('Answer added')
+ toastr.info('Answer saved')
$(el).find(".correct").remove()
+ $(el).removeClass("proposed-answer")
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
From fafe5eccaf27dcf3ac4b65b85907ad0a6a470218 Mon Sep 17 00:00:00 2001
From: Ross
Date: Wed, 7 Jul 2021 18:14:26 +0100
Subject: [PATCH 22/53] .
---
rapids/templates/rapids/question_display_block.html | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index 8e177e5b..742415d5 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -84,7 +84,7 @@
$(document).ready(function () {
$(".suggested_answers li").each((n, el) => {
- $(el).append($("[Add Correct]").on("click", function () {
+ $(el).append($("[Add Correct]").on("click", function () {
$.ajax({
url: "{% url 'answer_submit' %}",
data: {
@@ -104,7 +104,7 @@
if (data.success) {
toastr.info('Answer saved')
- $(el).find(".confirm").remove()
+ $(el).find(".correct").remove()
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
@@ -120,7 +120,7 @@
$(".proposed-answer").each((n, el) => {
// Add button to confirm answer is correct
- $(el).append($("[Add Correct]").on("click", function () {
+ $(el).append($("[Add Correct]").on("click", function () {
$.ajax({
url: "{% url 'answer_suggestion_confirm' %}",
data: {
@@ -139,7 +139,7 @@
if (data.success) {
toastr.info('Answer saved')
- $(el).find(".correct").remove()
+ $(el).find(".confirm").remove()
$(el).removeClass("proposed-answer")
}
// show some message according to the response.
From aca4c7fa2871a3068bf009f5b4d0845472a94f64 Mon Sep 17 00:00:00 2001
From: Ross
Date: Thu, 8 Jul 2021 14:44:36 +0100
Subject: [PATCH 23/53] .
---
rapids/models.py | 2 +
.../rapids/question_display_block.html | 203 +++++++++---------
2 files changed, 104 insertions(+), 101 deletions(-)
diff --git a/rapids/models.py b/rapids/models.py
index f29c6934..65542bd9 100644
--- a/rapids/models.py
+++ b/rapids/models.py
@@ -326,6 +326,8 @@ class Rapid(models.Model):
for a in self.abnormality.all():
answers.append("{}{} {}".format(laterality, r.name, a.name))
answers.append("{} {}{}".format(a.name, laterality, r.name))
+ answers.append("{} {}".format(r.name, a.name))
+ answers.append("{} {}".format(a.name, r.name))
compare_answers = self.get_compare_answers()
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index 742415d5..ae01fe14 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -31,7 +31,8 @@
Scrapped: {{ question.scrapped }} (toggle)
Answers (score): {% for answer in question.answers.all %}
-
+
{{ answer }} ({{answer.status}}),
{% endfor %}
@@ -69,8 +70,8 @@
{{ans}}
{% endfor %}
+
-
@@ -78,109 +79,109 @@
-
+
-
\ No newline at end of file
+ // send request to change the is_private state on customSwitches toggle
+ $(".proposed-answer").each((n, el) => {
+
+ // Add button to confirm answer is correct
+ $(el).append($("[Add Correct]").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,
+ status: 2,
+ },
+ type: "POST",
+ dataType: "json",
+ })
+ // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
+ .done(function (data) {
+ console.log(data);
+
+ 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
+ })
+ .always(function () {
+ console.log('[Done]');
+ })
+ }))
+
+ // Add button to confirm answer is incorrect
+ $(el).append($("[Incorrect]").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,
+ status: 0,
+ },
+ type: "POST",
+ dataType: "json",
+ })
+ // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
+ .done(function (data) {
+ console.log(data);
+
+ 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
+ })
+ .always(function () {
+ console.log('[Done]');
+ })
+ }))
+ });
+ });
+
+
\ No newline at end of file
From d3139baba7896a76cb2e83376b6d31b94ae38150 Mon Sep 17 00:00:00 2001
From: Ross
Date: Thu, 8 Jul 2021 14:52:56 +0100
Subject: [PATCH 24/53] .
---
.../rapids/question_display_block.html | 85 +++++++++----------
1 file changed, 42 insertions(+), 43 deletions(-)
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index ae01fe14..65e0d003 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -29,14 +29,14 @@
Checked by: {% for verified in question.verified.all %} {{verified}}, {% endfor %}
Scrapped: {{ question.scrapped }} (toggle)
-
- Answers (score): {% for answer in question.answers.all %}
-
- {{ answer }} ({{answer.status}}),
-
- {% endfor %}
-
+
+ Answers (score): {% for answer in question.answers.all %}
+
+ {{ answer }} ({{answer.status}}),
+
+ {% endfor %}
+
@@ -87,18 +87,18 @@
$(".suggested_answers li").each((n, el) => {
$(el).append($("
[Add Correct]").on("click", function () {
$.ajax({
- url: "{% url 'answer_submit' %}",
- data: {
- csrfmiddlewaretoken: "{{ csrf_token }}",
- //active: this.checked // true if checked else false
- question_type: "rapid",
- qid: "{{question.pk}}",
- status: 2,
- answer: el.dataset.string,
- },
- type: "POST",
- dataType: "json",
- })
+ url: "{% url 'answer_submit' %}",
+ data: {
+ csrfmiddlewaretoken: "{{ csrf_token }}",
+ //active: this.checked // true if checked else false
+ question_type: "rapid",
+ qid: "{{question.pk}}",
+ status: 2,
+ answer: el.dataset.string,
+ },
+ type: "POST",
+ dataType: "json",
+ })
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
@@ -123,17 +123,17 @@
// Add button to confirm answer is correct
$(el).append($("
[Add Correct]").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,
- status: 2,
- },
- type: "POST",
- dataType: "json",
- })
+ url: "{% url 'answer_suggestion_confirm' %}",
+ data: {
+ csrfmiddlewaretoken: "{{ csrf_token }}",
+ //active: this.checked // true if checked else false
+ question_type: "rapid",
+ aid: el.dataset.aid,
+ status: 2,
+ },
+ type: "POST",
+ dataType: "json",
+ })
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
@@ -154,17 +154,17 @@
// Add button to confirm answer is incorrect
$(el).append($("
[Incorrect]").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,
- status: 0,
- },
- type: "POST",
- dataType: "json",
- })
+ url: "{% url 'answer_suggestion_confirm' %}",
+ data: {
+ csrfmiddlewaretoken: "{{ csrf_token }}",
+ //active: this.checked // true if checked else false
+ question_type: "rapid",
+ aid: el.dataset.aid,
+ status: 0,
+ },
+ type: "POST",
+ dataType: "json",
+ })
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
@@ -183,5 +183,4 @@
}))
});
});
-
\ No newline at end of file
From 2b7751c6c1e4270c9406a9e6a2da2018d0c8c8c4 Mon Sep 17 00:00:00 2001
From: Ross
Date: Thu, 8 Jul 2021 14:54:34 +0100
Subject: [PATCH 25/53] .
---
rapids/templates/rapids/question_display_block.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index 65e0d003..9336c827 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -77,9 +77,9 @@
Image viewer
+
-
\ No newline at end of file
+
+ // send request to change the is_private state on customSwitches toggle
+ $(".proposed-answer").each((n, el) => {
+
+ // Add button to confirm answer is correct
+ $(el).append($("[Add Correct]").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,
+ status: 2,
+ },
+ type: "POST",
+ dataType: "json",
+ })
+ // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
+ .done(function (data) {
+ console.log(data);
+
+ 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
+ })
+ .always(function () {
+ console.log('[Done]');
+ })
+ }))
+
+ // Add button to confirm answer is incorrect
+ $(el).append($("[Incorrect]").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,
+ status: 0,
+ },
+ type: "POST",
+ dataType: "json",
+ })
+ // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
+ .done(function (data) {
+ console.log(data);
+
+ 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
+ })
+ .always(function () {
+ console.log('[Done]');
+ })
+ }))
+ });
+ });
+
+
\ No newline at end of file
From fb2aa07b174ac2bb53796be9117ea9b828bde8c1 Mon Sep 17 00:00:00 2001
From: Ross
Date: Thu, 8 Jul 2021 16:35:49 +0100
Subject: [PATCH 43/53] .
---
.../rapids/question_display_block.html | 224 +++++++++---------
1 file changed, 112 insertions(+), 112 deletions(-)
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index 19b368f5..38154a6a 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -92,127 +92,126 @@
/* beautify ignore:end */
$("#toggle-normal-button").click(function () {
- $.ajax({
- url: "{% url 'rapid-detail' question.id %}",
- type: 'PATCH',
- headers: {
- "X-CSRFToken": "{{ csrf_token }}"
- },
- timeout: 3000,
- data: {
- csrfmiddlewaretoken: "{{ csrf_token }}",
- normal: n,
- }
- })
- .done(function (data) {
- console.log(data);
- toastr.info('Answer saved')
- }
- })
- .fail(function () {
- alert('Error updating this model instance.');
- //chk_status_field.prop('checked', !chk_status_field.prop('checked'));
- });
+ $.ajax({
+ url: "{% url 'rapid-detail' question.id %}",
+ type: 'PATCH',
+ headers: {
+ "X-CSRFToken": "{{ csrf_token }}"
+ },
+ timeout: 3000,
+ data: {
+ csrfmiddlewaretoken: "{{ csrf_token }}",
+ normal: n,
+ }
+ })
+ .done(function (data) {
+ console.log(data);
+ toastr.info('Answer saved')
+ })
+ .fail(function () {
+ alert('Error updating this model instance.');
+ //chk_status_field.prop('checked', !chk_status_field.prop('checked'));
+ });
});
- $(".suggested_answers li").each((n, el) => {
- $(el).append($("[Add Correct]").on("click", function () {
- $.ajax({
- url: "{% url 'answer_submit' %}",
- data: {
- csrfmiddlewaretoken: "{{ csrf_token }}",
- //active: this.checked // true if checked else false
- question_type: "rapid",
- qid: "{{question.pk}}",
- status: 2,
- answer: el.dataset.string,
- },
- type: "POST",
- dataType: "json",
- })
- // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
- .done(function (data) {
- console.log(data);
+ $(".suggested_answers li").each((n, el) => {
+ $(el).append($("[Add Correct]").on("click", function () {
+ $.ajax({
+ url: "{% url 'answer_submit' %}",
+ data: {
+ csrfmiddlewaretoken: "{{ csrf_token }}",
+ //active: this.checked // true if checked else false
+ question_type: "rapid",
+ qid: "{{question.pk}}",
+ status: 2,
+ answer: el.dataset.string,
+ },
+ type: "POST",
+ dataType: "json",
+ })
+ // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
+ .done(function (data) {
+ console.log(data);
- if (data.success) {
- toastr.info('Answer saved')
- $(el).find(".correct").remove()
- }
- // show some message according to the response.
- // For eg. A message box showing that the status has been changed
- })
- .always(function () {
- console.log('[Done]');
- })
- }))
+ if (data.success) {
+ toastr.info('Answer saved')
+ $(el).find(".correct").remove()
+ }
+ // show some message according to the response.
+ // For eg. A message box showing that the status has been changed
+ })
+ .always(function () {
+ console.log('[Done]');
+ })
+ }))
- });
+ });
- // send request to change the is_private state on customSwitches toggle
- $(".proposed-answer").each((n, el) => {
+ // send request to change the is_private state on customSwitches toggle
+ $(".proposed-answer").each((n, el) => {
- // Add button to confirm answer is correct
- $(el).append($("[Add Correct]").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,
- status: 2,
- },
- type: "POST",
- dataType: "json",
- })
- // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
- .done(function (data) {
- console.log(data);
+ // Add button to confirm answer is correct
+ $(el).append($("[Add Correct]").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,
+ status: 2,
+ },
+ type: "POST",
+ dataType: "json",
+ })
+ // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
+ .done(function (data) {
+ console.log(data);
- 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
- })
- .always(function () {
- console.log('[Done]');
- })
- }))
+ 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
+ })
+ .always(function () {
+ console.log('[Done]');
+ })
+ }))
- // Add button to confirm answer is incorrect
- $(el).append($("[Incorrect]").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,
- status: 0,
- },
- type: "POST",
- dataType: "json",
- })
- // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
- .done(function (data) {
- console.log(data);
+ // Add button to confirm answer is incorrect
+ $(el).append($("[Incorrect]").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,
+ status: 0,
+ },
+ type: "POST",
+ dataType: "json",
+ })
+ // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
+ .done(function (data) {
+ console.log(data);
- 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
- })
- .always(function () {
- console.log('[Done]');
- })
- }))
- });
+ 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
+ })
+ .always(function () {
+ console.log('[Done]');
+ })
+ }))
+ });
});