.
This commit is contained in:
@@ -62,8 +62,8 @@
|
||||
[A]
|
||||
{% endif %}
|
||||
</td>
|
||||
{% for ans, score in by_question|get_item:question %}
|
||||
<td class="rapid-ans user-answer-score-{{score}}" title="answer score: {{score}}">{{ans}}</td>
|
||||
{% for cid in cids %}
|
||||
<td class="rapid-ans user-answer-score-{{ans_by_question|get_item:question}}" title="answer score: {{ans_by_question|get_item:question}}">{{ans_by_question|get_item:question}}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
+23
-18
@@ -526,7 +526,9 @@ def loadJsonAnswer(answer):
|
||||
exam = get_object_or_404(Exam, pk=eid)
|
||||
|
||||
if not exam.check_cid_user(answer["cid"], answer["passcode"]):
|
||||
return False, JsonResponse({"success": False, "error": "invalid cid / passcode"})
|
||||
return False, JsonResponse(
|
||||
{"success": False, "error": "invalid cid / passcode"}
|
||||
)
|
||||
|
||||
# if not exam.active:
|
||||
# return False, JsonResponse(
|
||||
@@ -580,6 +582,7 @@ def mark_all(request, exam_pk, sk):
|
||||
def mark_review(request, exam_pk, sk):
|
||||
return mark(request, exam_pk, sk, unmarked_exam_answers_only=False, review=True)
|
||||
|
||||
|
||||
@login_required
|
||||
def exam_scores_cid2(request, pk):
|
||||
exam = get_object_or_404(Exam, pk=pk)
|
||||
@@ -592,18 +595,16 @@ def exam_scores_cid2(request, pk):
|
||||
user_answers = defaultdict(list)
|
||||
user_names = {}
|
||||
|
||||
by_question = defaultdict(list)
|
||||
score_by_question = defaultdict(dict)
|
||||
ans_by_question = defaultdict(dict)
|
||||
unmarked = set()
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
|
||||
cid_user_answers = (
|
||||
CidUserAnswer.objects.filter(question__in=questions, exam__id=pk)
|
||||
)
|
||||
cid_user_answers = CidUserAnswer.objects.filter(question__in=questions, exam__id=pk)
|
||||
|
||||
cids = set()
|
||||
|
||||
|
||||
# Loop through all candidates
|
||||
for cid_user_answer in cid_user_answers:
|
||||
# Convoluted (probably...)
|
||||
@@ -614,14 +615,13 @@ def exam_scores_cid2(request, pk):
|
||||
|
||||
q = cid_user_answer.question
|
||||
|
||||
|
||||
if not s:
|
||||
# skip if no answer
|
||||
user_answers_marks[cid].append(0)
|
||||
user_answers[cid].append("")
|
||||
by_question[q].append(("", 0))
|
||||
continue
|
||||
elif s.normal:
|
||||
# if not s:
|
||||
# # skip if no answer
|
||||
# user_answers_marks[cid].append(0)
|
||||
# user_answers[cid].append("")
|
||||
# by_question[q].append(("", 0))
|
||||
# continue
|
||||
if s.normal:
|
||||
ans = "Normal"
|
||||
else:
|
||||
ans = s.answer
|
||||
@@ -633,7 +633,8 @@ def exam_scores_cid2(request, pk):
|
||||
user_answers_marks[cid].append(answer_score)
|
||||
user_answers_and_marks[cid].append((ans, answer_score))
|
||||
|
||||
by_question[q].append((ans, answer_score))
|
||||
score_by_question[q][cid] = answer_score
|
||||
ans_by_question[q][cid] = ans
|
||||
|
||||
user_scores = {}
|
||||
user_scores_normalised = {}
|
||||
@@ -677,11 +678,12 @@ def exam_scores_cid2(request, pk):
|
||||
request,
|
||||
"rapids/exam_scores.html",
|
||||
{
|
||||
"cids": cids,
|
||||
"cids": sorted(cids),
|
||||
"exam": exam,
|
||||
"unmarked": unmarked,
|
||||
"questions": questions,
|
||||
"by_question": by_question,
|
||||
"score_by_question": score_by_question,
|
||||
"ans_by_question": ans_by_question,
|
||||
"user_answers": dict(user_answers),
|
||||
"user_answers_marks": dict(user_answers_marks),
|
||||
"user_scores": user_scores,
|
||||
@@ -697,6 +699,7 @@ def exam_scores_cid2(request, pk):
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# @user_passes_test(user_is_admin, login_url="/accounts/login")
|
||||
@login_required
|
||||
def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
||||
@@ -1044,7 +1047,9 @@ class QuestionDelete(AuthorOrCheckerRequiredMixin, DeleteView):
|
||||
success_url = reverse_lazy("rapids:rapid_view")
|
||||
|
||||
|
||||
RapidExamViews = ExamViews(Exam, Rapid, CidUserAnswer, "rapids", "rapid", loadJsonAnswer)
|
||||
RapidExamViews = ExamViews(
|
||||
Exam, Rapid, CidUserAnswer, "rapids", "rapid", loadJsonAnswer
|
||||
)
|
||||
|
||||
|
||||
class ExamCreate(RevisionMixin, LoginRequiredMixin, CreateView):
|
||||
|
||||
Reference in New Issue
Block a user