fix longs tests
This commit is contained in:
+20
-2
@@ -1587,6 +1587,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
raise Http404("No available exam")
|
||||
|
||||
# TODO: check access for logged in users
|
||||
print("TEST", cid)
|
||||
|
||||
# Check access for users
|
||||
if request.user.is_anonymous:
|
||||
@@ -1722,9 +1723,12 @@ 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)
|
||||
|
||||
print("CID", cid)
|
||||
|
||||
if not exam.active and not self.check_user_access(request.user, pk):
|
||||
raise Http404("No available exam")
|
||||
@@ -1735,6 +1739,8 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
else:
|
||||
user_id = request.user.pk
|
||||
|
||||
print("CID", cid)
|
||||
|
||||
if not exam.check_cid_user(cid, passcode, request, user_id):
|
||||
raise Http404("No available exam")
|
||||
|
||||
@@ -1795,16 +1801,19 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
).first()
|
||||
# user_answer = cid_user_answers_q_map[q]
|
||||
|
||||
print("QUSETION", q)
|
||||
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
|
||||
else:
|
||||
ans = user_answer.get_answer()
|
||||
answer_score = user_answer.get_answer_score()
|
||||
print("ans", ans)
|
||||
print("ans score", answer_score)
|
||||
|
||||
correct_answer = q.get_primary_answer()
|
||||
|
||||
@@ -1815,6 +1824,8 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
answers_marks.append(answer_score)
|
||||
answers_and_marks.append((ans, answer_score, correct_answer))
|
||||
|
||||
print(answers_marks)
|
||||
|
||||
if "unmarked" in answers_marks:
|
||||
answered = [i for i in answers_marks if type(i) == int]
|
||||
total_score = sum(answered)
|
||||
@@ -1823,7 +1834,14 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
else:
|
||||
total_score = sum(answers_marks)
|
||||
|
||||
max_score = len(questions) * 2
|
||||
match self.app_name:
|
||||
case "rapids" | "anatomy":
|
||||
max_score = len(questions) * 2
|
||||
case "longs":
|
||||
max_score = len(questions) * 8
|
||||
case _:
|
||||
max_score = len(questions)
|
||||
|
||||
|
||||
template_context = {
|
||||
"exam": exam,
|
||||
|
||||
Reference in New Issue
Block a user