Skip to content

Commit aa14cd4

Browse files
committed
Add a filter option to view teacher submissions for an assignment
1 parent dbef6ad commit aa14cd4

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

tin/apps/assignments/views.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ def show_view(request, assignment_id):
108108
)
109109
else:
110110
student_list = course.students.all().order_by("last_name", "first_name")
111+
elif period == "all":
112+
active_period = "all"
113+
student_list = course.students.all().order_by("last_name", "first_name")
114+
elif period == "none":
115+
active_period = "none"
116+
student_list = []
117+
elif period == "teachers":
118+
active_period = "teachers"
119+
student_list = course.teacher.all().order_by("last_name", "first_name")
111120
elif course.period_set.exists():
112121
if period == "":
113122
if request.user in course.teacher.all():
@@ -120,20 +129,14 @@ def show_view(request, assignment_id):
120129
else:
121130
period = "none"
122131

123-
if period == "all":
124-
active_period = "all"
125-
student_list = course.students.all().order_by("last_name", "first_name")
126-
elif period == "none":
132+
if period == "none":
127133
active_period = "none"
128134
student_list = []
129135
else:
130136
active_period = get_object_or_404(
131137
Period.objects.filter(course=course), id=int(period)
132138
)
133139
student_list = active_period.students.all().order_by("last_name", "first_name")
134-
elif period == "all":
135-
active_period = "all"
136-
student_list = course.students.all().order_by("last_name", "first_name")
137140
else:
138141
active_period = "none"
139142
student_list = []

tin/templates/assignments/show.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ <h2 style="border-top:1px solid lightgray;padding-top:15px;">Filter Submissions<
9595
href="{% url 'assignments:show' assignment.id %}?period=none">None</a>
9696
<a class="right tin-btn" {% if active_period == "all" %}style="color:#4fab4f;"{% endif %}
9797
href="{% url 'assignments:show' assignment.id %}?period=all">All</a>
98+
<a class="right tin-btn" {% if active_period == "teachers" %}style="color:#4fab4f;"{% endif %}
99+
href="{% url 'assignments:show' assignment.id %}?period=teachers">Teachers</a>
98100
&ensp;
99101
{% for period in period_set %}
100102
<a class="right tin-btn" {% if active_period.id == period.id %}style="color:#4fab4f;"{% endif %}
@@ -130,7 +132,7 @@ <h2 style="border-top:1px solid lightgray;padding-top:15px;">Filter Submissions<
130132
<table id="submission-list" class="has-border">
131133
<tr>
132134
<th style="min-width:20px; text-align: center;">#</th>
133-
<th style="min-width:125px">Student</th>
135+
<th style="min-width:125px">{% if active_period == "teachers" %}Teacher{% else %}Student{% endif %}</th>
134136
{% if not active_period.name %}
135137
<th style="min-width:65px;">Period</th>
136138
{% endif %}
@@ -172,7 +174,7 @@ <h2 style="border-top:1px solid lightgray;padding-top:15px;">Filter Submissions<
172174
<table id="submission-list" class="has-border">
173175
<tr>
174176
<th style="min-width:20px; text-align:center;">#</th>
175-
<th style="min-width:125px">Student</th>
177+
<th style="min-width:125px">{% if active_period == "teachers" %}Teacher{% else %}Student{% endif %}</th>
176178
{% if not active_period.name %}
177179
<th style="min-width:65px;">Period</th>
178180
{% endif %}

0 commit comments

Comments
 (0)