.
This commit is contained in:
+7
-2
@@ -747,10 +747,15 @@ def exam_scores_cid_user(request, pk, cid, passcode):
|
|||||||
|
|
||||||
# TODO:Need some kind of test for cid
|
# TODO:Need some kind of test for cid
|
||||||
|
|
||||||
questions = exam.exam_questions.all().prefetch_related("cid_user_answers", "answers")
|
questions = exam.exam_questions.all()#.prefetch_related("cid_user_answers", "answers")
|
||||||
|
|
||||||
cid_user_answers = CidUserAnswer.objects.filter(cid=cid, exam__id=pk)
|
cid_user_answers = CidUserAnswer.objects.filter(cid=cid, exam__id=pk)
|
||||||
|
|
||||||
|
cid_user_answers_q_map = {}
|
||||||
|
|
||||||
|
for ans in cid_user_answers:
|
||||||
|
cid_user_answers_q_map[ans.question] = ans
|
||||||
|
|
||||||
answers_and_marks = []
|
answers_and_marks = []
|
||||||
answers_marks = []
|
answers_marks = []
|
||||||
answers = []
|
answers = []
|
||||||
@@ -762,7 +767,7 @@ def exam_scores_cid_user(request, pk, cid, passcode):
|
|||||||
for q in questions:
|
for q in questions:
|
||||||
# Get user answer
|
# Get user answer
|
||||||
#user_answer = q.cid_user_answers.filter(cid=cid, exam__id=pk).first()
|
#user_answer = q.cid_user_answers.filter(cid=cid, exam__id=pk).first()
|
||||||
user_answer = cid_user_answers.filter(question=q).first()
|
user_answer = cid_user_answers_q_map[q]
|
||||||
|
|
||||||
if not user_answer or user_answer is None:
|
if not user_answer or user_answer is None:
|
||||||
# skip if no answer
|
# skip if no answer
|
||||||
|
|||||||
Reference in New Issue
Block a user