Fix organization problem bug while in contest
This commit is contained in:
parent
619388a36a
commit
ceb48b5bbe
4 changed files with 28 additions and 16 deletions
|
@ -67,7 +67,7 @@ from judge.utils.views import (
|
|||
QueryStringSortMixin,
|
||||
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.contests import ContestList
|
||||
from judge.views.submission import AllSubmissions, SubmissionsListBase
|
||||
|
@ -388,7 +388,7 @@ class OrganizationProblems(LoginRequiredMixin, MemberOrganizationMixin, ProblemL
|
|||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def get_latest_attempted_problems(self, limit=None):
|
||||
if self.in_contest or not self.profile:
|
||||
if not self.profile:
|
||||
return ()
|
||||
problems = set(self.get_queryset().values_list("code", flat=True))
|
||||
result = list(user_attempted_ids(self.profile).values())
|
||||
|
@ -398,9 +398,20 @@ class OrganizationProblems(LoginRequiredMixin, MemberOrganizationMixin, ProblemL
|
|||
result = result[:limit]
|
||||
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):
|
||||
context = super(OrganizationProblems, self).get_context_data(**kwargs)
|
||||
context["page_type"] = "problems"
|
||||
context["show_contest_mode"] = False
|
||||
return context
|
||||
|
||||
|
||||
|
|
|
@ -715,6 +715,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
)
|
||||
context["first_page_href"] = (self.first_page_href or ".") + suffix
|
||||
context["has_show_editorial_option"] = True
|
||||
context["show_contest_mode"] = self.request.in_contest_mode
|
||||
return context
|
||||
|
||||
def get_noui_slider_points(self):
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
}
|
||||
</style>
|
||||
</noscript>
|
||||
{% if not request.in_contest_mode %}
|
||||
{% if not show_contest_mode %}
|
||||
<style>
|
||||
#search-org, #search-author {
|
||||
width: 100%;
|
||||
|
@ -208,7 +208,7 @@
|
|||
});
|
||||
</script>
|
||||
{% endcompress %}
|
||||
{% if request.in_contest_mode %}
|
||||
{% if show_contest_mode %}
|
||||
{% compress js %}
|
||||
<script src="{{ static('libs/tablesorter.js') }}" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
|
@ -238,7 +238,7 @@
|
|||
});
|
||||
window.register_contest_notification("{{url('contest_clarification_ajax', request.participation.contest.key)}}");
|
||||
|
||||
{% if request.in_contest_mode %}
|
||||
{% if show_contest_mode %}
|
||||
$('.left-sidebar').hide();
|
||||
{% endif %}
|
||||
});
|
||||
|
@ -248,7 +248,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block left_sidebar %}
|
||||
{% if not request.in_contest_mode %}
|
||||
{% if not show_contest_mode %}
|
||||
<div class="left-sidebar">
|
||||
{{ make_tab_item('feed', 'fa fa-pagelines', url('problem_feed'), _('Feed')) }}
|
||||
{{ make_tab_item('list', 'fa fa-list', url('problem_list'), _('List')) }}
|
||||
|
@ -258,7 +258,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block right_sidebar %}
|
||||
{% if not request.in_contest_mode %}
|
||||
{% if not show_contest_mode %}
|
||||
<div id="content-right" class="problems right-sidebar">
|
||||
{% include "problem/search-form.html" %}
|
||||
{% include "problem/recent-attempt.html" %}
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
{% include "problem/left-sidebar.html" %}
|
||||
{% 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 %}
|
||||
<div id="content-left" class="problems">
|
||||
<table id="problem-table" class="table striped">
|
||||
<thead>
|
||||
<tr>
|
||||
{% if request.in_contest_mode %}
|
||||
{% if show_contest_mode %}
|
||||
{% if request.user.is_authenticated and not has_hidden_subtasks %}
|
||||
<th class="solved"><i class="fa fa-check"></i></th>
|
||||
{% endif %}
|
||||
|
@ -68,7 +68,7 @@
|
|||
{% if problem.id in completed_problem_ids %}
|
||||
<td solved="1">
|
||||
<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>
|
||||
{% else %}
|
||||
<i class="solved-problem-color fa fa-lock"></i>
|
||||
|
@ -78,7 +78,7 @@
|
|||
{% elif problem.id in attempted_problems %}
|
||||
<td solved="0">
|
||||
<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>
|
||||
{% else %}
|
||||
<i class="attempted-problem-color fa fa-lock"></i>
|
||||
|
@ -87,7 +87,7 @@
|
|||
</td>
|
||||
{% else %}
|
||||
<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>
|
||||
{% else %}
|
||||
<i class="unsolved-problem-color fa fa-lock"></i>
|
||||
|
@ -101,7 +101,7 @@
|
|||
<td class="pcode">
|
||||
<a class="pcodecell" href="{{ url('problem_detail', problem.code) }}">{{ problem.code }}</a>
|
||||
</td>
|
||||
{% if not request.in_contest_mode %}
|
||||
{% if not show_contest_mode %}
|
||||
<td class="category">{{ problem.group.full_name }}</td>
|
||||
{% endif %}
|
||||
{% if show_types %}
|
||||
|
@ -112,13 +112,13 @@
|
|||
</td>
|
||||
{% endif %}
|
||||
<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>
|
||||
{% endif %}
|
||||
{% if not has_hidden_subtasks %}
|
||||
<td class="users">
|
||||
<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 }}
|
||||
{% else %}
|
||||
???
|
||||
|
@ -138,7 +138,7 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if request.in_contest_mode and request.participation.contest.use_clarifications %}
|
||||
{% if show_contest_mode and request.participation.contest.use_clarifications %}
|
||||
<br><br>
|
||||
{% if can_edit_contest %}
|
||||
<div style="float: right; font-size: 1.2em">
|
||||
|
|
Loading…
Reference in a new issue