Improve answers display on question pages
This commit is contained in:
@@ -40,9 +40,25 @@
|
||||
</div>
|
||||
<h1>{{ question.get_primary_answer }}</h1>
|
||||
<h2>{{question.question_type}}</h2>
|
||||
Answers (score): {% for answer in question.answers.all %}
|
||||
{{ answer }} ({{answer.status}}),
|
||||
{% endfor %}
|
||||
<details>
|
||||
<summary>
|
||||
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>
|
||||
Description: {{ question.description }}
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<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 %}
|
||||
<div class="alert alert-info" role="alert">{{errors}}</a></div>
|
||||
{% endif %}
|
||||
|
||||
@@ -556,11 +556,13 @@ class UserListTableView(CidManagerRequiredMixin, SingleTableMixin, FilterView):
|
||||
# context["cid_user_groups"] = cid_user_groups
|
||||
return context
|
||||
|
||||
|
||||
class DeleteUserView(CidManagerRequiredMixin, DeleteView):
|
||||
model = User
|
||||
template_name: str = "confirm_delete.html"
|
||||
success_url = reverse_lazy("accounts_list")
|
||||
|
||||
|
||||
class UpdateUserView(CidManagerRequiredMixin, UpdateView):
|
||||
model = User
|
||||
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>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>Examination:</b> {{ question.get_examinations }}</p>
|
||||
<p class="pre-whitespace"><b>Laterality:</b> {{ question.laterality }}
|
||||
@@ -21,16 +21,16 @@
|
||||
<p class="pre-whitespace"><b>Abnormality:</b> {{ question.get_abnormalities }}</p>
|
||||
<div class="pre-whitespace multi-image-block"><b>Images:</b>
|
||||
{% for image in question.images.all %}
|
||||
<span class="image-block">
|
||||
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 %}"
|
||||
data-url="https://www.penracourses.org.uk{{ image.image.url}}"></div>
|
||||
</span>
|
||||
<span class="image-block">
|
||||
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 %}"
|
||||
data-url="https://www.penracourses.org.uk{{ image.image.url}}"></div>
|
||||
</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div>
|
||||
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 %}
|
||||
|
||||
<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>History:</b> {{ question.history }}</p>
|
||||
<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
|
||||
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
|
||||
href="{% url 'rapids:rapid_scrap' pk=question.pk %}">(toggle)</a></p> {% endcomment %}
|
||||
<p class="pre-whitespace">
|
||||
Answers (score): {% for answer in question.answers.all %}
|
||||
<span {% if answer.proposed %}class="proposed-answer" data-aid="{{answer.pk}}" data-question-type="rapid"
|
||||
{% endif %}>
|
||||
{{ answer }} ({{answer.status}}),
|
||||
</span>
|
||||
{% endfor %}
|
||||
<details>
|
||||
<summary>
|
||||
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="rapid"
|
||||
{% endif %}>
|
||||
{{ answer }}
|
||||
</span>
|
||||
<td>
|
||||
<td>{{answer.status}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</details>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
{% if view_feedback %}
|
||||
{% include 'question_notes.html' %}
|
||||
{% if not question.normal %}
|
||||
<details>
|
||||
<summary>
|
||||
Suggested answers
|
||||
</summary>
|
||||
<ul class="suggested_answers">
|
||||
{% for ans in question.get_suggested_answers %}
|
||||
<li data-string="{{ans}}">{{ans}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</details>
|
||||
{% endif %}
|
||||
{% include 'question_notes.html' %}
|
||||
{% if not question.normal %}
|
||||
<details>
|
||||
<summary>
|
||||
Suggested answers
|
||||
</summary>
|
||||
<ul class="suggested_answers">
|
||||
{% for ans in question.get_suggested_answers %}
|
||||
<li data-string="{{ans}}">{{ans}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</details>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -91,13 +104,13 @@
|
||||
Image annotations:
|
||||
</summary>
|
||||
{% for image in question.images.all %}
|
||||
<span class="image-block">
|
||||
Image {{ forloop.counter }}: {{image.image_annotations}}<br />
|
||||
</span>
|
||||
<span class="image-block">
|
||||
Image {{ forloop.counter }}: {{image.image_annotations}}<br />
|
||||
</span>
|
||||
{% endfor %}
|
||||
</details>
|
||||
<a href="{% url 'rapids:question_anonymise_dicom' pk=question.pk %}"
|
||||
title="Anonymise dicom images">Anonymise dicoms</a><br />
|
||||
<a href="{% url 'rapids:question_anonymise_dicom' pk=question.pk %}"
|
||||
title="Anonymise dicom images">Anonymise dicoms</a><br />
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#edit-button").click(() => {
|
||||
@@ -127,34 +140,34 @@
|
||||
console.log("json_toolstates", json_toolstates)
|
||||
|
||||
$.ajax({
|
||||
url: "{% url 'rapids:question_save_annotation' pk=question.pk %}",
|
||||
data: {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
// Yes we do double encode the json....
|
||||
annotation: JSON.stringify(json_toolstates),
|
||||
},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
error: function (e) {
|
||||
toastr.warning(`Error saving annotations`)
|
||||
console.log(e);
|
||||
},
|
||||
url: "{% url 'rapids:question_save_annotation' pk=question.pk %}",
|
||||
data: {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
// Yes we do double encode the json....
|
||||
annotation: JSON.stringify(json_toolstates),
|
||||
},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
error: function (e) {
|
||||
toastr.warning(`Error saving annotations`)
|
||||
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) {
|
||||
console.log(data);
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
if (data.status == "success") {
|
||||
toastr.info('Annotations saved')
|
||||
} else {
|
||||
toastr.warning('Error saving annotations')
|
||||
}
|
||||
})
|
||||
console.log(data);
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
if (data.status == "success") {
|
||||
toastr.info('Annotations saved')
|
||||
} else {
|
||||
toastr.warning('Error saving annotations')
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
console.log('[Done]');
|
||||
})
|
||||
})
|
||||
|
||||
$("#cancel-add-to-exam").click(function (evt) {
|
||||
@@ -168,28 +181,28 @@
|
||||
$("#cancel-add-to-exam").toggle();
|
||||
|
||||
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: '',
|
||||
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)
|
||||
}))
|
||||
})
|
||||
}).data("exam-id", obj.id).click((evt) => {
|
||||
addToExam(evt)
|
||||
}))
|
||||
})
|
||||
})
|
||||
.done(function () {
|
||||
//alert( "second success" );
|
||||
})
|
||||
//alert( "second success" );
|
||||
})
|
||||
.fail(function () {
|
||||
//alert( "error" );
|
||||
})
|
||||
//alert( "error" );
|
||||
})
|
||||
.always(function () {
|
||||
//alert( "finished" );
|
||||
});
|
||||
//alert( "finished" );
|
||||
});
|
||||
|
||||
return;
|
||||
|
||||
@@ -200,7 +213,7 @@
|
||||
let ids = [];
|
||||
ids.push(exam_button.dataset.qid);
|
||||
|
||||
// if no question selected
|
||||
// if no question selected
|
||||
if (ids.length < 1) {
|
||||
toastr.info('No question selected.');
|
||||
return
|
||||
@@ -209,28 +222,28 @@
|
||||
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
|
||||
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);
|
||||
console.log(data);
|
||||
|
||||
if (data.status == "success") {
|
||||
toastr.info('Questions added to exams.')
|
||||
}
|
||||
})
|
||||
if (data.status == "success") {
|
||||
toastr.info('Questions added to exams.')
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
$("#exam-options").empty();
|
||||
})
|
||||
console.log('[Done]');
|
||||
$("#exam-options").empty();
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
@@ -241,6 +254,29 @@
|
||||
|
||||
$("#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 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 %}",
|
||||
type: 'PATCH',
|
||||
headers: {
|
||||
@@ -249,71 +285,48 @@
|
||||
timeout: 3000,
|
||||
data: {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
normal: n,
|
||||
laterality: el.dataset.lat,
|
||||
}
|
||||
})
|
||||
.done(function (data) {
|
||||
.done(function (data) {
|
||||
console.log(data);
|
||||
toastr.info('Answer updated')
|
||||
})
|
||||
.fail(function () {
|
||||
.fail(function () {
|
||||
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) => {
|
||||
$(el).append($("<span class='correct'>[Add Correct]</span>").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
|
||||
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);
|
||||
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
|
||||
})
|
||||
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]');
|
||||
})
|
||||
console.log('[Done]');
|
||||
})
|
||||
}))
|
||||
|
||||
});
|
||||
@@ -324,63 +337,63 @@
|
||||
// Add button to confirm answer is correct
|
||||
$(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
|
||||
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);
|
||||
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
|
||||
})
|
||||
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]');
|
||||
})
|
||||
console.log('[Done]');
|
||||
})
|
||||
}))
|
||||
|
||||
// Add button to confirm answer is incorrect
|
||||
$(el).append($("<span class='confirm'>[Incorrect]</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: 0,
|
||||
},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
})
|
||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||
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);
|
||||
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
|
||||
})
|
||||
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]');
|
||||
})
|
||||
console.log('[Done]');
|
||||
})
|
||||
}))
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user