Skip to content

Commit

Permalink
Sort students with common last names by first name
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnans2006 committed Jan 8, 2025
1 parent f9af902 commit f409b0f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tin/apps/assignments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def show_view(request, assignment_id):
if query:
active_period = "query"
student_list = course.students.filter(full_name__icontains=query).order_by(
"periods", "last_name"
"periods", "last_name", "first_name"
)
elif course.period_set.exists():
if period == "":
Expand All @@ -104,18 +104,18 @@ def show_view(request, assignment_id):

if period == "all":
active_period = "all"
student_list = course.students.all().order_by("periods", "last_name")
student_list = course.students.all().order_by("periods", "last_name", "first_name")
elif period == "none":
active_period = "none"
student_list = []
else:
active_period = get_object_or_404(
Period.objects.filter(course=course), id=int(period)
)
student_list = active_period.students.all().order_by("last_name")
student_list = active_period.students.all().order_by("last_name", "first_name")
elif period == "all":
active_period = "all"
student_list = course.students.all().order_by("last_name")
student_list = course.students.all().order_by("last_name", "first_name")
else:
active_period = "none"
student_list = []
Expand Down Expand Up @@ -880,7 +880,7 @@ def scores_csv_view(request, assignment_id):
writer = csv.writer(response)
writer.writerow(["Name", "Username", "Period", "Raw Score", "Final Score", "Formatted Grade"])

for student in students.order_by("periods", "last_name"):
for student in students.order_by("periods", "last_name", "first_name"):
row = [student.full_name, student.username]
periods = ", ".join([p.name for p in student.periods.filter(course=assignment.course)])
row.append(periods)
Expand Down

0 comments on commit f409b0f

Please sign in to comment.