Improve answers display on question pages
This commit is contained in:
@@ -40,9 +40,25 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1>{{ question.get_primary_answer }}</h1>
|
<h1>{{ question.get_primary_answer }}</h1>
|
||||||
<h2>{{question.question_type}}</h2>
|
<h2>{{question.question_type}}</h2>
|
||||||
Answers (score): {% for answer in question.answers.all %}
|
<details>
|
||||||
{{ answer }} ({{answer.status}}),
|
<summary>
|
||||||
{% endfor %}
|
Answers:
|
||||||
|
</summary>
|
||||||
|
<table>
|
||||||
|
<tr><th>Answer</th><th>Score</th></tr>
|
||||||
|
{% for answer in question.answers.all|dictsortreversed:"status" %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span {% if answer.proposed %}class="proposed-answer" data-aid="{{answer.pk}}" data-question-type="anatomy"
|
||||||
|
{% endif %}>
|
||||||
|
{{ answer }}
|
||||||
|
</span>
|
||||||
|
<td>
|
||||||
|
<td>{{answer.status}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</details>
|
||||||
<div>
|
<div>
|
||||||
Description: {{ question.description }}
|
Description: {{ question.description }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Edit User / {{ciduser.cid}}</h2>
|
<h2>Edit User / {{ciduser.cid}}</h2>
|
||||||
Use this form to create a user. Only existing supervisors can be added (create it first or add it later if it does not exist).
|
Use this form to create a user. Only existing supervisors can be added (<a href="{% url 'generic:supervisor_create' %}">create them first</a> and refresh this page or add them later if they do not exist).
|
||||||
{% if errors %}
|
{% if errors %}
|
||||||
<div class="alert alert-info" role="alert">{{errors}}</a></div>
|
<div class="alert alert-info" role="alert">{{errors}}</a></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -556,11 +556,13 @@ class UserListTableView(CidManagerRequiredMixin, SingleTableMixin, FilterView):
|
|||||||
# context["cid_user_groups"] = cid_user_groups
|
# context["cid_user_groups"] = cid_user_groups
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class DeleteUserView(CidManagerRequiredMixin, DeleteView):
|
class DeleteUserView(CidManagerRequiredMixin, DeleteView):
|
||||||
model = User
|
model = User
|
||||||
template_name: str = "confirm_delete.html"
|
template_name: str = "confirm_delete.html"
|
||||||
success_url = reverse_lazy("accounts_list")
|
success_url = reverse_lazy("accounts_list")
|
||||||
|
|
||||||
|
|
||||||
class UpdateUserView(CidManagerRequiredMixin, UpdateView):
|
class UpdateUserView(CidManagerRequiredMixin, UpdateView):
|
||||||
model = User
|
model = User
|
||||||
fields = ["first_name", "last_name", "email"] # Keep listing whatever fields
|
fields = ["first_name", "last_name", "email"] # Keep listing whatever fields
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<p class="pre-whitespace"><b>Rapid:</b> {{ question }}</p>
|
<p class="pre-whitespace"><b>Rapid:</b> {{ question }}</p>
|
||||||
<p class="pre-whitespace"><b>Normal:</b> {{ question.normal }} <button id="toggle-normal-button"
|
<p class="pre-whitespace"><b>Normal:</b> {{ question.normal }} <button id="toggle-normal-button"
|
||||||
class="toggle-button">toggle</button></p>
|
class="toggle-button">toggle</button></p>
|
||||||
<p class="pre-whitespace"><b>Region:</b> {{ question.get_regions }}</p>
|
<p class="pre-whitespace"><b>Region:</b> {{ question.get_regions }}</p>
|
||||||
<p class="pre-whitespace"><b>Examination:</b> {{ question.get_examinations }}</p>
|
<p class="pre-whitespace"><b>Examination:</b> {{ question.get_examinations }}</p>
|
||||||
<p class="pre-whitespace"><b>Laterality:</b> {{ question.laterality }}
|
<p class="pre-whitespace"><b>Laterality:</b> {{ question.laterality }}
|
||||||
@@ -21,16 +21,16 @@
|
|||||||
<p class="pre-whitespace"><b>Abnormality:</b> {{ question.get_abnormalities }}</p>
|
<p class="pre-whitespace"><b>Abnormality:</b> {{ question.get_abnormalities }}</p>
|
||||||
<div class="pre-whitespace multi-image-block"><b>Images:</b>
|
<div class="pre-whitespace multi-image-block"><b>Images:</b>
|
||||||
{% for image in question.images.all %}
|
{% for image in question.images.all %}
|
||||||
<span class="image-block">
|
<span class="image-block">
|
||||||
Image {{ forloop.counter }}{% if image.description %} ({{image.description}}){% endif %}{% if image.feedback_image %} [feedback image]{% endif %}:
|
Image {{ forloop.counter }}{% if image.description %} ({{image.description}}){% endif %}{% if image.feedback_image %} [feedback image]{% endif %}:
|
||||||
<div class="dicom-image rapid-img {% if image.feedback_image %}feedback-img{% endif %}"
|
<div class="dicom-image rapid-img {% if image.feedback_image %}feedback-img{% endif %}"
|
||||||
data-url="https://www.penracourses.org.uk{{ image.image.url}}"></div>
|
data-url="https://www.penracourses.org.uk{{ image.image.url}}"></div>
|
||||||
</span>
|
</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Exam(s): {% for exam in question.exams.all %}
|
Exam(s): {% for exam in question.exams.all %}
|
||||||
<a href="{% url 'rapids:exam_overview' pk=exam.pk %}">{{ exam.name }}</a>,
|
<a href="{% url 'rapids:exam_overview' pk=exam.pk %}">{{ exam.name }}</a>,
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<button id="add-to-exam" data-exam_json_edit_url="{% url 'generic:generic_exam_json_edit' %}"
|
<button id="add-to-exam" data-exam_json_edit_url="{% url 'generic:generic_exam_json_edit' %}"
|
||||||
@@ -43,36 +43,49 @@
|
|||||||
<p class="pre-whitespace"><b>Feedback:</b> {{ question.feedback }}</p>
|
<p class="pre-whitespace"><b>Feedback:</b> {{ question.feedback }}</p>
|
||||||
<p class="pre-whitespace"><b>History:</b> {{ question.history }}</p>
|
<p class="pre-whitespace"><b>History:</b> {{ question.history }}</p>
|
||||||
<p><b>Author(s):</b> {% for author in question.author.all %} <a
|
<p><b>Author(s):</b> {% for author in question.author.all %} <a
|
||||||
href="{% url 'rapids:author_detail' pk=author.pk %}">{{author}}</a>, {% endfor %}</p>
|
href="{% url 'rapids:author_detail' pk=author.pk %}">{{author}}</a>, {% endfor %}</p>
|
||||||
<p><b>Checked by:</b> {% for verified in question.verified.all %} <a
|
<p><b>Checked by:</b> {% for verified in question.verified.all %} <a
|
||||||
href="{% url 'rapids:verified_detail' pk=verified.pk %}">{{verified}}</a>, {% endfor %}</p>
|
href="{% url 'rapids:verified_detail' pk=verified.pk %}">{{verified}}</a>, {% endfor %}</p>
|
||||||
{% comment %} <p><b>Scrapped:</b> {{ question.scrapped }} <a
|
{% comment %} <p><b>Scrapped:</b> {{ question.scrapped }} <a
|
||||||
href="{% url 'rapids:rapid_scrap' pk=question.pk %}">(toggle)</a></p> {% endcomment %}
|
href="{% url 'rapids:rapid_scrap' pk=question.pk %}">(toggle)</a></p> {% endcomment %}
|
||||||
<p class="pre-whitespace">
|
<p class="pre-whitespace">
|
||||||
Answers (score): {% for answer in question.answers.all %}
|
<details>
|
||||||
<span {% if answer.proposed %}class="proposed-answer" data-aid="{{answer.pk}}" data-question-type="rapid"
|
<summary>
|
||||||
{% endif %}>
|
Answers:
|
||||||
{{ answer }} ({{answer.status}}),
|
</summary>
|
||||||
</span>
|
<table>
|
||||||
{% endfor %}
|
<tr><th>Answer</th><th>Score</th></tr>
|
||||||
|
{% for answer in question.answers.all|dictsortreversed:"status" %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span {% if answer.proposed %}class="proposed-answer" data-aid="{{answer.pk}}" data-question-type="rapid"
|
||||||
|
{% endif %}>
|
||||||
|
{{ answer }}
|
||||||
|
</span>
|
||||||
|
<td>
|
||||||
|
<td>{{answer.status}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</details>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
{% if view_feedback %}
|
{% if view_feedback %}
|
||||||
{% include 'question_notes.html' %}
|
{% include 'question_notes.html' %}
|
||||||
{% if not question.normal %}
|
{% if not question.normal %}
|
||||||
<details>
|
<details>
|
||||||
<summary>
|
<summary>
|
||||||
Suggested answers
|
Suggested answers
|
||||||
</summary>
|
</summary>
|
||||||
<ul class="suggested_answers">
|
<ul class="suggested_answers">
|
||||||
{% for ans in question.get_suggested_answers %}
|
{% for ans in question.get_suggested_answers %}
|
||||||
<li data-string="{{ans}}">{{ans}}</li>
|
<li data-string="{{ans}}">{{ans}}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -91,13 +104,13 @@
|
|||||||
Image annotations:
|
Image annotations:
|
||||||
</summary>
|
</summary>
|
||||||
{% for image in question.images.all %}
|
{% for image in question.images.all %}
|
||||||
<span class="image-block">
|
<span class="image-block">
|
||||||
Image {{ forloop.counter }}: {{image.image_annotations}}<br />
|
Image {{ forloop.counter }}: {{image.image_annotations}}<br />
|
||||||
</span>
|
</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</details>
|
</details>
|
||||||
<a href="{% url 'rapids:question_anonymise_dicom' pk=question.pk %}"
|
<a href="{% url 'rapids:question_anonymise_dicom' pk=question.pk %}"
|
||||||
title="Anonymise dicom images">Anonymise dicoms</a><br />
|
title="Anonymise dicom images">Anonymise dicoms</a><br />
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#edit-button").click(() => {
|
$("#edit-button").click(() => {
|
||||||
@@ -127,34 +140,34 @@
|
|||||||
console.log("json_toolstates", json_toolstates)
|
console.log("json_toolstates", json_toolstates)
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapids:question_save_annotation' pk=question.pk %}",
|
url: "{% url 'rapids:question_save_annotation' pk=question.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
// Yes we do double encode the json....
|
// Yes we do double encode the json....
|
||||||
annotation: JSON.stringify(json_toolstates),
|
annotation: JSON.stringify(json_toolstates),
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
toastr.warning(`Error saving annotations`)
|
toastr.warning(`Error saving annotations`)
|
||||||
console.log(e);
|
console.log(e);
|
||||||
},
|
},
|
||||||
|
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// 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
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
toastr.info('Annotations saved')
|
toastr.info('Annotations saved')
|
||||||
} else {
|
} else {
|
||||||
toastr.warning('Error saving annotations')
|
toastr.warning('Error saving annotations')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#cancel-add-to-exam").click(function (evt) {
|
$("#cancel-add-to-exam").click(function (evt) {
|
||||||
@@ -168,28 +181,28 @@
|
|||||||
$("#cancel-add-to-exam").toggle();
|
$("#cancel-add-to-exam").toggle();
|
||||||
|
|
||||||
var jqxhr = $.get(evt.target.dataset.exam_list_url, function (data) {
|
var jqxhr = $.get(evt.target.dataset.exam_list_url, function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
$("#exam-options").empty();
|
$("#exam-options").empty();
|
||||||
data.forEach((obj, n) => {
|
data.forEach((obj, n) => {
|
||||||
$("#exam-options").append($(document.createElement('button')).prop({
|
$("#exam-options").append($(document.createElement('button')).prop({
|
||||||
type: 'button',
|
type: 'button',
|
||||||
innerHTML: obj.name,
|
innerHTML: obj.name,
|
||||||
class: '',
|
class: '',
|
||||||
|
|
||||||
}).data("exam-id", obj.id).click((evt) => {
|
}).data("exam-id", obj.id).click((evt) => {
|
||||||
addToExam(evt)
|
addToExam(evt)
|
||||||
}))
|
}))
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
.done(function () {
|
.done(function () {
|
||||||
//alert( "second success" );
|
//alert( "second success" );
|
||||||
})
|
})
|
||||||
.fail(function () {
|
.fail(function () {
|
||||||
//alert( "error" );
|
//alert( "error" );
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
//alert( "finished" );
|
//alert( "finished" );
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -200,7 +213,7 @@
|
|||||||
let ids = [];
|
let ids = [];
|
||||||
ids.push(exam_button.dataset.qid);
|
ids.push(exam_button.dataset.qid);
|
||||||
|
|
||||||
// if no question selected
|
// if no question selected
|
||||||
if (ids.length < 1) {
|
if (ids.length < 1) {
|
||||||
toastr.info('No question selected.');
|
toastr.info('No question selected.');
|
||||||
return
|
return
|
||||||
@@ -209,28 +222,28 @@
|
|||||||
let type = exam_button.dataset.type;
|
let type = exam_button.dataset.type;
|
||||||
let csrf = exam_button.dataset.csrf;
|
let csrf = exam_button.dataset.csrf;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: post_url,
|
url: post_url,
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: csrf,
|
csrfmiddlewaretoken: csrf,
|
||||||
add_exam_questions: JSON.stringify(ids),
|
add_exam_questions: JSON.stringify(ids),
|
||||||
type: type,
|
type: type,
|
||||||
exam_id: $(evt.target).data("exam-id"),
|
exam_id: $(evt.target).data("exam-id"),
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
toastr.info('Questions added to exams.')
|
toastr.info('Questions added to exams.')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
$("#exam-options").empty();
|
$("#exam-options").empty();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -241,6 +254,29 @@
|
|||||||
|
|
||||||
$("#toggle-normal-button").click(function () {
|
$("#toggle-normal-button").click(function () {
|
||||||
$.ajax({
|
$.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 updated')
|
||||||
|
})
|
||||||
|
.fail(function () {
|
||||||
|
alert('Error updating this model instance.');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".toggle-laterality-button").each((n, el) => {
|
||||||
|
$(el).click(function () {
|
||||||
|
$.ajax({
|
||||||
url: "{% url 'rapid-detail' question.id %}",
|
url: "{% url 'rapid-detail' question.id %}",
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -249,71 +285,48 @@
|
|||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
normal: n,
|
laterality: el.dataset.lat,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
toastr.info('Answer updated')
|
toastr.info('Answer updated')
|
||||||
})
|
})
|
||||||
.fail(function () {
|
.fail(function () {
|
||||||
alert('Error updating this model instance.');
|
alert('Error updating this model instance.');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$(".toggle-laterality-button").each((n, el) => {
|
|
||||||
$(el).click(function () {
|
|
||||||
$.ajax({
|
|
||||||
url: "{% url 'rapid-detail' question.id %}",
|
|
||||||
type: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
"X-CSRFToken": "{{ csrf_token }}"
|
|
||||||
},
|
|
||||||
timeout: 3000,
|
|
||||||
data: {
|
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
|
||||||
laterality: el.dataset.lat,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.done(function (data) {
|
|
||||||
console.log(data);
|
|
||||||
toastr.info('Answer updated')
|
|
||||||
})
|
|
||||||
.fail(function () {
|
|
||||||
alert('Error updating this model instance.');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".suggested_answers li").each((n, el) => {
|
$(".suggested_answers li").each((n, el) => {
|
||||||
$(el).append($("<span class='correct'>[Add Correct]</span>").on("click", function () {
|
$(el).append($("<span class='correct'>[Add Correct]</span>").on("click", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'answer_submit' %}",
|
url: "{% url 'answer_submit' %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
//active: this.checked // true if checked else false
|
//active: this.checked // true if checked else false
|
||||||
question_type: "rapid",
|
question_type: "rapid",
|
||||||
qid: "{{question.pk}}",
|
qid: "{{question.pk}}",
|
||||||
status: 2,
|
status: 2,
|
||||||
answer: el.dataset.string,
|
answer: el.dataset.string,
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
toastr.info('Answer saved')
|
toastr.info('Answer saved')
|
||||||
$(el).find(".correct").remove()
|
$(el).find(".correct").remove()
|
||||||
}
|
}
|
||||||
// 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
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -324,63 +337,63 @@
|
|||||||
// Add button to confirm answer is correct
|
// Add button to confirm answer is correct
|
||||||
$(el).append($("<span class='confirm'>[Add Correct]</span>").on("click", function () {
|
$(el).append($("<span class='confirm'>[Add Correct]</span>").on("click", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'answer_suggestion_confirm' %}",
|
url: "{% url 'answer_suggestion_confirm' %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
//active: this.checked // true if checked else false
|
//active: this.checked // true if checked else false
|
||||||
question_type: "rapid",
|
question_type: "rapid",
|
||||||
aid: el.dataset.aid,
|
aid: el.dataset.aid,
|
||||||
status: 2,
|
status: 2,
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
toastr.info('Answer saved')
|
toastr.info('Answer saved')
|
||||||
$(el).find(".confirm").remove()
|
$(el).find(".confirm").remove()
|
||||||
$(el).removeClass("proposed-answer")
|
$(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
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Add button to confirm answer is incorrect
|
// Add button to confirm answer is incorrect
|
||||||
$(el).append($("<span class='confirm'>[Incorrect]</span>").on("click", function () {
|
$(el).append($("<span class='confirm'>[Incorrect]</span>").on("click", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'answer_suggestion_confirm' %}",
|
url: "{% url 'answer_suggestion_confirm' %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
//active: this.checked // true if checked else false
|
//active: this.checked // true if checked else false
|
||||||
question_type: "rapid",
|
question_type: "rapid",
|
||||||
aid: el.dataset.aid,
|
aid: el.dataset.aid,
|
||||||
status: 0,
|
status: 0,
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
toastr.info('Answer saved')
|
toastr.info('Answer saved')
|
||||||
$(el).find(".confirm").remove()
|
$(el).find(".confirm").remove()
|
||||||
$(el).removeClass("proposed-answer")
|
$(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
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user