Skip to content

Commit

Permalink
Sort participation table by number of lectures attended (#2498)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornthiberg authored Sep 17, 2024
1 parent 4bfaf94 commit cdef179
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/track_participation.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ def get_participation_markdown(participation):
content += "| Index | Student Name | Number of Lectures Attended | Lecture(s) attended |\n"
content += "|-------|--------------|-------------------|----------------|\n"

# sort by number of lectures attended
sorted_participation = sorted(participation.items(), key=lambda item: len(item[1]), reverse=True)

index = 1
for author, lectures in participation.items():
for author, lectures in sorted_participation:
lecture_numbers = [f"L{LECTURE_DATES_TO_NUMBER[lecture]}" for lecture in sorted(lectures)]
lectures_list = " ".join(map(str, lecture_numbers))
total_lectures = len(lectures)
Expand All @@ -163,8 +166,11 @@ def get_participation_text(participation):
table = PrettyTable()
table.field_names = ["Index", "Student Name", "Number of Lectures Attended", "Lecture(s) attended"]

# sort by number of lectures attended
sorted_participation = sorted(participation.items(), key=lambda item: len(item[1]), reverse=True)

index = 1
for author, lectures in participation.items():
for author, lectures in sorted_participation:
lecture_numbers = [f"L{LECTURE_DATES_TO_NUMBER[lecture]}" for lecture in sorted(lectures)]
lectures_list = " ".join(map(str, lecture_numbers))
total_lectures = len(lectures)
Expand Down

0 comments on commit cdef179

Please sign in to comment.