Skip to content

Commit

Permalink
(SIO-1907) Display score in problems list
Browse files Browse the repository at this point in the history
Change-Id: Ib3229364cbf84be38390e89668d8043ac9171901
  • Loading branch information
earlgreyz authored and Gerrit Code Review committed Mar 14, 2017
1 parent 8b0280b commit 57255ee
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 23 deletions.
55 changes: 36 additions & 19 deletions oioioi/contests/templates/contests/problems_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,47 @@ <h2>{% trans "Problems" %}</h2>
<thead>
<tr>
<th style="min-width: 60px">{% trans "Symbol" %}</th>
<th style="min-width: 300px">{% trans "Name" %}</th>
{% if show_rounds %}
<th style="min-width: 100px">{% trans "Round" %}</th>
<th style="min-width: 100px">{% trans "End of the round" %}</th>
{% endif %}
<th style="min-width: 200px">{% trans "Name" %}</th>
<th>{% trans "Score" %}</th>
</tr>
</thead>
<tbody>
{% for pi, statement_visible, round_time in problem_instances %}
{% if statement_visible %}
{% url 'problem_statement' contest_id=contest.id problem_instance=pi.short_name as link %}
{% endif %}
<tr>
<td>{{ pi.get_short_name_display }}</td>
<td>{% if statement_visible %}<a href="{{ link }}">{% endif %}{{ pi.problem.name }}{% if statement_visible %}</a>{% endif %}</td>
{% for pi, statement_visible, round_time, result in problem_instances %}

{% if show_rounds %}
<td>{{ pi.round }}</td>
<td>
{% blocktrans with end_time=round_time.get_end|default_if_none:"Not set" %}
{{ end_time }}
{% endblocktrans %}
</td>
{% ifchanged pi.round %}
<tr>
<td colspan="3">
<b>{{ pi.round }}</b>
{% if round_time.get_end %}
<i>({{ round_time.get_end|date:"j F Y, H:i" }})</i>
{% endif %}
</td>
</tr>
{% endifchanged %}
{% endif %}
</tr>
<tr>
<td>{{ pi.get_short_name_display }}</td>
<td>
{% if statement_visible %}
{% url 'problem_statement' contest_id=contest.id problem_instance=pi.short_name as link %}
<a href="{{ link }}">{{ pi.problem.name }}</a>
{% else %}
{{ pi.problem.name }}
{% endif %}
</td>
<td style="text-align: right">
{% if result %}
{% if result.score == result.submission_report.score_report.max_score %}
<div class="label label-success"> {{ result.score }}</div>
{% elif result.score > 0 %}
<div class="label label-warning"> {{ result.score }}</div>
{% else %}
<div class="label label-important"> {{ result.score }}</div>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
Expand Down
19 changes: 15 additions & 4 deletions oioioi/contests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from oioioi.contests.controllers import submission_template_context
from oioioi.contests.forms import SubmissionForm, GetUserInfoForm
from oioioi.contests.models import Contest, ProblemInstance, Submission, \
SubmissionReport, ContestAttachment
SubmissionReport, ContestAttachment, UserResultForProblem
from oioioi.contests.processors import recent_contests
from oioioi.contests.utils import visible_contests, can_enter_contest, \
can_see_personal_data, is_contest_admin, has_any_submittable_problem, \
Expand Down Expand Up @@ -73,14 +73,25 @@ def get_contest_permissions(request, response):
def problems_list_view(request):
controller = request.contest.controller
problem_instances = visible_problem_instances(request)
problems_statements = [

# Problem statements in order
# 1) problem instance
# 2) statement_visible
# 3) round end time
# 4) user result
# Sorted by (start_date, end_date, round name, problem name)
problems_statements = sorted([
(
pi,
controller.can_see_statement(request, pi),
controller.get_round_times(request, pi.round)
controller.get_round_times(request, pi.round),
UserResultForProblem.objects.filter(user=request.user,
problem_instance=pi).first()
)
for pi in problem_instances
]
], key=lambda p: (p[2].get_start(), p[2].get_end(), p[0].round.name,
p[0].short_name))

show_rounds = len(frozenset(pi.round_id for pi in problem_instances)) > 1
return TemplateResponse(request, 'contests/problems_list.html',
{'problem_instances': problems_statements,
Expand Down

0 comments on commit 57255ee

Please sign in to comment.