Skip to content

Commit f409b0f

Browse files
committed
Sort students with common last names by first name
1 parent f9af902 commit f409b0f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tin/apps/assignments/views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def show_view(request, assignment_id):
8888
if query:
8989
active_period = "query"
9090
student_list = course.students.filter(full_name__icontains=query).order_by(
91-
"periods", "last_name"
91+
"periods", "last_name", "first_name"
9292
)
9393
elif course.period_set.exists():
9494
if period == "":
@@ -104,18 +104,18 @@ def show_view(request, assignment_id):
104104

105105
if period == "all":
106106
active_period = "all"
107-
student_list = course.students.all().order_by("periods", "last_name")
107+
student_list = course.students.all().order_by("periods", "last_name", "first_name")
108108
elif period == "none":
109109
active_period = "none"
110110
student_list = []
111111
else:
112112
active_period = get_object_or_404(
113113
Period.objects.filter(course=course), id=int(period)
114114
)
115-
student_list = active_period.students.all().order_by("last_name")
115+
student_list = active_period.students.all().order_by("last_name", "first_name")
116116
elif period == "all":
117117
active_period = "all"
118-
student_list = course.students.all().order_by("last_name")
118+
student_list = course.students.all().order_by("last_name", "first_name")
119119
else:
120120
active_period = "none"
121121
student_list = []
@@ -880,7 +880,7 @@ def scores_csv_view(request, assignment_id):
880880
writer = csv.writer(response)
881881
writer.writerow(["Name", "Username", "Period", "Raw Score", "Final Score", "Formatted Grade"])
882882

883-
for student in students.order_by("periods", "last_name"):
883+
for student in students.order_by("periods", "last_name", "first_name"):
884884
row = [student.full_name, student.username]
885885
periods = ", ".join([p.name for p in student.periods.filter(course=assignment.course)])
886886
row.append(periods)

0 commit comments

Comments
 (0)