.
This commit is contained in:
@@ -78,6 +78,7 @@ $(document).ready(function () {
|
||||
|
||||
var jqxhr = $.get(evt.target.dataset.exam_list_url, function (data) {
|
||||
console.log(data);
|
||||
$("#exam-options").empty();
|
||||
data.forEach((obj, n) => {
|
||||
$("#exam-options").append($(document.createElement('button')).prop({
|
||||
type: 'button',
|
||||
@@ -106,6 +107,12 @@ $(document).ready(function () {
|
||||
$("table input:checked").each((n, el) => {
|
||||
ids.push(el.value)
|
||||
})
|
||||
|
||||
// if no question selected
|
||||
if (ids.length < 1) {
|
||||
toastr.info('No question selected.');
|
||||
return
|
||||
}
|
||||
let post_url = document.getElementById("button-select-add-exam").dataset.exam_json_edit_url;
|
||||
let type = document.getElementById("button-select-add-exam").dataset.type;
|
||||
let csrf = document.getElementById("button-select-add-exam").dataset.csrf;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
<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>Laterality:</b> {{ question.laterality }}
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="LEFT">Left</button>
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="RIGHT">Right</button>
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="BILAT">Bilateral</button>
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="NONE">None</button>
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="LEFT">Left</button>
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="RIGHT">Right</button>
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="BILAT">Bilateral</button>
|
||||
<button class="toggle-laterality-button toggle-button" data-lat="NONE">None</button>
|
||||
</p>
|
||||
<p class="pre-whitespace"><b>Abnormality:</b> {{ question.get_abnormalities }}</p>
|
||||
<div class="pre-whitespace multi-image-block"><b>Images:</b>
|
||||
@@ -28,6 +28,9 @@
|
||||
Exams: {% for exam in question.exams.all %}
|
||||
<a href="{% url 'rapids:exam_overview' pk=exam.pk %}">{{ exam.name }}</a>,
|
||||
{% endfor %}
|
||||
|
||||
<button id="add-to-exam" data-exam_json_edit_url="{% url 'generic:generic_exam_json_edit' %}" data-exam_list_url="{% url 'rapid-exam-list' %}" data-type="rapid" data-csrf="{{ csrf_token}}" data-qid="{{question.pk}}">Add to exam</button>
|
||||
<span id="exam-options"></span>
|
||||
</div>
|
||||
<p class="pre-whitespace"><b>Open Access:</b> {{ question.open_access }}</p>
|
||||
<p class="pre-whitespace"><b>Feedback:</b> {{ question.feedback }}</p>
|
||||
@@ -91,6 +94,76 @@
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
$("#add-to-exam").click(function (evt) {
|
||||
|
||||
var jqxhr = $.get(evt.target.dataset.exam_list_url, function (data) {
|
||||
console.log(data);
|
||||
$("#exam-options").empty();
|
||||
data.forEach((obj, n) => {
|
||||
$("#exam-options").append($(document.createElement('button')).prop({
|
||||
type: 'button',
|
||||
innerHTML: obj.name,
|
||||
class: '',
|
||||
|
||||
}).data("exam-id", obj.id).click((evt) => {
|
||||
addToExam(evt)
|
||||
}))
|
||||
})
|
||||
})
|
||||
.done(function () {
|
||||
//alert( "second success" );
|
||||
})
|
||||
.fail(function () {
|
||||
//alert( "error" );
|
||||
})
|
||||
.always(function () {
|
||||
//alert( "finished" );
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
|
||||
function addToExam(evt) {
|
||||
|
||||
let exam_button = document.getElementById("add-to-exam");
|
||||
let ids = [];
|
||||
ids.push(exam_button.dataset.qid);
|
||||
|
||||
// if no question selected
|
||||
if (ids.length < 1) {
|
||||
toastr.info('No question selected.');
|
||||
return
|
||||
}
|
||||
let post_url = exam_button.dataset.exam_json_edit_url;
|
||||
let type = exam_button.dataset.type;
|
||||
let csrf = exam_button.dataset.csrf;
|
||||
$.ajax({
|
||||
url: post_url,
|
||||
data: {
|
||||
csrfmiddlewaretoken: csrf,
|
||||
add_exam_questions: JSON.stringify(ids),
|
||||
type: type,
|
||||
exam_id: $(evt.target).data("exam-id"),
|
||||
},
|
||||
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('Questions added to exams.')
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
$("#exam-options").empty();
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
//var $crf_token = $('[name="csrfmiddlewaretoken"]').attr('value');
|
||||
/* beautify ignore:start */
|
||||
n = !{{ question.normal | lower }}
|
||||
|
||||
Reference in New Issue
Block a user