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