[func] don't show shchools without points [func] show ranking and scores for teachers

This commit is contained in:
Nikola Kubiczek 2022-04-25 16:15:52 +00:00
parent befa154b4e
commit 8e8474920f
2 changed files with 23 additions and 4 deletions

View File

@ -13,12 +13,18 @@
<th>Identyfikator</th>
<th>Uczeń</th>
<th>Klasa</th>
{% if ongoing.scores_available %}
<th>Zajęte miejsce</th>
<th>Wynik z finału</th>
<th>Wynik z eliminacji</th>
{% else %}
{% if ongoing.scores_eliminations %}
<th>Liczba punktów zdobytych podczas eliminacji</th>
{% if ongoing.entry_threshold > 0 %}
<th>Wynik eliminacji</th>
{% endif %}
{% endif %}
{% endif %}
</tr>
</thead>
{% for student in students %}
@ -27,6 +33,11 @@
<th>{{ student.identifier }}</th>
<td>{{ student.name }} {{ student.surname }}</td>
<td>{{ student.grade }}</td>
{% if ongoing.scores_available %}
<th>{{ student.ranking }}</td>
<td>{{ student.score_second }}</td>
<td>{{ student.score_first }}</td>
{% else %}
{% if ongoing.scores_eliminations %}
<td>
{{ student.score_first | default:"-" }}
@ -41,6 +52,7 @@
</td>
{% endif %}
{% endif %}
{% endif %}
</tr>
</tbody>
{% endfor %}

View File

@ -42,10 +42,16 @@ def SubmitStudentsView(request):
}
if edition.submissions is not True:
ranking = {}
for index, student in enumerate(sorted(Student.objects.filter(identifier__startswith=f'{edition.year}-'), key=lambda x: x.score_first*x.score_second, reversed=True)):
ranking[student.identifier] = index + 1
queryset = Student.objects.filter(
identifier__startswith=f'{edition.year}-{request.user.id}-').order_by('identifier')
return render(request, 'user/submission.html', {'students': queryset, **context})
students = [{**student.__dict__, 'ranking': ranking[student.identifier]} for queryset]
return render(request, 'user/submission.html', {'students': students, **context})
queryset = Student.objects.filter(identifier__startswith=f'{edition.year}-{request.user.id}-')
ArticleFormSet = formset_factory(StudentForm, extra=3, max_num=3, min_num=0)
@ -145,6 +151,7 @@ def ScoresView(request, year=None):
score_first = reduce(lambda x, y: x + y.score_first, team, 0)
score_second = reduce(lambda x, y: x + y.score_second, team, 0)
if score_first*score_second > 0:
teams.append({**school, 'score': score_first * score_second})
context = {