many Longs fixes
This commit is contained in:
+26
-5
@@ -72,9 +72,9 @@ from .models import (
|
||||
get_next_cid,
|
||||
)
|
||||
|
||||
from rapids.models import Rapid as RapidQuestion
|
||||
from rapids.models import Rapid as RapidQuestion, RapidImage
|
||||
from rapids.models import Exam as RapidExam
|
||||
from longs.models import Long as LongQuestion
|
||||
from longs.models import Long as LongQuestion, LongSeries
|
||||
from longs.models import Exam as LongExam
|
||||
from anatomy.models import AnatomyQuestion as AnatomyQuestion
|
||||
from anatomy.models import Exam as AnatomyExam
|
||||
@@ -795,6 +795,26 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
),
|
||||
)
|
||||
)
|
||||
elif self.app_name == "longs":
|
||||
questions = (
|
||||
exam.exam_questions.select_related()
|
||||
.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",
|
||||
)
|
||||
.all()
|
||||
)
|
||||
elif self.app_name == "rapids":
|
||||
questions = (
|
||||
exam.exam_questions.select_related()
|
||||
@@ -812,6 +832,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
"abnormality",
|
||||
"region",
|
||||
"examination",
|
||||
"author"
|
||||
)
|
||||
)
|
||||
# questions = (
|
||||
@@ -1868,7 +1889,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
user_answers_callstates = defaultdict(list)
|
||||
user_answers_callstates_counted = {}
|
||||
|
||||
if self.app_name in ("physics", "sbas"):
|
||||
if self.app_name in ("physics", "sbas", "longs"):
|
||||
cached_scores = False
|
||||
questions = exam.exam_questions.all()
|
||||
else:
|
||||
@@ -1932,7 +1953,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
callstate = s.get_answer_callstate()
|
||||
by_question[q][cid] = (ans, answer_score, callstate)
|
||||
user_answers_callstates[cid].append(callstate)
|
||||
elif self.app_name in ("rapids", "anatomy", "sbas"):
|
||||
elif self.app_name in ("anatomy", "sbas", "longs"):
|
||||
by_question[q][cid] = (ans, answer_score)
|
||||
else:
|
||||
zipped_ans_scores = zip(ans, answer_score)
|
||||
@@ -1942,7 +1963,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
user_scores_normalised = {}
|
||||
user_answer_count = {}
|
||||
for user in user_answers_marks:
|
||||
if self.app_name in ("rapids", "anatomy", "sbas"):
|
||||
if self.app_name in ("rapids", "anatomy", "sbas", "longs"):
|
||||
user_scores[user] = sum(
|
||||
[i for i in user_answers_marks[user] if i != "unmarked"]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user