407 lines
15 KiB
PHP
407 lines
15 KiB
PHP
<?php $show_title = "$MSG_PROBLEMS - $OJ_NAME"; ?>
|
|
<?php include("template/$OJ_TEMPLATE/header.php"); ?>
|
|
<div class="padding">
|
|
|
|
<style>
|
|
.problemset-toolbar {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12px 16px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.problemset-toolbar-left,
|
|
.problemset-toolbar-right {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
gap: 10px;
|
|
min-width: 0;
|
|
margin: 0;
|
|
}
|
|
|
|
.problemset-toolbar-left {
|
|
flex: 1 1 320px;
|
|
}
|
|
|
|
.problemset-toolbar-right {
|
|
flex: 1 1 420px;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.problemset-toolbar .ui.search {
|
|
margin-top: -5.3px;
|
|
}
|
|
|
|
.problemset-title-search {
|
|
width: 160px;
|
|
height: 28px;
|
|
}
|
|
|
|
.problemset-user-search {
|
|
width: 120px;
|
|
height: 28px;
|
|
}
|
|
|
|
.problemset-toolbar #hardness_select {
|
|
width: 120px;
|
|
min-height: 32px;
|
|
line-height: 32px;
|
|
margin-left: 0;
|
|
vertical-align: middle;
|
|
padding-top: 0;
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
.problemset-title-cell {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.problemset-title-link {
|
|
flex: 1 1 auto;
|
|
min-width: 0;
|
|
}
|
|
|
|
.problemset-tags {
|
|
flex: 0 1 auto;
|
|
max-width: 55%;
|
|
text-align: right;
|
|
}
|
|
|
|
.problemset-tags .label,
|
|
.problemset-tags .ui.label {
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
@media (max-width: 991px) {
|
|
.problemset-toolbar-right {
|
|
justify-content: flex-start;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 767px) {
|
|
.problemset-toolbar-left,
|
|
.problemset-toolbar-right {
|
|
flex-basis: 100%;
|
|
}
|
|
|
|
.problemset-title-search,
|
|
.problemset-user-search,
|
|
.problemset-toolbar #hardness_select {
|
|
width: 100% !important;
|
|
}
|
|
|
|
.problemset-toolbar .ui.search {
|
|
width: 100% !important;
|
|
}
|
|
|
|
.problemset-title-cell {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.problemset-tags {
|
|
width: 100%;
|
|
max-width: 100%;
|
|
text-align: left;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<div class="problemset-toolbar">
|
|
<form action="" method="get" class="problemset-toolbar-left">
|
|
<div class="ui search problemset-title-search">
|
|
<div class="ui left icon input" style="width: 100%; ">
|
|
<input class="prompt" style="width: 100%; " type="text" placeholder="<?php echo $MSG_TITLE; ?> …"
|
|
name="search" value="<?php if (isset($_GET['search']))
|
|
echo htmlentities($_GET['search'], ENT_QUOTES, 'UTF-8') ?>">
|
|
<i class="search icon"></i>
|
|
</div>
|
|
<div class="results" style="width: 100%; "></div>
|
|
</div>
|
|
|
|
<?php if (isset($_SESSION[$OJ_NAME . '_' . 'administrator'])): ?>
|
|
<div class="ui search problemset-user-search">
|
|
<div class="ui icon input" style="width: 100%; ">
|
|
<input class="prompt" style="width: 100%; " type="text" placeholder="用户ID" name="query_user_id" value="<?php if (isset($_GET['query_user_id']))
|
|
echo htmlentities($_GET['query_user_id'], ENT_QUOTES, 'UTF-8') ?>">
|
|
<i class="search icon"></i>
|
|
</div>
|
|
<div class="results" style="width: 100%; "></div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<button type="submit" class="ui mini button" style="display: none;">搜索</button>
|
|
</form>
|
|
|
|
<div class="problemset-toolbar-right">
|
|
|
|
<div class="ui toggle checkbox" id="show_tag">
|
|
<style id="show_tag_style"></style>
|
|
<script>
|
|
if (localStorage.getItem('show_tag') != '0') {
|
|
document.write('<input type="checkbox" checked>');
|
|
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }';
|
|
} else {
|
|
document.write('<input type="checkbox">');
|
|
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
$(function () {
|
|
$('#show_tag').checkbox('setting', 'onChange', function () {
|
|
let checked = $('#show_tag').checkbox('is checked');
|
|
localStorage.setItem('show_tag', checked ? '1' : '0');
|
|
if (checked) {
|
|
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }';
|
|
} else {
|
|
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<label><?php echo $MSG_SHOW_TAGS; ?></label>
|
|
|
|
</div>
|
|
|
|
<div class="ui toggle checkbox" id="show_solved">
|
|
<style id="show_solved_style"></style>
|
|
<script>
|
|
if (localStorage.getItem('show_solved') != '0') {
|
|
document.write('<input type="checkbox" checked>');
|
|
document.getElementById('show_solved_style').innerHTML = '';
|
|
} else {
|
|
document.write('<input type="checkbox">');
|
|
document.getElementById('show_solved_style').innerHTML = '.solved-problem { display: none; }';
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
$(function () {
|
|
$('#show_solved').checkbox('setting', 'onChange', function () {
|
|
let checked = $('#show_solved').checkbox('is checked');
|
|
localStorage.setItem('show_solved', checked ? '1' : '0');
|
|
if (checked) {
|
|
document.getElementById('show_solved_style').innerHTML = '';
|
|
document.querySelectorAll('.solved-problem').forEach(function (row) {
|
|
row.style.display = '';
|
|
});
|
|
} else {
|
|
document.getElementById('show_solved_style').innerHTML = '.solved-problem { display: none; }';
|
|
document.querySelectorAll('.solved-problem').forEach(function (row) {
|
|
row.style.display = 'none';
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<label>显示已正确题目</label>
|
|
</div>
|
|
|
|
<?php
|
|
$selected_hardness = 0;
|
|
if (isset($_GET['hardness'])) {
|
|
$selected_hardness = intval($_GET['hardness']);
|
|
if ($selected_hardness < 1 || $selected_hardness > 8)
|
|
$selected_hardness = 0;
|
|
}
|
|
?>
|
|
<select id="hardness_select" class="ui dropdown">
|
|
<option value="0" <?php if ($selected_hardness == 0)
|
|
echo 'selected'; ?>>全部难度</option>
|
|
<?php for ($h = 1; $h <= 8; $h++) {
|
|
echo '<option value="' . $h . '"' . ($selected_hardness == $h ? ' selected' : '') . '>难度 ' . $h . '</option>';
|
|
} ?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$(function () {
|
|
document.getElementById('hardness_select').addEventListener('change', function () {
|
|
var value = this.value;
|
|
var params = new URLSearchParams(window.location.search);
|
|
if (value == '0' || value === '') {
|
|
params.delete('hardness');
|
|
} else {
|
|
params.set('hardness', value);
|
|
}
|
|
params.delete('page');
|
|
var query = params.toString();
|
|
window.location.href = query ? ('?' + query) : window.location.pathname;
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<?php if (!isset($_GET['list'])) { ?>
|
|
|
|
<div style="margin-bottom: 30px; ">
|
|
|
|
<?php
|
|
if (!isset($page))
|
|
$page = 1;
|
|
$page = intval($page);
|
|
$section = 8;
|
|
$start = $page > $section ? $page - $section : 1;
|
|
$end = $page + $section > $view_total_page ? $view_total_page : $page + $section;
|
|
$query_user_id = $_GET['query_user_id'];
|
|
function get_query_user_id($query_user_id)
|
|
{
|
|
if (!isset($query_user_id))
|
|
return "";
|
|
return "&query_user_id=" . $query_user_id;
|
|
}
|
|
function get_href($page, $postfix, $query_user_id)
|
|
{
|
|
return "problemset.php?page=" . $page .
|
|
htmlentities($postfix, ENT_QUOTES, 'UTF-8') .
|
|
get_query_user_id($query_user_id);
|
|
}
|
|
?>
|
|
<div style="text-align: center; ">
|
|
<div class="ui pagination menu" style="box-shadow: none; ">
|
|
<a class="<?php if ($page == 1)
|
|
echo "disabled "; ?>icon item" href="<?php if ($page <> 1)
|
|
echo get_href(1, $postfix, $query_user_id); ?>" id="page_first">
|
|
<i class="angle double left icon"></i>
|
|
</a>
|
|
<a class="<?php if ($page == 1)
|
|
echo "disabled "; ?>icon item" href="<?php if ($page <> 1)
|
|
echo get_href($page - 1, $postfix, $query_user_id); ?>" id="page_prev">
|
|
<i class="angle left icon"></i>
|
|
</a>
|
|
<?php
|
|
for ($i = $start; $i <= $end; $i++) {
|
|
echo "<a class=\"" . ($page == $i ? "active " : "") . "item\" href=\"" . get_href($i, $postfix, $query_user_id) . "\">" . $i . "</a>";
|
|
}
|
|
?>
|
|
<a class="<?php if ($page == $view_total_page)
|
|
echo "disabled "; ?> icon item" href="<?php if ($page <> $view_total_page)
|
|
echo get_href($page + 1, $postfix, $query_user_id); ?>" id="page_next">
|
|
<i class="angle right icon"></i>
|
|
</a>
|
|
<a class="<?php if ($page == $view_total_page)
|
|
echo "disabled "; ?> icon item" href="<?php if ($page <> $view_total_page)
|
|
echo get_href($view_total_page, $postfix, $query_user_id); ?>" id="page_last">
|
|
<i class="angle double right icon"></i>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
|
|
<table class="ui very basic center aligned table">
|
|
<thead>
|
|
<tr>
|
|
|
|
<?php if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) { ?>
|
|
<th class="one wide"><?php echo $MSG_STATUS ?></th>
|
|
<?php } ?>
|
|
<th class="one wide"><?php echo $MSG_PROBLEM_ID ?></th>
|
|
<th class="left aligned"><?php echo $MSG_TITLE ?></th>
|
|
<th class="one wide"><?php echo $MSG_SOVLED . "/" . $MSG_SUBMIT ?></th>
|
|
|
|
<th class="one wide"><?php echo $MSG_PASS_RATE ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$color = array("blue", "teal", "orange", "pink", "olive", "red", "yellow", "green", "purple");
|
|
$tcolor = 0;
|
|
$i = 0;
|
|
foreach ($result as $row) {
|
|
$solved_class = '';
|
|
if (isset($_SESSION[$OJ_NAME . '_' . 'user_id']) && isset($acc_arr[$row['problem_id']])) {
|
|
$solved_class = 'solved-problem';
|
|
}
|
|
echo "<tr class=\"$solved_class\">";
|
|
if (isset($_SESSION[$OJ_NAME . '_' . 'user_id'])) {
|
|
|
|
if (isset($sub_arr[$row['problem_id']])) {
|
|
if (isset($acc_arr[$row['problem_id']]))
|
|
echo "<td><span class=\"status accepted\"><i class=\"checkmark icon\"></i></span></td>";
|
|
else
|
|
echo "<td><span class=\"status wrong_answer\"><i class=\"remove icon\"></i></span></td>";
|
|
} else {
|
|
echo "<td><span class=\"status\"><i class=\"icon\"></i></span></td>";
|
|
}
|
|
}
|
|
|
|
echo "<td><b>" . $row['problem_id'] . "</b></td>";
|
|
echo "<td class=\"left aligned\">";
|
|
echo "<div class=\"problemset-title-cell\">";
|
|
echo "<div class=\"problemset-title-link\">";
|
|
echo "<a style=\"vertical-align: middle; \" href=\"problem.php?id=" . $row['problem_id'] . "\">";
|
|
echo $row['title'];
|
|
echo "</a>";
|
|
if ($row['defunct'] == 'Y') {
|
|
echo "<a href=admin/problem_df_change.php?id=" . $row['problem_id'] . "&getkey=" . $_SESSION[$OJ_NAME . '_' . 'getkey'] . ">" . ("<span class=\"ui tiny red label\">未公开</span>") . "</a>";
|
|
}
|
|
echo "</div>";
|
|
|
|
echo "<div class=\"show_tag_controled problemset-tags\">";
|
|
echo $view_problemset[$i][3];
|
|
echo "</div>";
|
|
echo "</div>";
|
|
echo "</td>";
|
|
echo "<td><a href=\"status.php?problem_id=" . $row['problem_id'] . "&jresult=4\">" . $row['accepted'] . "/" . $row['submit'] . "</a></td>";
|
|
// echo "<td><a href='status.php?problem_id=".$row['problem_id']."'>".$row['submit']."</a></td>";
|
|
if ($row['submit'] == 0) {
|
|
echo '<td><div class="progress" style="margin-bottom:-20px; "><div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%;">0.000%</div></div></td>';
|
|
} else {
|
|
$percentage = round(100 * $row['accepted'] / $row['submit'], 3);
|
|
echo '<td><div class="progress" style="margin-bottom:-20px;"><div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="' . $percentage . '" aria-valuemin="0" aria-valuemax="100" style="width:' . $percentage . '%;">' . $percentage . '%</div></div></td>';
|
|
}
|
|
echo "</tr>";
|
|
$i++;
|
|
}
|
|
?>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table><br>
|
|
<?php if (!isset($_GET['list'])) { ?>
|
|
<div style="margin-bottom: 30px; ">
|
|
<div style="text-align: center; ">
|
|
<div class="ui pagination menu" style="box-shadow: none; ">
|
|
<a class="<?php if ($page == 1)
|
|
echo "disabled "; ?>icon item" href="<?php if ($page <> 1)
|
|
echo get_href(1, $postfix, $query_user_id); ?>" id="page_first">
|
|
<i class="angle double left icon"></i>
|
|
</a>
|
|
<a class="<?php if ($page == 1)
|
|
echo "disabled "; ?>icon item" href="<?php if ($page <> 1)
|
|
echo get_href($page - 1, $postfix, $query_user_id); ?>" id="page_prev">
|
|
<i class="angle left icon"></i>
|
|
</a>
|
|
<?php
|
|
for ($i = $start; $i <= $end; $i++) {
|
|
echo "<a class=\"" . ($page == $i ? "active " : "") . "item\" href=\"" . get_href($i, $postfix, $query_user_id) . "\">" . $i . "</a>";
|
|
}
|
|
?>
|
|
<a class="<?php if ($page == $view_total_page)
|
|
echo "disabled "; ?> icon item" href="<?php if ($page <> $view_total_page)
|
|
echo get_href($page + 1, $postfix, $query_user_id); ?>" id="page_next">
|
|
<i class="angle right icon"></i>
|
|
</a>
|
|
<a class="<?php if ($page == $view_total_page)
|
|
echo "disabled "; ?> icon item" href="<?php if ($page <> $view_total_page)
|
|
echo get_href($view_total_page, $postfix, $query_user_id); ?>" id="page_last">
|
|
<i class="angle double right icon"></i>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
<script type="text/javascript" src="include/jquery.tablesorter.js"></script>
|
|
|
|
</div>
|
|
<?php include("template/$OJ_TEMPLATE/footer.php"); ?>
|