Fix organization problem bug while in contest

This commit is contained in:
cuom1999 2023-01-07 03:18:16 -06:00
parent 619388a36a
commit ceb48b5bbe
4 changed files with 28 additions and 16 deletions

View file

@ -67,7 +67,7 @@ from judge.utils.views import (
QueryStringSortMixin, QueryStringSortMixin,
DiggPaginatorMixin, DiggPaginatorMixin,
) )
from judge.utils.problems import user_attempted_ids from judge.utils.problems import user_attempted_ids, user_completed_ids
from judge.views.problem import ProblemList from judge.views.problem import ProblemList
from judge.views.contests import ContestList from judge.views.contests import ContestList
from judge.views.submission import AllSubmissions, SubmissionsListBase from judge.views.submission import AllSubmissions, SubmissionsListBase
@ -388,7 +388,7 @@ class OrganizationProblems(LoginRequiredMixin, MemberOrganizationMixin, ProblemL
return super().get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
def get_latest_attempted_problems(self, limit=None): def get_latest_attempted_problems(self, limit=None):
if self.in_contest or not self.profile: if not self.profile:
return () return ()
problems = set(self.get_queryset().values_list("code", flat=True)) problems = set(self.get_queryset().values_list("code", flat=True))
result = list(user_attempted_ids(self.profile).values()) result = list(user_attempted_ids(self.profile).values())
@ -398,9 +398,20 @@ class OrganizationProblems(LoginRequiredMixin, MemberOrganizationMixin, ProblemL
result = result[:limit] result = result[:limit]
return result return result
def get_completed_problems(self):
return user_completed_ids(self.profile) if self.profile is not None else ()
def get_attempted_problems(self):
return user_attempted_ids(self.profile) if self.profile is not None else ()
@cached_property
def in_contest(self):
return False
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(OrganizationProblems, self).get_context_data(**kwargs) context = super(OrganizationProblems, self).get_context_data(**kwargs)
context["page_type"] = "problems" context["page_type"] = "problems"
context["show_contest_mode"] = False
return context return context

View file

@ -715,6 +715,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
) )
context["first_page_href"] = (self.first_page_href or ".") + suffix context["first_page_href"] = (self.first_page_href or ".") + suffix
context["has_show_editorial_option"] = True context["has_show_editorial_option"] = True
context["show_contest_mode"] = self.request.in_contest_mode
return context return context
def get_noui_slider_points(self): def get_noui_slider_points(self):

View file

@ -8,7 +8,7 @@
} }
</style> </style>
</noscript> </noscript>
{% if not request.in_contest_mode %} {% if not show_contest_mode %}
<style> <style>
#search-org, #search-author { #search-org, #search-author {
width: 100%; width: 100%;
@ -208,7 +208,7 @@
}); });
</script> </script>
{% endcompress %} {% endcompress %}
{% if request.in_contest_mode %} {% if show_contest_mode %}
{% compress js %} {% compress js %}
<script src="{{ static('libs/tablesorter.js') }}" type="text/javascript"></script> <script src="{{ static('libs/tablesorter.js') }}" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
@ -238,7 +238,7 @@
}); });
window.register_contest_notification("{{url('contest_clarification_ajax', request.participation.contest.key)}}"); window.register_contest_notification("{{url('contest_clarification_ajax', request.participation.contest.key)}}");
{% if request.in_contest_mode %} {% if show_contest_mode %}
$('.left-sidebar').hide(); $('.left-sidebar').hide();
{% endif %} {% endif %}
}); });
@ -248,7 +248,7 @@
{% endblock %} {% endblock %}
{% block left_sidebar %} {% block left_sidebar %}
{% if not request.in_contest_mode %} {% if not show_contest_mode %}
<div class="left-sidebar"> <div class="left-sidebar">
{{ make_tab_item('feed', 'fa fa-pagelines', url('problem_feed'), _('Feed')) }} {{ make_tab_item('feed', 'fa fa-pagelines', url('problem_feed'), _('Feed')) }}
{{ make_tab_item('list', 'fa fa-list', url('problem_list'), _('List')) }} {{ make_tab_item('list', 'fa fa-list', url('problem_list'), _('List')) }}
@ -258,7 +258,7 @@
{% endblock %} {% endblock %}
{% block right_sidebar %} {% block right_sidebar %}
{% if not request.in_contest_mode %} {% if not show_contest_mode %}
<div id="content-right" class="problems right-sidebar"> <div id="content-right" class="problems right-sidebar">
{% include "problem/search-form.html" %} {% include "problem/search-form.html" %}
{% include "problem/recent-attempt.html" %} {% include "problem/recent-attempt.html" %}

View file

@ -3,14 +3,14 @@
{% include "problem/left-sidebar.html" %} {% include "problem/left-sidebar.html" %}
{% endblock %} {% endblock %}
{% set has_hidden_subtasks = request.in_contest_mode and request.participation.contest.format.has_hidden_subtasks %} {% set has_hidden_subtasks = show_contest_mode and request.participation.contest.format.has_hidden_subtasks %}
{% block middle_content %} {% block middle_content %}
<div id="content-left" class="problems"> <div id="content-left" class="problems">
<table id="problem-table" class="table striped"> <table id="problem-table" class="table striped">
<thead> <thead>
<tr> <tr>
{% if request.in_contest_mode %} {% if show_contest_mode %}
{% if request.user.is_authenticated and not has_hidden_subtasks %} {% if request.user.is_authenticated and not has_hidden_subtasks %}
<th class="solved"><i class="fa fa-check"></i></th> <th class="solved"><i class="fa fa-check"></i></th>
{% endif %} {% endif %}
@ -68,7 +68,7 @@
{% if problem.id in completed_problem_ids %} {% if problem.id in completed_problem_ids %}
<td solved="1"> <td solved="1">
<a href="{{ url('user_submissions', problem.code, request.user.username) }}"> <a href="{{ url('user_submissions', problem.code, request.user.username) }}">
{% if problem.is_public or request.in_contest_mode %} {% if problem.is_public or show_contest_mode %}
<i class="solved-problem-color fa fa-check-circle"></i> <i class="solved-problem-color fa fa-check-circle"></i>
{% else %} {% else %}
<i class="solved-problem-color fa fa-lock"></i> <i class="solved-problem-color fa fa-lock"></i>
@ -78,7 +78,7 @@
{% elif problem.id in attempted_problems %} {% elif problem.id in attempted_problems %}
<td solved="0"> <td solved="0">
<a href="{{ url('user_submissions', problem.code, request.user.username) }}"> <a href="{{ url('user_submissions', problem.code, request.user.username) }}">
{% if problem.is_public or request.in_contest_mode %} {% if problem.is_public or show_contest_mode %}
<i class="attempted-problem-color fa fa-minus-circle"></i> <i class="attempted-problem-color fa fa-minus-circle"></i>
{% else %} {% else %}
<i class="attempted-problem-color fa fa-lock"></i> <i class="attempted-problem-color fa fa-lock"></i>
@ -87,7 +87,7 @@
</td> </td>
{% else %} {% else %}
<td solved="-1"> <td solved="-1">
{% if problem.is_public or request.in_contest_mode %} {% if problem.is_public or show_contest_mode %}
<i class="unsolved-problem-color fa fa-minus-circle"></i> <i class="unsolved-problem-color fa fa-minus-circle"></i>
{% else %} {% else %}
<i class="unsolved-problem-color fa fa-lock"></i> <i class="unsolved-problem-color fa fa-lock"></i>
@ -101,7 +101,7 @@
<td class="pcode"> <td class="pcode">
<a class="pcodecell" href="{{ url('problem_detail', problem.code) }}">{{ problem.code }}</a> <a class="pcodecell" href="{{ url('problem_detail', problem.code) }}">{{ problem.code }}</a>
</td> </td>
{% if not request.in_contest_mode %} {% if not show_contest_mode %}
<td class="category">{{ problem.group.full_name }}</td> <td class="category">{{ problem.group.full_name }}</td>
{% endif %} {% endif %}
{% if show_types %} {% if show_types %}
@ -112,13 +112,13 @@
</td> </td>
{% endif %} {% endif %}
<td class="p">{{ problem.points|floatformat }}{% if problem.partial %}p{% endif %}</td> <td class="p">{{ problem.points|floatformat }}{% if problem.partial %}p{% endif %}</td>
{% if not request.in_contest_mode %} {% if not show_contest_mode %}
<td class="ac-rate">{{ problem.ac_rate|floatformat(0) }}%</td> <td class="ac-rate">{{ problem.ac_rate|floatformat(0) }}%</td>
{% endif %} {% endif %}
{% if not has_hidden_subtasks %} {% if not has_hidden_subtasks %}
<td class="users"> <td class="users">
<a href="{{ url('ranked_submissions', problem.code) }}"> <a href="{{ url('ranked_submissions', problem.code) }}">
{% if not request.in_contest_mode or not hide_contest_scoreboard %} {% if not show_contest_mode or not hide_contest_scoreboard %}
{{ problem.user_count }} {{ problem.user_count }}
{% else %} {% else %}
??? ???
@ -138,7 +138,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% if request.in_contest_mode and request.participation.contest.use_clarifications %} {% if show_contest_mode and request.participation.contest.use_clarifications %}
<br><br> <br><br>
{% if can_edit_contest %} {% if can_edit_contest %}
<div style="float: right; font-size: 1.2em"> <div style="float: right; font-size: 1.2em">