.
This commit is contained in:
@@ -35,7 +35,9 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% if can_edit %}
|
{% if can_edit %}
|
||||||
<p><button id='button-edit-order' title='click and drag questions to change order' data-posturl="{% url 'anatomy:exam_json_edit' pk=exam.pk %}">Edit question order / Delete questions</button></p>
|
<p>
|
||||||
|
<button id='button-edit-order' title='click and drag questions to change order' data-posturl="{% url 'anatomy:exam_json_edit' pk=exam.pk %}">Edit question order / Delete questions</button>
|
||||||
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div>
|
<div>
|
||||||
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
|
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
|
||||||
|
|||||||
+52
-13
@@ -3,6 +3,7 @@ import django_filters
|
|||||||
from .models import Rapid, CidUserAnswer, Exam
|
from .models import Rapid, CidUserAnswer, Exam
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
def get_exams(request):
|
def get_exams(request):
|
||||||
if request is None:
|
if request is None:
|
||||||
return Exam.objects.none()
|
return Exam.objects.none()
|
||||||
@@ -14,6 +15,7 @@ def get_exams(request):
|
|||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
def get_authors(request):
|
def get_authors(request):
|
||||||
if request is None:
|
if request is None:
|
||||||
return User.objects.none()
|
return User.objects.none()
|
||||||
@@ -25,22 +27,47 @@ def get_authors(request):
|
|||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class RapidFilter(django_filters.FilterSet):
|
class RapidFilter(django_filters.FilterSet):
|
||||||
exams = django_filters.ModelMultipleChoiceFilter(queryset=get_exams, null_label="No exam")
|
exams = django_filters.ModelMultipleChoiceFilter(
|
||||||
author = django_filters.ModelMultipleChoiceFilter(queryset=get_authors, null_label="No author")
|
queryset=get_exams, null_label="No exam"
|
||||||
|
)
|
||||||
|
author = django_filters.ModelMultipleChoiceFilter(
|
||||||
|
queryset=get_authors, null_label="No author"
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Rapid
|
model = Rapid
|
||||||
fields = ("normal", "abnormality", "region", "examination",
|
fields = {
|
||||||
"laterality",
|
"normal": ["exact"],
|
||||||
#"site",
|
"abnormality": ["exact"],
|
||||||
"created_date", "open_access")
|
"region": ["exact"],
|
||||||
|
"examination": ["exact"],
|
||||||
|
"laterality": ["exact"],
|
||||||
|
# "site",
|
||||||
|
"created_date": ["exact"],
|
||||||
|
"open_access": ["exact"],
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, data=None, queryset=None, prefix=None, strict=None, user=None, request=None):
|
def __init__(
|
||||||
|
self,
|
||||||
|
data=None,
|
||||||
|
queryset=None,
|
||||||
|
prefix=None,
|
||||||
|
strict=None,
|
||||||
|
user=None,
|
||||||
|
request=None,
|
||||||
|
):
|
||||||
if not request.user.groups.filter(name="rapid_checker").exists():
|
if not request.user.groups.filter(name="rapid_checker").exists():
|
||||||
queryset = queryset.filter(open_access=True) | queryset.filter(author__id=request.user.id)
|
queryset = queryset.filter(open_access=True) | queryset.filter(
|
||||||
super(RapidFilter, self).__init__(data=data, queryset=queryset, prefix=prefix, request=request)
|
author__id=request.user.id
|
||||||
|
)
|
||||||
|
super(RapidFilter, self).__init__(
|
||||||
|
data=data, queryset=queryset, prefix=prefix, request=request
|
||||||
|
)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RapidUserAnswerFilter(django_filters.FilterSet):
|
class RapidUserAnswerFilter(django_filters.FilterSet):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = CidUserAnswer
|
model = CidUserAnswer
|
||||||
@@ -49,14 +76,26 @@ class RapidUserAnswerFilter(django_filters.FilterSet):
|
|||||||
"user",
|
"user",
|
||||||
"normal",
|
"normal",
|
||||||
"answer",
|
"answer",
|
||||||
#"answer_compare",
|
# "answer_compare",
|
||||||
"exam",
|
"exam",
|
||||||
"created",
|
"created",
|
||||||
"updated",
|
"updated",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, data=None, queryset=None, prefix=None, strict=None, user=None, request=None):
|
def __init__(
|
||||||
|
self,
|
||||||
|
data=None,
|
||||||
|
queryset=None,
|
||||||
|
prefix=None,
|
||||||
|
strict=None,
|
||||||
|
user=None,
|
||||||
|
request=None,
|
||||||
|
):
|
||||||
if not request.user.groups.filter(name="rapid_checker").exists():
|
if not request.user.groups.filter(name="rapid_checker").exists():
|
||||||
queryset = queryset.filter(open_access=True) | queryset.filter(author__id=request.user.id)
|
queryset = queryset.filter(open_access=True) | queryset.filter(
|
||||||
super(RapidUserAnswerFilter, self).__init__(data=data, queryset=queryset, prefix=prefix, request=request)
|
author__id=request.user.id
|
||||||
|
)
|
||||||
|
super(RapidUserAnswerFilter, self).__init__(
|
||||||
|
data=data, queryset=queryset, prefix=prefix, request=request
|
||||||
|
)
|
||||||
pass
|
pass
|
||||||
@@ -11,24 +11,24 @@
|
|||||||
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(`Exam: ${data.name} [${data.id}]
|
toastr.info(`Exam: ${data.name} [${data.id}]
|
||||||
Active state changed to: ${data.active}.`)
|
Active state changed to: ${data.active}.`)
|
||||||
}
|
}
|
||||||
// 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
|
||||||
})
|
})
|
||||||
.fail(function (data) {
|
.fail(function (data) {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
toastr.error(`Failed to change state<br/>${data.responseJSON.status}`);
|
toastr.error(`Failed to change state<br/>${data.responseJSON.status}`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
$("#exam-publish-results-switch, .exam-publish-results-switch").on("change", function (evt) {
|
$("#exam-publish-results-switch, .exam-publish-results-switch").on("change", function (evt) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -40,23 +40,23 @@
|
|||||||
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(`Exam: ${data.name} [${data.id}]
|
toastr.info(`Exam: ${data.name} [${data.id}]
|
||||||
Published state changed to: ${data.publish_results}.`)
|
Published state changed to: ${data.publish_results}.`)
|
||||||
}
|
}
|
||||||
// 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
|
||||||
})
|
})
|
||||||
.fail(function (data) {
|
.fail(function (data) {
|
||||||
toastr.error(`Failed to change state`);
|
toastr.error(`Failed to change state`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
$("#button-open-access").click(function (evt) {
|
$("#button-open-access").click(function (evt) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -68,23 +68,23 @@
|
|||||||
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('Question access state changed.');
|
toastr.info('Question access state changed.');
|
||||||
} else {
|
} else {
|
||||||
toastr.warning("Error");
|
toastr.warning("Error");
|
||||||
toastr.info(data.status);
|
toastr.info(data.status);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail((e) => {
|
.fail((e) => {
|
||||||
toastr.warning(`Error, ${e}`);
|
toastr.warning(`Error, ${e}`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
$("#button-closed-access").click(function (evt) {
|
$("#button-closed-access").click(function (evt) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -96,28 +96,36 @@
|
|||||||
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('Question access state changed.');
|
toastr.info('Question access state changed.');
|
||||||
} else {
|
} else {
|
||||||
toastr.warning("Error");
|
toastr.warning("Error");
|
||||||
toastr.info(data.status);
|
toastr.info(data.status);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail((e) => {
|
.fail((e) => {
|
||||||
toastr.warning(`Error, ${e}`);
|
toastr.warning(`Error, ${e}`);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
$("#button-edit-order").click(function (evt) {
|
$("#button-edit-order").click(function (evt) {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
sortable('.sortable');
|
sortable('.sortable');
|
||||||
|
|
||||||
|
$("#full-question-list").after($("<button id='random-order-button'>Randomise order</button>").click(() =>{
|
||||||
|
var ul = document.getElementById("full-question-list");
|
||||||
|
for (var i = ul.children.length; i >= 0; i--) {
|
||||||
|
ul.appendChild(ul.children[Math.random() * i | 0]);
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
$("#full-question-list li").each((n, el) => {
|
$("#full-question-list li").each((n, el) => {
|
||||||
$(el).append($(
|
$(el).append($(
|
||||||
"<span class='exam-question-delete flex-col'><button>DELETE</button></span>"
|
"<span class='exam-question-delete flex-col'><button>DELETE</button></span>"
|
||||||
@@ -127,7 +135,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
$("#full-question-list").append($(
|
$("#full-question-list").after($(
|
||||||
"<button title='click and drag questions to change order'>Save exam order</button>"
|
"<button title='click and drag questions to change order'>Save exam order</button>"
|
||||||
).click(() => {
|
).click(() => {
|
||||||
new_order = [];
|
new_order = [];
|
||||||
@@ -143,17 +151,17 @@
|
|||||||
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('Exam order changed.')
|
toastr.info('Exam order changed.')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
console.log('[Done]');
|
console.log('[Done]');
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user