NDOJ/templates/problem/list.html

450 lines
21 KiB
HTML
Raw Normal View History

2022-04-13 05:52:03 +00:00
{% extends "three-column-content.html" %}
{% block three_col_media %}
2020-01-21 06:35:58 +00:00
<link rel="stylesheet" href="{{ static('libs/nouislider.min.css') }}">
<noscript>
2021-02-20 07:36:16 +00:00
<style>
#category, #types {
visibility: visible;
}
2020-01-21 06:35:58 +00:00
</style>
</noscript>
2022-01-10 11:13:46 +00:00
{% if not request.in_contest_mode %}
2020-01-21 06:35:58 +00:00
<style>
2022-05-22 01:30:44 +00:00
#search-org, #search-author {
2021-02-20 07:36:16 +00:00
width: 100%;
}
2020-01-21 06:35:58 +00:00
#problem-table th {
padding: 0;
}
a.hot-problem-link:hover > .hot-problem-count {
visibility: visible;
}
span.hot-problem-count {
color: #555;
font-size: 0.75em;
vertical-align: super;
visibility: hidden;
padding-left: 0.25em;
position: relative;
}
ul.problem-list {
padding: 0 !important;
}
2022-04-13 05:52:03 +00:00
#content {
width: 99%;
margin-left: 0;
2022-05-03 02:44:14 +00:00
}
.volunteer-types {
width: 100%;
}
.point-input {
height: 2em;
padding-top: 4px;
}
2020-01-21 06:35:58 +00:00
</style>
{% endif %}
{% endblock %}
2022-04-13 05:52:03 +00:00
{% block three_col_js %}
2020-01-21 06:35:58 +00:00
<script>
window.point_start = {{point_start}};
window.point_end = {{point_end}};
window.point_values = {{point_values|json|safe}};
</script>
{% compress js %}
<script src="{{ static('libs/nouislider.min.js') }}" type="text/javascript"></script>
<script>
$(function () {
2022-04-13 05:52:03 +00:00
{% if not request.in_contest_mode %}
// wrap middle and write column
if (window.matchMedia('(max-width: 799px)').matches) {
$('.middle-content').next().addBack().wrapAll('<div class="problem-middle-right"/>');
}
{% endif %}
2020-01-21 06:35:58 +00:00
var $form = $('form#filter-form');
var $search = $('#search');
var $category = $('#category');
function prep_form() {
$search.prop('disabled', !$search.val());
$category.prop('disabled', !$category.val());
}
2022-04-16 22:11:29 +00:00
function clear_point_interval() {
if ($('#search').val() !== "{{ search_query or '' }}") {
$('#point-start').remove();
$('#point-end').remove();
}
}
2020-01-21 06:35:58 +00:00
function clean_submit() {
prep_form();
2022-04-16 22:11:29 +00:00
clear_point_interval();
2020-01-21 06:35:58 +00:00
$form.submit();
}
2022-04-16 22:11:29 +00:00
function form_serialize() {
clear_point_interval();
return $form.serialize();
}
2020-01-21 06:35:58 +00:00
$category.select2().css({'visibility': 'visible'}).change(clean_submit);
$('#types').select2({multiple: 1, placeholder: '{{ _('Filter by type...') }}'})
.css({'visibility': 'visible'});
2021-02-20 07:36:16 +00:00
$('#search-org').select2({multiple: 1, placeholder: '{{ _('Organizations...') }}'})
.css({'visibility': 'visible'});
2022-05-22 01:30:44 +00:00
$('#search-author').select2({multiple: 1, placeholder: '{{ _('Authors') }}...'})
.css({'visibility': 'visible'});
2020-01-21 06:35:58 +00:00
// This is incredibly nasty to do but it's needed because otherwise the select2 steals the focus
$search.keypress(function (e) {
if (e.keyCode == 13)
$('#go').click();
});
$('#random').click(function (e) {
var action = $form.attr('action');
$form.attr('action', '{{ url('problem_random') }}').attr('target', '_blank').submit();
$form.attr('action', action).attr('target', '');
e.preventDefault();
});
$('#go').click(clean_submit);
2022-04-13 05:52:03 +00:00
$('input#full_text, input#hide_solved, input#show_types, input#show_editorial, input#have_editorial').click(function () {
2020-01-21 06:35:58 +00:00
prep_form();
2022-04-16 22:11:29 +00:00
($('<form>').attr('action', window.location.pathname + '?' + form_serialize())
2020-01-21 06:35:58 +00:00
.append($('<input>').attr('type', 'hidden').attr('name', 'csrfmiddlewaretoken')
.attr('value', $.cookie('csrftoken')))
.attr('method', 'POST').appendTo($('body')).submit());
});
var intFormatter = {
to: function (value) {
return value;
},
from: function (value) {
return +value;
}
};
var $slider = $('#point-slider');
if ($slider.length) {
var $start = $('#point-start');
var $end = $('#point-end');
noUiSlider.create($slider[0], {
start: [point_start, point_end],
connect: true,
snap: true,
tooltips: [intFormatter, intFormatter],
range: point_values
}).on('change', function (values) {
var start = +values[0], end = +values[1];
$start.prop('disabled', start === point_values.min).val(start);
$end.prop('disabled', end === point_values.max).val(end);
});
}
2022-05-03 02:44:14 +00:00
{% if feed_type=='volunteer' and request.user.has_perm('judge.suggest_problem_changes') %}
$(".edit-btn").on('click', function() {
var pid = $(this).attr('pid');
$('#volunteer-types-' + pid).css({'width': '100%'});
$('#volunteer-types-' + pid).select2({multiple: 1, placeholder: '{{ _('Add types...') }}'})
.css({'visibility': 'visible'});
$('#form-' + pid).show();
$('#submit-' + pid).show();
$(this).hide();
});
let isChecking = false;
$(".volunteer-submit-btn").on('click', function(e) {
var pid = $(this).attr('pid');
var pcode = $(this).attr('pcode');
var $form = $('#form-' + pid);
if (!$form[0].checkValidity()) {
if (isChecking) return;
isChecking = true;
// The form won't actually submit;
$(this).click();
}
else {
isChecking = false;
}
if (isChecking) return;
e.preventDefault();
$('#volunteer-types-' + pid).select2({multiple: 1, placeholder: '{{ _('Add types...') }}'})
.css({'visibility': 'visible'});
$('#form-' + pid).hide();
$('#edit-' + pid).show();
$('#thank-' + pid).show();
$(this).hide();
var data = {
problem: pcode,
types: $('#volunteer-types-' + pid).val(),
knowledge_points: $('#knowledge_point-' + pid).val(),
thinking_points: $('#thinking_point-' + pid).val(),
feedback: $('#feedback-' + pid).val(),
};
$.post("{{url('volunteer_problem_vote')}}", data)
.fail(function() {
$('#thank-' + pid).html("{{_('Fail to vote!')}}");
})
.done(function() {
$('#thank-' + pid).html("{{_('Successful vote! Thank you!')}}");
});
});
{% endif %}
2020-01-21 06:35:58 +00:00
});
</script>
{% endcompress %}
2022-01-10 11:13:46 +00:00
{% if request.in_contest_mode %}
2020-01-21 06:35:58 +00:00
{% compress js %}
<script src="{{ static('libs/tablesorter.js') }}" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$.tablesorter.addParser({
id: 'solvedsort',
is: function (s) {
return false;
},
format: function (s, table, cell, cellIndex) {
return $(cell).attr('solved');
},
type: 'numeric'
});
$('#problem-table').tablesorter({
headers: {
0: {
sorter: 'solvedsort'
}
},
textExtraction: function (node) {
node = $(node);
var text = node.text().replace(/^\s+|\s+$/g, '');
return (node.hasClass('p') ? text.replace(/p$/, '') : text);
}
});
2021-10-16 22:40:02 +00:00
window.register_contest_notification("{{url('contest_clarification_ajax', request.participation.contest.key)}}");
2022-04-13 05:52:03 +00:00
{% if request.in_contest_mode %}
$('.left-sidebar').hide();
$('.middle-content').css('max-width', '80%');
{% endif %}
2020-01-21 06:35:58 +00:00
});
</script>
{% endcompress %}
{% endif %}
{% endblock %}
2022-04-13 05:52:03 +00:00
{% block left_sidebar %}
{% if not request.in_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')) }}
{{ make_tab_item('admin', 'fa fa-edit', url('admin:judge_problem_changelist'), _('Admin')) }}
2020-01-21 06:35:58 +00:00
</div>
{% endif %}
2022-04-13 05:52:03 +00:00
{% endblock %}
2020-01-21 06:35:58 +00:00
2022-04-13 05:52:03 +00:00
{% block middle_content %}
{% if in_contest_mode or page_type == 'list' %}
2020-01-21 06:35:58 +00:00
<div id="content-left" class="problems">
<table id="problem-table" class="table striped">
<thead>
<tr>
2022-01-10 11:13:46 +00:00
{% if request.in_contest_mode %}
2020-01-21 06:35:58 +00:00
{% if request.user.is_authenticated %}
<th class="solved"><i class="fa fa-check"></i></th>
{% endif %}
<th class="problem">{{ _('Problem') }}</th>
2020-05-03 17:41:19 +00:00
<th class="pcode">{{ _('Problem code') }}</th>
2020-01-21 06:35:58 +00:00
{% if show_types %}
<th>{{ _('Types') }}</th>
{% endif %}
<th class="points">{{ _('Points') }}</th>
<th class="users">{{ _('Users') }}</th>
{% else %}
{% if request.user.is_authenticated %}
<th class="solved">
<a href="{{ sort_links.solved }}"><i class="fa fa-check"></i>{{ sort_order.solved }}
</a>
</th>
{% endif %}
<th class="problem">
<a href="{{ sort_links.name }}">{{ _('Problem') }}{{ sort_order.name }}</a>
</th>
2020-05-02 18:43:50 +00:00
<th class="pcode">
2020-05-03 17:41:19 +00:00
<a href="{{ sort_links.code }}">{{ _('Problem code') }}</a>
2020-05-02 18:43:50 +00:00
</th>
2020-01-21 06:35:58 +00:00
<th class="category">
<a href="{{ sort_links.group }}">{{ _('Category') }}{{ sort_order.group }}</a>
</th>
{% if show_types %}
<th>
<a href="{{ sort_links.type }}">{{ _('Types') }}{{ sort_order.type }}</a>
</th>
{% endif %}
<th class="points">
<a href="{{ sort_links.points }}">{{ _('Points') }}{{ sort_order.points }}</a>
</th>
<th class="ac-rate">
<a href="{{ sort_links.ac_rate }}">{{ _('AC %%') }}{{ sort_order.ac_rate }}</a>
</th>
<th class="users">
<a href="{{ sort_links.user_count }}">{{ _('Users') }}{{ sort_order.user_count }}</a>
</th>
2020-06-15 18:46:43 +00:00
{% if show_editorial %}
<th class="editorial">
2022-04-13 05:52:03 +00:00
{{_('Editorial')}}
2020-06-15 18:46:43 +00:00
</th>
{% endif %}
2020-01-21 06:35:58 +00:00
{% endif %}
</tr>
</thead>
<tbody>
2020-06-15 18:46:43 +00:00
{% for problem in object_list %}
2020-01-21 06:35:58 +00:00
<tr>
{% if request.user.is_authenticated %}
{% if problem.id in completed_problem_ids %}
<td solved="1">
<a href="{{ url('user_submissions', problem.code, request.user.username) }}">
2022-01-10 11:13:46 +00:00
{% if problem.is_public or request.in_contest_mode %}
2020-01-21 06:35:58 +00:00
<i class="solved-problem-color fa fa-check-circle"></i>
{% else %}
<i class="solved-problem-color fa fa-lock"></i>
{% endif %}
</a>
</td>
{% elif problem.id in attempted_problems %}
<td solved="0">
<a href="{{ url('user_submissions', problem.code, request.user.username) }}">
2022-01-10 11:13:46 +00:00
{% if problem.is_public or request.in_contest_mode %}
2020-01-21 06:35:58 +00:00
<i class="attempted-problem-color fa fa-minus-circle"></i>
{% else %}
<i class="attempted-problem-color fa fa-lock"></i>
{% endif %}
</a>
</td>
{% else %}
<td solved="-1">
2022-01-10 11:13:46 +00:00
{% if problem.is_public or request.in_contest_mode %}
2020-01-21 06:35:58 +00:00
<i class="unsolved-problem-color fa fa-minus-circle"></i>
{% else %}
<i class="unsolved-problem-color fa fa-lock"></i>
{% endif %}
</td>
{% endif %}
{% endif %}
<td class="problem">
<a href="{{ url('problem_detail', problem.code) }}">{{ problem.i18n_name }}</a>
</td>
2020-05-02 18:43:50 +00:00
<td class="pcode">
2020-05-03 07:11:33 +00:00
<a class="pcodecell" href="{{ url('problem_detail', problem.code) }}">{{ problem.code }}</a>
2020-05-02 18:43:50 +00:00
</td>
2022-05-22 01:30:44 +00:00
{% if not request.in_contest_mode %}
<td class="category">{{ problem.group.full_name }}</td>
{% endif %}
2020-01-21 06:35:58 +00:00
{% if show_types %}
<td class="types">
{% for type in problem.types_list %}
<span class="type-tag">{{ type }}</span>{% if not loop.last %}, {% endif %}
{% endfor %}
</td>
{% endif %}
<td class="p">{{ problem.points|floatformat }}{% if problem.partial %}p{% endif %}</td>
2022-01-10 11:13:46 +00:00
{% if not request.in_contest_mode %}
2020-01-21 06:35:58 +00:00
<td class="ac-rate">{{ problem.ac_rate|floatformat(1) }}%</td>
{% endif %}
<td class="users">
<a href="{{ url('ranked_submissions', problem.code) }}">
2022-01-10 11:13:46 +00:00
{% if not request.in_contest_mode or not hide_contest_scoreboard %}
2020-01-21 06:35:58 +00:00
{{ problem.user_count }}
{% else %}
???
{% endif %}
</a>
</td>
2020-06-15 18:46:43 +00:00
{% if show_editorial%}
<td class="editorial">
{% if problem.has_public_editorial %}
<a href="{{ url('problem_editorial', problem.code) }}">{{ _('Editorial') }}</a>
{% endif %}
</td>
{% endif %}
2020-01-21 06:35:58 +00:00
</tr>
{% endfor %}
</tbody>
</table>
2022-01-10 11:13:46 +00:00
{% if request.in_contest_mode and request.participation.contest.use_clarifications %}
2021-10-19 22:41:53 +00:00
<br><br>
{% if can_edit_contest %}
<div style="float: right; font-size: 1.2em">
<a href="{{url('new_contest_clarification', request.participation.contest.key)}}"><i class="fa fa-plus-circle" style="color:green"></i> <u>{{_('Add clarifications')}}</u></a>
</div>
{% endif %}
{% if has_clarifications %}
<div style="font-size: 1.2em; font-style: bold">
<i class="fa fa-question-circle"></i> {{_('Clarifications')}}</div>
<table class="table">
<tr>
<th>{{_('Problem')}}</th>
<th>{{_('Time')}}</th>
<th>{{_('Description')}}</th>
</tr>
{% for clarification in clarifications %}
<tr>
<td>
<a href="{{ url('problem_detail', clarification.problem.code) }}"
class="problem">
{{ clarification.problem.name }}
</a>
</td>
<td class="time">{{ relative_time(clarification.date) }}</td>
<td><p style="overflow-wrap: break-word; word-break: break-word">{{clarification.description}}</p></td>
</tr>
{% endfor %}
</table>
{% else %}
<p style="font-style: italic; text-align: center">
{{ _('No clarifications have been made at this time.') }}</center>
</p>
{% endif %}
{% endif %}
2022-04-13 05:52:03 +00:00
2020-01-21 06:35:58 +00:00
</div>
2022-04-13 05:52:03 +00:00
{% elif page_type == 'feed' %}
<div class="problem-feed-option">
<a href="{{url('problem_feed')}}" class="problem-feed-option-item {{'active' if feed_type=='for_you'}}">
{{_('FOR YOU')}}
</a>
<a href="{{url('problem_feed_new')}}" class="problem-feed-option-item {{'active' if feed_type=='new'}}">
{{_('NEW')}}
</a>
2022-05-03 02:44:14 +00:00
{% if request.user.has_perm('judge.suggest_problem_changes') %}
<a href="{{url('problem_feed_volunteer')}}" class="problem-feed-option-item {{'active' if feed_type=='volunteer'}}">
{{_('VOLUNTEER')}}
</a>
{% endif %}
2022-04-13 05:52:03 +00:00
</div>
{% for problem in problems %}
{% include "problem/feed.html" %}
{% endfor %}
{% endif %}
{% if page_obj.num_pages > 1 %}
<div style="margin-top:10px;">{% include "list-pages.html" %}</div>
{% endif %}
2020-01-21 06:35:58 +00:00
{% endblock %}
2022-04-13 05:52:03 +00:00
{% block right_sidebar %}
{% if not request.in_contest_mode %}
2022-04-18 22:18:21 +00:00
<div id="content-right" class="problems right-sidebar">
2022-05-22 01:30:44 +00:00
{% include "problem/search-form.html" %}
{% include "problem/recent-attempt.html" %}
2022-04-13 05:52:03 +00:00
</div>
{% endif %}
{% endblock %}