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