Skip to content

Commit

Permalink
Improve problem headers in ContestAllProblems
Browse files Browse the repository at this point in the history
- Link to problem detail
- Solved mark
- Translations
  • Loading branch information
hieplpvip committed Sep 28, 2023
1 parent 28b7df5 commit dfa261d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
4 changes: 4 additions & 0 deletions judge/views/contests.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ def get_context_data(self, **kwargs):
for idx, p in enumerate(context['contest_problems']):
p.points = points_list[idx][0]

authenticated = self.request.user.is_authenticated
context['completed_problem_ids'] = user_completed_ids(self.request.profile) if authenticated else []
context['attempted_problem_ids'] = user_attempted_ids(self.request.profile) if authenticated else []

return context


Expand Down
58 changes: 31 additions & 27 deletions templates/contest/contest-all-problems.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,39 @@
{% endblock %}

{% block body %}
{% set in_contest = contest.is_in_contest(request.user) %}
{% if in_contest or contest.ended or request.user.is_superuser or is_editor or is_tester %}
{% block description %}
{% for problem in contest_problems %}
<div style="display: flex; flex-direction: column; align-items: center;">
<div class="content-description" style="width: 70%;">
<div class="problem_container">
<div style="display: flex">
<h2 style="margin-top: 0.5em; margin-right: 0.5em;">{{ problem.i18n_name }}</h2>
<a href="{{ url('problem_submit', problem.code) }}" class="button" style="display: inline; margin: auto 0;">
{{ _('Submit') }}
</a>
</div>

<div>
<span><strong>Time limit:</strong> {{ problem.time_limit }} /</span>
<span><strong>Memory limit:</strong> {{ problem.memory_limit|kbsimpleformat }}</span>
<p><strong>Point:</strong> {{ problem.points }}</p>
</div>
</div>
{% include "problem/problem-detail.html" %}
<hr>
</div>
{% for problem in contest_problems %}
<div style="display: flex; flex-direction: column; align-items: center;">
<div class="content-description" style="width: 70%;">
<div class="problem_container">
<div style="display: flex">
<h2 style="margin-top: 0.5em; margin-right: 0.5em;">
{% if problem.id in completed_problem_ids %}
<a href="{{ url('user_submissions', problem.code, request.user.username) }}">
<i class="solved-problem-color fa fa-check-circle"></i>
</a>
{% elif problem.id in attempted_problem_ids %}
<a href="{{ url('user_submissions', problem.code, request.user.username) }}">
<i class="attempted-problem-color fa fa-frown-o"></i>
</a>
{% endif %}
<a href="{{ url('problem_detail', problem.code) }}">{{ problem.i18n_name or problem.name }}</a>
</h2>
<a href="{{ url('problem_submit', problem.code) }}" class="button" style="display: inline; margin: auto 0;">
{{ _('Submit') }}
</a>
</div>
{% endfor %}
{% endblock %}
{% endif %}

<!-- <hr> -->
<div>
<span><strong>{{ _('Time limit:') }}</strong> {{ problem.time_limit }}s /</span>
<span><strong>{{ _('Memory limit:') }}</strong> {{ problem.memory_limit|kbsimpleformat }}</span>
<p><strong>{{ _('Points:') }}</strong> {{ problem.points }}</p>
</div>
</div>
{% include "problem/problem-detail.html" %}
<hr>
</div>
</div>
{% endfor %}
{% endblock %}

{% block description_end %}{% endblock %}
Expand Down

0 comments on commit dfa261d

Please sign in to comment.