This commit is contained in:
Ross
2021-05-06 21:51:37 +01:00
parent 2354d8970e
commit abef5f5173
3 changed files with 61 additions and 3 deletions
@@ -30,7 +30,7 @@
<p><b>Scrapped:</b> {{ question.scrapped }} <a href="{% url 'rapids:rapid_scrap' pk=question.pk %}">(toggle)</a>
<p class="pre-whitespace">
Answers (score): {% for answer in question.answers.all %}
<span {% if answer.proposed %}class="proposed-answer"{% endif %}>
<span {% if answer.proposed %}class="proposed-answer" data-aid="{{answer.pk}}" data-question-type="rapid" {% endif %}>
{{ answer }} ({{answer.status}}),
</span>
{% endfor %}
@@ -55,4 +55,39 @@
</ul>
<div id="single-dicom-viewer" class="dicom-viewer" data-images="{{ question.GetImageUrls }}" data-annotations=''></div>
</div>
</div>
<script>
$(document).ready(function () {
// send request to change the is_private state on customSwitches toggle
$(".proposed-answer").each((n, el) => {
$(el).append("<span>SAVE</span>").on("click", function () {
$.ajax({
url: "{% url 'answer_suggestion_confirm' %}",
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
//active: this.checked // true if checked else false
},
body: { question_type: "rapid", aid: el.dataset.aid},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
toastr.info('Exam state changed.')
}
// show some message according to the response.
// For eg. A message box showing that the status has been changed
})
.always(function () {
console.log('[Done]');
})
})
});
});
</script>