From c7289e3b8e42645f8a12e2d3d5f5e2484adefe29 Mon Sep 17 00:00:00 2001 From: Connor Nelson Date: Tue, 31 Oct 2023 14:59:46 -0700 Subject: [PATCH] Improve course grades view --- dojo_plugin/pages/course.py | 20 ++++++++++++++++---- dojo_theme/templates/grades_admin.html | 25 +++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/dojo_plugin/pages/course.py b/dojo_plugin/pages/course.py index 7c66f8a0f..4cb7ac02c 100644 --- a/dojo_plugin/pages/course.py +++ b/dojo_plugin/pages/course.py @@ -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} diff --git a/dojo_theme/templates/grades_admin.html b/dojo_theme/templates/grades_admin.html index d2274c54d..752defb24 100644 --- a/dojo_theme/templates/grades_admin.html +++ b/dojo_theme/templates/grades_admin.html @@ -63,10 +63,31 @@

All Grades

{% endfor %} - {% for statistic, value in grade_statistics.items() %} + {% for statistic, (summary, details) in grade_statistics.items() %} {{ statistic }} - {{ value }} + +
+ {{ summary }} + + + + {% for column in details[0] %} + + + + + {% for row in details %} + + {% for value in row.values() %} + + {% endfor %} + + {% endfor %} + +
{{ column }}
{{ value }}
+
+ {% endfor %}