This commit is contained in:
Ross
2021-07-07 18:04:05 +01:00
parent 1bfb480f52
commit d40fec3e6a
2 changed files with 4 additions and 4 deletions
+1
View File
@@ -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"})
@@ -121,7 +121,7 @@
$(".proposed-answer").each((n, el) => {
// Add button to confirm answer is correct
$(el).append($("<span class='confirm'>[Correct]</span>").on("click", function () {
$(el).append($("<span class='correct'>[Add Correct]</span>").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