diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index 52a39c91..012635b2 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -329,6 +329,10 @@ img.uploading:hover { color: lightblue; } +.physics-ans .user-answer-score-1 { + color: lightblue; +} + td.user-answer-score-0::after { content: "✗"; } diff --git a/physics/templates/physics/exam_scores.html b/physics/templates/physics/exam_scores.html index c72a63ff..72a7066b 100644 --- a/physics/templates/physics/exam_scores.html +++ b/physics/templates/physics/exam_scores.html @@ -7,9 +7,12 @@

Stats

+ Max score: {{max_score}}
Mean: {{mean}}, Median {{median}}, Mode {{mode}} - -

Distribution of results

{{plot|safe}}
+ +
+

Distribution of results

{{plot|safe}} +
@@ -25,4 +28,37 @@ {% endfor %}
-{% endblock %} +
+

Answers as a table

+ + + + {% for cid in cids %} + + {% endfor %} + + + {% for question in questions %} + + + {% for zipped_answers in by_question|get_item:question %} + + {% endfor %} + + {% endfor %} + + + {% for score in user_scores_list %} + + {% endfor %} + +
Candidate{{cid}}
Question {{forloop.counter}} +
    + {% for ans, score in zipped_answers %} +
  1. {{ans}}
  2. + {% endfor %} +
+
Score:{{score}}
+ +
+{% endblock %} \ No newline at end of file diff --git a/physics/views.py b/physics/views.py index 2d31833b..ace1bb6f 100644 --- a/physics/views.py +++ b/physics/views.py @@ -134,6 +134,7 @@ def exam_scores_cid(request, pk): user_answers = defaultdict(list) user_names = {} + by_question = defaultdict(list) unmarked = set() # Loop through all candidates @@ -147,6 +148,7 @@ def exam_scores_cid(request, pk): # skip if no answer user_answers_marks[cid].append(0) user_answers[cid].append("") + by_question[q].append(("", 0)) continue ans = s.get_answers() @@ -156,6 +158,10 @@ def exam_scores_cid(request, pk): user_answers_marks[cid].append(answer_scores) user_answers_and_marks[cid].append((ans, answer_scores)) + zipped_ans_scores = zip(ans, answer_scores) + + by_question[q].append(zipped_ans_scores) + user_scores = {} for user in user_answers_marks: user_scores[user] = sum([sum(i) for i in user_answers_marks[user]]) @@ -179,20 +185,24 @@ def exam_scores_cid(request, pk): fig = px.histogram(df, x=0, title="Distribution of scores", labels={"0": "Score"}, height=400, width=600) fig_html = fig.to_html() - total = len(questions) + max_score = len(questions) return render( request, "physics/exam_scores.html", { + "cids": cids, "exam": exam, "unmarked": unmarked, "questions": questions, + "by_question": by_question, "user_answers": dict(user_answers), "user_answers_marks": dict(user_answers_marks), "user_scores": user_scores, + "user_scores_list": user_scores_list, "user_names": user_names, "user_answers_and_marks": user_answers_and_marks, + "max_score": max_score, "mean": mean, "median": median, "mode": mode,