.
This commit is contained in:
@@ -275,6 +275,7 @@ def answer_submit(request):
|
|||||||
|
|
||||||
a = AnswerModel(question=q, answer=answer_string, status=status)
|
a = AnswerModel(question=q, answer=answer_string, status=status)
|
||||||
a.save()
|
a.save()
|
||||||
|
return JsonResponse({"success": True, "error": "Answer added"})
|
||||||
|
|
||||||
return JsonResponse({"success": False, "error": "Invalid data"})
|
return JsonResponse({"success": False, "error": "Invalid data"})
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
$(".proposed-answer").each((n, el) => {
|
$(".proposed-answer").each((n, el) => {
|
||||||
|
|
||||||
// Add button to confirm answer is correct
|
// 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({
|
$.ajax({
|
||||||
url: "{% url 'answer_suggestion_confirm' %}",
|
url: "{% url 'answer_suggestion_confirm' %}",
|
||||||
data: {
|
data: {
|
||||||
@@ -139,9 +139,8 @@
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
toastr.info('Answer saved')
|
toastr.info('Answer added')
|
||||||
$(el).find(".confirm").remove()
|
$(el).find(".correct").remove()
|
||||||
$(el).removeClass("proposed-answer")
|
|
||||||
}
|
}
|
||||||
// show some message according to the response.
|
// show some message according to the response.
|
||||||
// For eg. A message box showing that the status has been changed
|
// For eg. A message box showing that the status has been changed
|
||||||
|
|||||||
Reference in New Issue
Block a user