From dfa261d6ce5baadfa5a6a1648b4ea55192b81ded Mon Sep 17 00:00:00 2001 From: Le Bao Hiep Date: Sun, 24 Sep 2023 17:00:43 +0700 Subject: [PATCH] Improve problem headers in ContestAllProblems - Link to problem detail - Solved mark - Translations --- judge/views/contests.py | 4 ++ templates/contest/contest-all-problems.html | 58 +++++++++++---------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/judge/views/contests.py b/judge/views/contests.py index cbed7df73..cd88853aa 100644 --- a/judge/views/contests.py +++ b/judge/views/contests.py @@ -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 diff --git a/templates/contest/contest-all-problems.html b/templates/contest/contest-all-problems.html index f46785bb5..1acdc00f2 100644 --- a/templates/contest/contest-all-problems.html +++ b/templates/contest/contest-all-problems.html @@ -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 %} -
-
-
-
-

{{ problem.i18n_name }}

- - {{ _('Submit') }} - -
- -
- Time limit: {{ problem.time_limit }} / - Memory limit: {{ problem.memory_limit|kbsimpleformat }} -

Point: {{ problem.points }}

-
-
- {% include "problem/problem-detail.html" %} -
-
+ {% for problem in contest_problems %} +
+
+
+
+

+ {% if problem.id in completed_problem_ids %} + + + + {% elif problem.id in attempted_problem_ids %} + + + + {% endif %} + {{ problem.i18n_name or problem.name }} +

+ + {{ _('Submit') }} +
- {% endfor %} - {% endblock %} - {% endif %} - +
+ {{ _('Time limit:') }} {{ problem.time_limit }}s / + {{ _('Memory limit:') }} {{ problem.memory_limit|kbsimpleformat }} +

{{ _('Points:') }} {{ problem.points }}

+
+
+ {% include "problem/problem-detail.html" %} +
+
+
+ {% endfor %} {% endblock %} {% block description_end %}{% endblock %}