diff --git a/rad/views.py b/rad/views.py
index e2e9e172..9e06c755 100644
--- a/rad/views.py
+++ b/rad/views.py
@@ -231,6 +231,7 @@ def answer_suggestion_confirm(request):
if request.is_ajax and request.method == "POST":
question_type = request.POST.get("question_type")
aid = request.POST.get("aid")
+ status = request.POST.get("status")
if question_type == "anatomy":
AnswerModel = AnatomyAnswer
@@ -243,5 +244,6 @@ def answer_suggestion_confirm(request):
answer = get_object_or_404(AnswerModel, pk=aid)
answer.proposed = False
+ answer.status = status
answer.save()
return JsonResponse({"success": True, "error": "Answer changed"})
diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html
index eb93657f..b16a9b70 100755
--- a/rapids/templates/rapids/question_display_block.html
+++ b/rapids/templates/rapids/question_display_block.html
@@ -62,14 +62,16 @@
// send request to change the is_private state on customSwitches toggle
$(".proposed-answer").each((n, el) => {
- $(el).append("[Confirm]").on("click", function () {
+ // Add button to confirm answer is correct
+ $(el).append(("[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
+ aid: el.dataset.aid,
+ status: 2,
},
type: "POST",
dataType: "json",
@@ -89,7 +91,38 @@
.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: 1,
+ },
+ 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]');
+ })
+ }))
});
});