.
This commit is contained in:
@@ -4,7 +4,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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">toggle</button></p>
|
<p class="pre-whitespace"><b>Normal:</b> {{ question.normal }} <button id="toggle-normal-button"
|
||||||
|
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>
|
<p class="pre-whitespace"><b>Laterality:</b> {{ question.laterality }}</p>
|
||||||
@@ -91,119 +92,136 @@
|
|||||||
/* beautify ignore:end */
|
/* beautify ignore:end */
|
||||||
|
|
||||||
$("#toggle-normal-button").click(function () {
|
$("#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($("<span class='correct'>[Add Correct]</span>").on("click", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'rapid-detail' question.id %}",
|
url: "{% url 'answer_submit' %}",
|
||||||
type: 'PATCH',
|
|
||||||
headers:{"X-CSRFToken": "{{ csrf_token }}"},
|
|
||||||
timeout: 3000,
|
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
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 () {
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
alert('Error updating this model instance.');
|
.done(function (data) {
|
||||||
//chk_status_field.prop('checked', !chk_status_field.prop('checked'));
|
console.log(data);
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".suggested_answers li").each((n, el) => {
|
if (data.success) {
|
||||||
$(el).append($("<span class='correct'>[Add Correct]</span>").on("click", function () {
|
toastr.info('Answer saved')
|
||||||
$.ajax({
|
$(el).find(".correct").remove()
|
||||||
url: "{% url 'answer_submit' %}",
|
}
|
||||||
data: {
|
// show some message according to the response.
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
// For eg. A message box showing that the status has been changed
|
||||||
//active: this.checked // true if checked else false
|
})
|
||||||
question_type: "rapid",
|
.always(function () {
|
||||||
qid: "{{question.pk}}",
|
console.log('[Done]');
|
||||||
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]');
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
|
|
||||||
});
|
// send request to change the is_private state on customSwitches toggle
|
||||||
|
$(".proposed-answer").each((n, el) => {
|
||||||
|
|
||||||
// send request to change the is_private state on customSwitches toggle
|
// Add button to confirm answer is correct
|
||||||
$(".proposed-answer").each((n, el) => {
|
$(el).append($("<span class='confirm'>[Add Correct]</span>").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);
|
||||||
|
|
||||||
// Add button to confirm answer is correct
|
if (data.success) {
|
||||||
$(el).append($("<span class='confirm'>[Add Correct]</span>").on("click", function () {
|
toastr.info('Answer saved')
|
||||||
$.ajax({
|
$(el).find(".confirm").remove()
|
||||||
url: "{% url 'answer_suggestion_confirm' %}",
|
$(el).removeClass("proposed-answer")
|
||||||
data: {
|
}
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
// show some message according to the response.
|
||||||
//active: this.checked // true if checked else false
|
// For eg. A message box showing that the status has been changed
|
||||||
question_type: "rapid",
|
})
|
||||||
aid: el.dataset.aid,
|
.always(function () {
|
||||||
status: 2,
|
console.log('[Done]');
|
||||||
},
|
})
|
||||||
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) {
|
// Add button to confirm answer is incorrect
|
||||||
toastr.info('Answer saved')
|
$(el).append($("<span class='confirm'>[Incorrect]</span>").on("click", function () {
|
||||||
$(el).find(".confirm").remove()
|
$.ajax({
|
||||||
$(el).removeClass("proposed-answer")
|
url: "{% url 'answer_suggestion_confirm' %}",
|
||||||
}
|
data: {
|
||||||
// show some message according to the response.
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
// For eg. A message box showing that the status has been changed
|
//active: this.checked // true if checked else false
|
||||||
})
|
question_type: "rapid",
|
||||||
.always(function () {
|
aid: el.dataset.aid,
|
||||||
console.log('[Done]');
|
status: 0,
|
||||||
})
|
},
|
||||||
}))
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
})
|
||||||
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
|
.done(function (data) {
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
// Add button to confirm answer is incorrect
|
if (data.success) {
|
||||||
$(el).append($("<span class='confirm'>[Incorrect]</span>").on("click", function () {
|
toastr.info('Answer saved')
|
||||||
$.ajax({
|
$(el).find(".confirm").remove()
|
||||||
url: "{% url 'answer_suggestion_confirm' %}",
|
$(el).removeClass("proposed-answer")
|
||||||
data: {
|
}
|
||||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
// show some message according to the response.
|
||||||
//active: this.checked // true if checked else false
|
// For eg. A message box showing that the status has been changed
|
||||||
question_type: "rapid",
|
})
|
||||||
aid: el.dataset.aid,
|
.always(function () {
|
||||||
status: 0,
|
console.log('[Done]');
|
||||||
},
|
})
|
||||||
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]');
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<style>
|
||||||
|
.toggle-button {
|
||||||
|
font-size: x-small;
|
||||||
|
opacity: 10%;
|
||||||
|
}
|
||||||
|
.toggle-button:hover {
|
||||||
|
font-size: x-small;
|
||||||
|
opacity: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user