.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user