allow merging of examinations
This commit is contained in:
+55
-17
@@ -54,6 +54,7 @@ from .forms import (
|
||||
CidUserExamForm,
|
||||
ExaminationForm,
|
||||
CidUserGroupForm,
|
||||
ExaminationMergeForm,
|
||||
SupervisorForm,
|
||||
UserUserForm,
|
||||
UserUserGroupForm,
|
||||
@@ -178,22 +179,59 @@ def create_examination(request):
|
||||
request, "rapids/create_simple.html", {"form": form, "name": "Examination"}
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def examination_detail(request, pk):
|
||||
examination = get_object_or_404(Examination, pk=pk)
|
||||
|
||||
merge_form = ExaminationMergeForm()
|
||||
# logging.debug(atlas.subspecialty.first().name.all())
|
||||
return render(
|
||||
request,
|
||||
"generic/examination_detail.html",
|
||||
{"examination": examination, "merge_form": merge_form},
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def examination_merge(request, pk):
|
||||
examination = get_object_or_404(Examination, pk=pk)
|
||||
|
||||
form = ExaminationMergeForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
examination_to_merge_into = form.cleaned_data["examination_to_merge_into"]
|
||||
|
||||
success = False
|
||||
if examination.merge_into(examination_to_merge_into):
|
||||
success = True
|
||||
|
||||
|
||||
else:
|
||||
examination_to_merge_into = False
|
||||
return render(
|
||||
request,
|
||||
"generic/examination_merge.html",
|
||||
{
|
||||
"form": form,
|
||||
"examination": examination,
|
||||
"examination_to_merge_into": examination_to_merge_into,
|
||||
"success": success
|
||||
},
|
||||
)
|
||||
|
||||
# logging.debug(atlas.subspecialty.first().name.all())
|
||||
return render(
|
||||
request,
|
||||
"generic/examination_merge.html",
|
||||
{
|
||||
"examination": examination,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def get_examination_id(request):
|
||||
if request.accepts("application/json")():
|
||||
@@ -818,17 +856,17 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
.prefetch_related(
|
||||
Prefetch(
|
||||
"series",
|
||||
queryset=LongSeries.objects.select_related("modality", "examination", "plane", "contrast").prefetch_related(
|
||||
Prefetch("images")
|
||||
),
|
||||
),
|
||||
"author"
|
||||
#to_attr="prefetched_primary_answer"
|
||||
# queryset=self.Answer.objects.filter(),
|
||||
#"series",
|
||||
#"abnormality",
|
||||
#"region",
|
||||
#"examination",
|
||||
queryset=LongSeries.objects.select_related(
|
||||
"modality", "examination", "plane", "contrast"
|
||||
).prefetch_related(Prefetch("images")),
|
||||
),
|
||||
"author"
|
||||
# to_attr="prefetched_primary_answer"
|
||||
# queryset=self.Answer.objects.filter(),
|
||||
# "series",
|
||||
# "abnormality",
|
||||
# "region",
|
||||
# "examination",
|
||||
)
|
||||
.all()
|
||||
)
|
||||
@@ -849,7 +887,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
"abnormality",
|
||||
"region",
|
||||
"examination",
|
||||
"author"
|
||||
"author",
|
||||
)
|
||||
)
|
||||
# questions = (
|
||||
@@ -1835,7 +1873,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
if not user_answer or user_answer is None:
|
||||
# skip if no answer
|
||||
score, text = q.get_unanswered_mark_and_text()
|
||||
#answers_marks.append(score)
|
||||
# answers_marks.append(score)
|
||||
# answers.append("")
|
||||
answer_score = score
|
||||
ans = text
|
||||
@@ -1872,7 +1910,6 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
case _:
|
||||
max_score = len(questions)
|
||||
|
||||
|
||||
template_context = {
|
||||
"exam": exam,
|
||||
"cid": cid,
|
||||
@@ -2092,7 +2129,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
exam.save()
|
||||
|
||||
missing_user_ids = valid_user_users - user_ids
|
||||
missing_user_ids = valid_user_users - user_ids
|
||||
|
||||
missing_users = []
|
||||
if missing_user_ids:
|
||||
@@ -2971,6 +3008,7 @@ class SupervisorCreate(CidManagerRequiredMixin, CreateView):
|
||||
class SupervisorList(CidManagerRequiredMixin, ListView):
|
||||
model = Supervisor
|
||||
|
||||
|
||||
class ExaminationView(SuperuserRequiredMixin, SingleTableMixin, FilterView):
|
||||
model = Examination
|
||||
table_class = ExaminationTable
|
||||
@@ -2987,4 +3025,4 @@ class ExaminationDelete(RevisionMixin, SuperuserRequiredMixin, DeleteView):
|
||||
|
||||
class ExaminationUpdate(UpdateView, SuperuserRequiredMixin):
|
||||
model = Examination
|
||||
form_class = ExaminationForm
|
||||
form_class = ExaminationForm
|
||||
|
||||
Reference in New Issue
Block a user