Skip to content

Commit fb68ea9

Browse files
committed
added score(number of correct answers) in quiz result
1 parent 0de01ae commit fb68ea9

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
media/
12
# Byte-compiled / optimized / DLL files
23
__pycache__/
34
*.py[cod]

django_school/classroom/templates/classroom/teachers/quiz_results.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111
</ol>
1212
</nav>
1313
<h2 class="mb-3">{{ quiz.name }} Results</h2>
14-
14+
<p class="lead">Total Questions: {{total_questions}}</p>
1515
<div class="card">
1616
<div class="card-header">
1717
<strong>Taken Quizzes</strong>
18-
<span class="badge badge-pill badge-primary float-right">Average Score: {{ quiz_score.average_score|default_if_none:0.0 }}</span>
18+
<span class="badge badge-pill badge-primary float-right">Average Score: {{ quiz_score.average_score|default_if_none:0.0|floatformat:2 }}</span>
1919
</div>
2020
<table class="table mb-0">
2121
<thead>
2222
<tr>
2323
<th>Student</th>
2424
<th>Date</th>
25+
<th>Score</th>
2526
<th>Percentage</th>
2627
</tr>
2728
</thead>
@@ -30,6 +31,7 @@ <h2 class="mb-3">{{ quiz.name }} Results</h2>
3031
<tr>
3132
<td>{{ taken_quiz.student.user.username }}</td>
3233
<td>{{ taken_quiz.date|naturaltime }}</td>
34+
<td>{{ taken_quiz.score }}</td>
3335
<td>{{ taken_quiz.percentage }}</td>
3436
</tr>
3537
{% endfor %}

django_school/classroom/views/teachers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def get_context_data(self, **kwargs):
115115
extra_context = {
116116
'taken_quizzes': taken_quizzes,
117117
'total_taken_quizzes': total_taken_quizzes,
118-
'quiz_score': quiz_score
118+
'quiz_score': quiz_score,
119+
'total_questions':quiz.questions.count()
119120
}
120121
kwargs.update(extra_context)
121122
return super().get_context_data(**kwargs)

0 commit comments

Comments
 (0)