.
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
<div id="single-dicom-viewer" class="dicom-viewer" data-images=""
|
||||||
|
data-annotations=''>
|
||||||
|
</div>
|
||||||
|
<button class="previous-btn">Previous</button>
|
||||||
|
<button class="next-btn">Next</button>
|
||||||
|
|
||||||
|
|
||||||
|
{% for id in ids %}
|
||||||
|
{{id}}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
+7
-1
@@ -17,7 +17,13 @@ urlpatterns = [
|
|||||||
# path("verified/<int:pk>/", views.verified_detail, name="verified_detail"),
|
# path("verified/<int:pk>/", views.verified_detail, name="verified_detail"),
|
||||||
path(
|
path(
|
||||||
"question/<int:pk>/", views.GenericViews.question_detail, name="question_detail"
|
"question/<int:pk>/", views.GenericViews.question_detail, name="question_detail"
|
||||||
), # path("question/<int:pk>/json", views.question_json, name="question_json"),
|
),
|
||||||
|
path("question/<int:pk>/json", views.question_json, name="question_json"),
|
||||||
|
path(
|
||||||
|
"question/<int:pk>/json/unbased",
|
||||||
|
views.question_json_unbased,
|
||||||
|
name="question_json_unbased",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"question/<int:pk>/save_annotation",
|
"question/<int:pk>/save_annotation",
|
||||||
views.question_save_annotation,
|
views.question_save_annotation,
|
||||||
|
|||||||
+62
-22
@@ -105,6 +105,7 @@ def normaliseScore(score):
|
|||||||
|
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
|
|
||||||
class AuthorOrCheckerRequiredMixin(object):
|
class AuthorOrCheckerRequiredMixin(object):
|
||||||
def get_object(self, *args, **kwargs):
|
def get_object(self, *args, **kwargs):
|
||||||
obj = super().get_object(*args, **kwargs)
|
obj = super().get_object(*args, **kwargs)
|
||||||
@@ -114,6 +115,7 @@ class AuthorOrCheckerRequiredMixin(object):
|
|||||||
raise PermissionDenied() # or Http404
|
raise PermissionDenied() # or Http404
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def rapid_split(request, pk):
|
def rapid_split(request, pk):
|
||||||
rapid = get_object_or_404(Rapid, pk=pk)
|
rapid = get_object_or_404(Rapid, pk=pk)
|
||||||
@@ -129,7 +131,7 @@ def rapid_split(request, pk):
|
|||||||
old_abnormality = rapid.abnormality.all()
|
old_abnormality = rapid.abnormality.all()
|
||||||
old_region = rapid.region.all()
|
old_region = rapid.region.all()
|
||||||
old_examination = rapid.examination.all()
|
old_examination = rapid.examination.all()
|
||||||
#old_site = rapid.site.all()
|
# old_site = rapid.site.all()
|
||||||
old_author = rapid.author.all()
|
old_author = rapid.author.all()
|
||||||
|
|
||||||
if not images:
|
if not images:
|
||||||
@@ -143,7 +145,7 @@ def rapid_split(request, pk):
|
|||||||
rapid.abnormality.set(old_abnormality)
|
rapid.abnormality.set(old_abnormality)
|
||||||
rapid.region.set(old_region)
|
rapid.region.set(old_region)
|
||||||
rapid.examination.set(old_examination)
|
rapid.examination.set(old_examination)
|
||||||
#rapid.site.set(old_site)
|
# rapid.site.set(old_site)
|
||||||
rapid.author.set(old_author)
|
rapid.author.set(old_author)
|
||||||
images[n].rapid = rapid
|
images[n].rapid = rapid
|
||||||
images[n].save()
|
images[n].save()
|
||||||
@@ -157,8 +159,6 @@ def rapid_split(request, pk):
|
|||||||
return render(request, "rapids/question_detail.html", {"question": rapid})
|
return render(request, "rapids/question_detail.html", {"question": rapid})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RapidCreationDefaultView(LoginRequiredMixin, UpdateView):
|
class RapidCreationDefaultView(LoginRequiredMixin, UpdateView):
|
||||||
model = RapidCreationDefault
|
model = RapidCreationDefault
|
||||||
form_class = RapidCreationDefaultForm
|
form_class = RapidCreationDefaultForm
|
||||||
@@ -195,7 +195,6 @@ class RapidCreationDefaultView(LoginRequiredMixin, UpdateView):
|
|||||||
# form.instance.author.add(self.request.user.id)
|
# form.instance.author.add(self.request.user.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def rapid_clone(request, pk):
|
def rapid_clone(request, pk):
|
||||||
new_item = get_object_or_404(Rapid, pk=pk)
|
new_item = get_object_or_404(Rapid, pk=pk)
|
||||||
@@ -526,7 +525,7 @@ def loadJsonAnswer(answer):
|
|||||||
|
|
||||||
exam = get_object_or_404(Exam, pk=eid)
|
exam = get_object_or_404(Exam, pk=eid)
|
||||||
|
|
||||||
#if not exam.active:
|
# if not exam.active:
|
||||||
# return False, JsonResponse(
|
# return False, JsonResponse(
|
||||||
# {"success": False, "error": "No active exam: {}".format(eid)}
|
# {"success": False, "error": "No active exam: {}".format(eid)}
|
||||||
# )
|
# )
|
||||||
@@ -573,10 +572,12 @@ def loadJsonAnswer(answer):
|
|||||||
def mark_all(request, exam_pk, sk):
|
def mark_all(request, exam_pk, sk):
|
||||||
return mark(request, exam_pk, sk, unmarked_exam_answers_only=False)
|
return mark(request, exam_pk, sk, unmarked_exam_answers_only=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def mark_review(request, exam_pk, sk):
|
def mark_review(request, exam_pk, sk):
|
||||||
return mark(request, exam_pk, sk, unmarked_exam_answers_only=False, review=True)
|
return mark(request, exam_pk, sk, unmarked_exam_answers_only=False, review=True)
|
||||||
|
|
||||||
|
|
||||||
# @user_passes_test(user_is_admin, login_url="/accounts/login")
|
# @user_passes_test(user_is_admin, login_url="/accounts/login")
|
||||||
@login_required
|
@login_required
|
||||||
def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
||||||
@@ -605,7 +606,6 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
raise Http404("Exam question does not exist")
|
raise Http404("Exam question does not exist")
|
||||||
|
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
|
||||||
form = MarkRapidQuestionForm(request.POST)
|
form = MarkRapidQuestionForm(request.POST)
|
||||||
@@ -657,12 +657,11 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
|||||||
else:
|
else:
|
||||||
form = MarkRapidQuestionForm()
|
form = MarkRapidQuestionForm()
|
||||||
|
|
||||||
#answers_dict = {}
|
# answers_dict = {}
|
||||||
|
|
||||||
#for ans in question.answers.all():
|
# for ans in question.answers.all():
|
||||||
# answers_dict[ans.answer_compare] = ans
|
# answers_dict[ans.answer_compare] = ans
|
||||||
|
|
||||||
|
|
||||||
correct_answers = []
|
correct_answers = []
|
||||||
half_mark_answers = []
|
half_mark_answers = []
|
||||||
incorrect_answers = []
|
incorrect_answers = []
|
||||||
@@ -678,17 +677,22 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
|||||||
incorrect_answers.remove("normal")
|
incorrect_answers.remove("normal")
|
||||||
else:
|
else:
|
||||||
if review:
|
if review:
|
||||||
unmarked_user_answers = question.get_user_answers(exam_pk=exam_pk, include_normal=False)
|
unmarked_user_answers = question.get_user_answers(
|
||||||
|
exam_pk=exam_pk, include_normal=False
|
||||||
|
)
|
||||||
elif unmarked_exam_answers_only:
|
elif unmarked_exam_answers_only:
|
||||||
unmarked_user_answers = question.get_unmarked_user_answers(exam_pk=exam_pk)
|
unmarked_user_answers = question.get_unmarked_user_answers(exam_pk=exam_pk)
|
||||||
else:
|
else:
|
||||||
unmarked_user_answers = question.get_unmarked_user_answers()
|
unmarked_user_answers = question.get_unmarked_user_answers()
|
||||||
|
|
||||||
|
|
||||||
if not unmarked_exam_answers_only:
|
if not unmarked_exam_answers_only:
|
||||||
correct_answers = question.answers.filter(status=Answer.MarkOptions.CORRECT)
|
correct_answers = question.answers.filter(status=Answer.MarkOptions.CORRECT)
|
||||||
half_mark_answers = question.answers.filter(status=Answer.MarkOptions.HALF_MARK)
|
half_mark_answers = question.answers.filter(
|
||||||
incorrect_answers = question.answers.filter(status=Answer.MarkOptions.INCORRECT)
|
status=Answer.MarkOptions.HALF_MARK
|
||||||
|
)
|
||||||
|
incorrect_answers = question.answers.filter(
|
||||||
|
status=Answer.MarkOptions.INCORRECT
|
||||||
|
)
|
||||||
|
|
||||||
if review:
|
if review:
|
||||||
for ans in unmarked_user_answers:
|
for ans in unmarked_user_answers:
|
||||||
@@ -706,7 +710,6 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
|||||||
unmarked_answers_bool = True
|
unmarked_answers_bool = True
|
||||||
review_user_answers.append((ans, mark))
|
review_user_answers.append((ans, mark))
|
||||||
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"rapids/mark.html",
|
"rapids/mark.html",
|
||||||
@@ -780,17 +783,15 @@ def exam_scores_cid(request, pk):
|
|||||||
|
|
||||||
by_question[q].append((ans, answer_score))
|
by_question[q].append((ans, answer_score))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
user_scores = {}
|
user_scores = {}
|
||||||
user_scores_normalised = {}
|
user_scores_normalised = {}
|
||||||
for user in user_answers_marks:
|
for user in user_answers_marks:
|
||||||
user_scores[user] = sum(
|
user_scores[user] = sum(
|
||||||
[i for i in user_answers_marks[user] if i != "unmarked"]
|
[i for i in user_answers_marks[user] if i != "unmarked"]
|
||||||
)
|
)
|
||||||
user_scores_normalised[user] = normaliseScore(sum(
|
user_scores_normalised[user] = normaliseScore(
|
||||||
[i for i in user_answers_marks[user] if i != "unmarked"]
|
sum([i for i in user_answers_marks[user] if i != "unmarked"])
|
||||||
))
|
)
|
||||||
|
|
||||||
user_scores_list = list(user_scores.values())
|
user_scores_list = list(user_scores.values())
|
||||||
|
|
||||||
@@ -859,7 +860,6 @@ def exam_scores_cid_user(request, pk, cid):
|
|||||||
answers_marks = []
|
answers_marks = []
|
||||||
answers = []
|
answers = []
|
||||||
|
|
||||||
|
|
||||||
view_all_results = False
|
view_all_results = False
|
||||||
if request.user.groups.filter(name="view_all_results").exists():
|
if request.user.groups.filter(name="view_all_results").exists():
|
||||||
view_all_results = True
|
view_all_results = True
|
||||||
@@ -1103,6 +1103,7 @@ def question_save_annotation(request, pk):
|
|||||||
data = {"status": "error"}
|
data = {"status": "error"}
|
||||||
return JsonResponse(data, status=400)
|
return JsonResponse(data, status=400)
|
||||||
|
|
||||||
|
|
||||||
class ExamClone(ExamCloneMixin, ExamCreate):
|
class ExamClone(ExamCloneMixin, ExamCreate):
|
||||||
"""Clone exam view"""
|
"""Clone exam view"""
|
||||||
|
|
||||||
@@ -1115,8 +1116,47 @@ def get_question_by_hash(request):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
question = RapidImage.objects.get(image_md5_hash=hash)
|
question = RapidImage.objects.get(image_md5_hash=hash)
|
||||||
data = {"status": "success", "id": question.pk, "url": question.rapid.get_absolute_url()}
|
data = {
|
||||||
|
"status": "success",
|
||||||
|
"id": question.pk,
|
||||||
|
"url": question.rapid.get_absolute_url(),
|
||||||
|
}
|
||||||
return JsonResponse(data, status=200)
|
return JsonResponse(data, status=200)
|
||||||
except RapidImage.DoesNotExist:
|
except RapidImage.DoesNotExist:
|
||||||
data = {"status": "success", "id": False}
|
data = {"status": "success", "id": False}
|
||||||
return JsonResponse(data, status=200)
|
return JsonResponse(data, status=200)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: better permissions
|
||||||
|
@login_required
|
||||||
|
def question_json_unbased(request, pk):
|
||||||
|
"""
|
||||||
|
No (file based) caching is enabled for unbased quesitons
|
||||||
|
"""
|
||||||
|
question = get_object_or_404(Rapid, pk=pk)
|
||||||
|
|
||||||
|
question_json = question.get_question_json(based=False)
|
||||||
|
return JsonResponse(question_json)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def question_json(request, pk):
|
||||||
|
question = get_object_or_404(Rapid, pk=pk)
|
||||||
|
|
||||||
|
question_json = question.get_question_json(based=True)
|
||||||
|
return JsonResponse(question_json)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def question_viewer(request, pk):
|
||||||
|
#question = get_object_or_404(Rapid, pk=pk)
|
||||||
|
|
||||||
|
ids = request.GET.get("ids").split(",")
|
||||||
|
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"rapids/question_viewer.html",
|
||||||
|
{
|
||||||
|
"ids": ids,
|
||||||
|
},
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user