tidy up some longs related stuff
This commit is contained in:
@@ -870,7 +870,6 @@ class ExamBase(ExamOrCollectionGenericBase):
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
print("TESTING")
|
||||
if self.start_date and self.start_date is not None:
|
||||
print(f"Start date: {self.start_date:%d %B %Y}")
|
||||
return f"{self.name} ({self.start_date:%d %B %Y})"
|
||||
|
||||
+29
-8
@@ -1860,8 +1860,6 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
return self.exam_question_json_unbased(request, pk, sk, cid, passcode)
|
||||
|
||||
def exam_question_json_unbased(self, request, pk, sk, cid=None, passcode=None):
|
||||
print("TESTING")
|
||||
print("**************************")
|
||||
question = get_object_or_404(self.Question, pk=sk)
|
||||
exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
@@ -1951,7 +1949,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
).first()
|
||||
# user_answer = cid_user_answers_q_map[q]
|
||||
|
||||
print("QUSETION", q)
|
||||
feedback = None
|
||||
if not user_answer or user_answer is None:
|
||||
# skip if no answer
|
||||
score, text = q.get_unanswered_mark_and_text()
|
||||
@@ -1962,8 +1960,10 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
else:
|
||||
ans = user_answer.get_answer()
|
||||
answer_score = user_answer.get_answer_score()
|
||||
print("ans", ans)
|
||||
print("ans score", answer_score)
|
||||
|
||||
if self.app_name == "longs":
|
||||
feedback = user_answer.candidate_feedback
|
||||
|
||||
|
||||
match self.app_name:
|
||||
case "sbas":
|
||||
@@ -1998,7 +1998,11 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
answer_score = 0
|
||||
answers.append(ans)
|
||||
answers_marks.append(answer_score)
|
||||
answers_and_marks.append((ans, answer_score, correct_answer))
|
||||
|
||||
if self.app_name == "longs":
|
||||
answers_and_marks.append((ans, answer_score, correct_answer, feedback))
|
||||
else:
|
||||
answers_and_marks.append((ans, answer_score, correct_answer))
|
||||
|
||||
print(answers_marks)
|
||||
|
||||
@@ -2072,7 +2076,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
# user_answers_and_marks = defaultdict(list)
|
||||
user_answers_marks = defaultdict(list)
|
||||
user_answers = defaultdict(list)
|
||||
#user_answers = defaultdict(list)
|
||||
# user_names = {}
|
||||
# cid_passcodes = {}
|
||||
|
||||
@@ -2146,7 +2150,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
if answer_score == "unmarked":
|
||||
index = exam.get_question_index(q)
|
||||
unmarked.add(index)
|
||||
user_answers[cid].append(ans)
|
||||
#user_answers[cid].append(ans)
|
||||
user_answers_marks[cid].append(answer_score)
|
||||
|
||||
if self.app_name == "rapids":
|
||||
@@ -2159,10 +2163,27 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
zipped_ans_scores = zip(ans, answer_score)
|
||||
by_question[q][cid] = zipped_ans_scores
|
||||
|
||||
|
||||
|
||||
|
||||
user_scores = {}
|
||||
user_scores_normalised = {}
|
||||
user_answer_count = {}
|
||||
for user in user_answers_marks:
|
||||
|
||||
# For longs we have a default score of 3 (not 0) if unanswered
|
||||
# so we need to check for those
|
||||
if self.app_name == "longs":
|
||||
for question in questions:
|
||||
if question not in by_question:
|
||||
continue
|
||||
|
||||
if user not in by_question[question]:
|
||||
#print("NOT in")
|
||||
by_question[question][user] = ("Not answered", 3.0)
|
||||
user_answers_marks[user].append(3.0)
|
||||
|
||||
|
||||
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