diff --git a/rapids/models.py b/rapids/models.py index f29c6934..65542bd9 100644 --- a/rapids/models.py +++ b/rapids/models.py @@ -326,6 +326,8 @@ class Rapid(models.Model): for a in self.abnormality.all(): answers.append("{}{} {}".format(laterality, r.name, a.name)) answers.append("{} {}{}".format(a.name, laterality, r.name)) + answers.append("{} {}".format(r.name, a.name)) + answers.append("{} {}".format(a.name, r.name)) compare_answers = self.get_compare_answers() diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html index 742415d5..ae01fe14 100755 --- a/rapids/templates/rapids/question_display_block.html +++ b/rapids/templates/rapids/question_display_block.html @@ -31,7 +31,8 @@

Scrapped: {{ question.scrapped }} (toggle)

Answers (score): {% for answer in question.answers.all %} - + {{ answer }} ({{answer.status}}), {% endfor %} @@ -69,8 +70,8 @@

  • {{ans}}
  • {% endfor %} + -
    @@ -78,109 +79,109 @@
    - +
    - \ No newline at end of file + // send request to change the is_private state on customSwitches toggle + $(".proposed-answer").each((n, el) => { + + // Add button to confirm answer is correct + $(el).append($("[Add 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, + status: 2, + }, + 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]'); + }) + })) + + // 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: 0, + }, + 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]'); + }) + })) + }); + }); + + \ No newline at end of file