diff --git a/rapids/templates/rapids/question_display_block.html b/rapids/templates/rapids/question_display_block.html index 76cb070e..19b368f5 100755 --- a/rapids/templates/rapids/question_display_block.html +++ b/rapids/templates/rapids/question_display_block.html @@ -4,7 +4,8 @@

Rapid: {{ question }}

-

Normal: {{ question.normal }}

+

Normal: {{ question.normal }}

Region: {{ question.get_regions }}

Examination: {{ question.get_examinations }}

Laterality: {{ question.laterality }}

@@ -91,119 +92,136 @@ /* beautify ignore:end */ $("#toggle-normal-button").click(function () { + $.ajax({ + url: "{% url 'rapid-detail' question.id %}", + type: 'PATCH', + headers: { + "X-CSRFToken": "{{ csrf_token }}" + }, + timeout: 3000, + data: { + csrfmiddlewaretoken: "{{ csrf_token }}", + normal: n, + } + }) + .done(function (data) { + console.log(data); + toastr.info('Answer saved') + } + }) + .fail(function () { + alert('Error updating this model instance.'); + //chk_status_field.prop('checked', !chk_status_field.prop('checked')); + }); + }); + + $(".suggested_answers li").each((n, el) => { + $(el).append($("[Add Correct]").on("click", function () { $.ajax({ - url: "{% url 'rapid-detail' question.id %}", - type: 'PATCH', - headers:{"X-CSRFToken": "{{ csrf_token }}"}, - timeout: 3000, + url: "{% url 'answer_submit' %}", data: { csrfmiddlewaretoken: "{{ csrf_token }}", - normal: n, - } + //active: this.checked // true if checked else false + question_type: "rapid", + qid: "{{question.pk}}", + status: 2, + answer: el.dataset.string, + }, + type: "POST", + dataType: "json", }) - .fail(function () { - alert('Error updating this model instance.'); - //chk_status_field.prop('checked', !chk_status_field.prop('checked')); - }); - }); + // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly + .done(function (data) { + console.log(data); - $(".suggested_answers li").each((n, el) => { - $(el).append($("[Add Correct]").on("click", function () { - $.ajax({ - url: "{% url 'answer_submit' %}", - data: { - csrfmiddlewaretoken: "{{ csrf_token }}", - //active: this.checked // true if checked else false - question_type: "rapid", - qid: "{{question.pk}}", - status: 2, - answer: el.dataset.string, - }, - 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(".correct").remove() + } + // show some message according to the response. + // For eg. A message box showing that the status has been changed + }) + .always(function () { + console.log('[Done]'); + }) + })) - if (data.success) { - toastr.info('Answer saved') - $(el).find(".correct").remove() - } - // show some message according to the response. - // For eg. A message box showing that the status has been changed - }) - .always(function () { - console.log('[Done]'); - }) - })) - - }); - - // 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 + + // 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