Skip to content

Commit

Permalink
Improve course grades view
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Oct 31, 2023
1 parent 8d68f21 commit c7289e3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
20 changes: 16 additions & 4 deletions dojo_plugin/pages/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,25 @@ def view_all_grades(dojo):

average_grade = sum(grade["overall_grade"] for grade in grades) / len(grades) if grades else 0.0
average_letter_grade = get_letter_grade(dojo, average_grade)
average_grade_summary = f"{average_letter_grade} ({average_grade * 100:.2f}%)"
average_grade_details = []
cumulative_count = 0
for letter_grade in dojo.course["letter_grades"]:
count = sum(1 for grade in grades if grade["letter_grade"] == letter_grade)
cumulative_count += count
percent = f"{count / len(grades) * 100:.2f}%" if grades else "0.00%"
cumulative_percent = f"{cumulative_count / len(grades) * 100:.2f}%" if grades else "0.00%"
average_grade_details.append({
"Grade": letter_grade,
"Count": count,
"Percent": percent,
"Cumulative Percent": cumulative_percent,
})
grade_statistics = {
"Average": f"{average_letter_grade} ({average_grade * 100:.2f}%)",
"Average": (average_grade_summary, average_grade_details),
}

for letter_grade in dojo.course["letter_grades"]:
count = sum(1 for grade in grades if grade["letter_grade"] == letter_grade)
grade_statistics[letter_grade] = f"{count} ({count / len(grades) * 100:.2f}%)"


students = {student.user_id: student.token for student in dojo.students}

Expand Down
25 changes: 23 additions & 2 deletions dojo_theme/templates/grades_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,31 @@ <h1>All Grades</h1>
{% endfor %}
</tbody>
<tfoot>
{% for statistic, value in grade_statistics.items() %}
{% for statistic, (summary, details) in grade_statistics.items() %}
<tr>
<td>{{ statistic }}</td>
<td>{{ value }}</td>
<td>
<details>
<summary>{{ summary }}</summary>
<table>
<thead>
<tr>
{% for column in details[0] %}
<td>{{ column }}</td>
</tr>
</thead>
<tbody>
{% for row in details %}
<tr>
{% for value in row.values() %}
<td>{{ value }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</details>
</td>
</tr>
{% endfor %}
</tfoot>
Expand Down

0 comments on commit c7289e3

Please sign in to comment.