mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 12:18:42 +00:00
feat(web): add ac_num ranklist
This commit is contained in:
parent
5d3f0d9bff
commit
5121b733bd
@ -118,6 +118,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 mt-4">
|
||||||
|
<h5><?= UOJLocale::get('top solver') ?></h5>
|
||||||
|
<?php echoRanklist(array('echo_full' => true, 'group_id' => $group_id, 'by_accepted' => true)) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if (isSuperUser($myUser)): ?>
|
<?php if (isSuperUser($myUser)): ?>
|
||||||
<h5>编辑小组信息</h5>
|
<h5>编辑小组信息</h5>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
|
@ -43,4 +43,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if (Auth::check()): ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 mt-4">
|
||||||
|
<h3><?= UOJLocale::get('top solver') ?></h3>
|
||||||
|
<?php echoRanklist(array('echo_full' => true, 'top10' => true, 'by_accepted' => true)) ?>
|
||||||
|
<div class="text-center">
|
||||||
|
<a href="/solverlist"><?= UOJLocale::get('view all') ?></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php echoUOJPageFooter() ?>
|
<?php echoUOJPageFooter() ?>
|
||||||
|
@ -3,8 +3,13 @@
|
|||||||
becomeMsgPage(UOJLocale::get('need login'));
|
becomeMsgPage(UOJLocale::get('need login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
become404Page();
|
if (isset($_GET['type']) && $_GET['type'] == 'accepted') {
|
||||||
|
$config = array('page_len' => 100, 'by_accepted' => true);
|
||||||
|
$title = UOJLocale::get('top solver');
|
||||||
|
} else {
|
||||||
|
become404Page();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<?php echoUOJPageHeader('比赛排行榜') ?>
|
<?php echoUOJPageHeader($title) ?>
|
||||||
<?php echoRanklist($config) ?>
|
<?php echoRanklist($config) ?>
|
||||||
<?php echoUOJPageFooter() ?>
|
<?php echoUOJPageFooter() ?>
|
||||||
|
@ -961,3 +961,54 @@ function echoUOJPageHeader($page_title, $extra_config = array()) {
|
|||||||
function echoUOJPageFooter($config = array()) {
|
function echoUOJPageFooter($config = array()) {
|
||||||
uojIncludeView('page-footer', $config);
|
uojIncludeView('page-footer', $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function echoRanklist($config = array()) {
|
||||||
|
$header_row = '';
|
||||||
|
$header_row .= '<tr>';
|
||||||
|
$header_row .= '<th style="width: 5em;">#</th>';
|
||||||
|
$header_row .= '<th style="width: 14em;">'.UOJLocale::get('username').'</th>';
|
||||||
|
$header_row .= '<th style="width: 50em;">'.UOJLocale::get('motto').'</th>';
|
||||||
|
$header_row .= '<th style="width: 5em;">'.UOJLocale::get('solved').'</th>';
|
||||||
|
$header_row .= '</tr>';
|
||||||
|
|
||||||
|
$users = array();
|
||||||
|
$print_row = function($user, $now_cnt) use (&$users, $config) {
|
||||||
|
if (!$users) {
|
||||||
|
if ($now_cnt == 1) {
|
||||||
|
$rank = 1;
|
||||||
|
} else {
|
||||||
|
$rank = DB::selectCount("select count(*) from (select b.username as username, count(*) as accepted from best_ac_submissions a inner join user_info b on a.submitter = b.username group by username) as derived where accepted > {$user['ac_num']}") + 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$rank = $now_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user['rank'] = $rank;
|
||||||
|
|
||||||
|
echo '<tr>';
|
||||||
|
echo '<td>' . $user['rank'] . '</td>';
|
||||||
|
echo '<td>' . getUserLink($user['username']) . '</td>';
|
||||||
|
echo '<td>' . HTML::escape($user['motto']) . '</td>';
|
||||||
|
echo '<td>' . $user['ac_num'] . '</td>';
|
||||||
|
echo '</tr>';
|
||||||
|
|
||||||
|
$users[] = $user;
|
||||||
|
};
|
||||||
|
|
||||||
|
$from = 'best_ac_submissions a inner join user_info b on a.submitter = b.username';
|
||||||
|
$col_names = array('b.username as username', 'count(*) as ac_num', 'b.motto as motto');
|
||||||
|
$cond = '1';
|
||||||
|
$tail = 'group by username order by ac_num desc, username asc';
|
||||||
|
|
||||||
|
if (isset($config['group_id'])) {
|
||||||
|
$group_id = $config['group_id'];
|
||||||
|
$from = "best_ac_submissions a inner join user_info b on a.submitter = b.username inner join groups_users c on (a.submitter = c.username and c.group_id = {$group_id})";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($config['top10'])) {
|
||||||
|
$tail .= ' limit 10';
|
||||||
|
}
|
||||||
|
|
||||||
|
$config['get_row_index'] = '';
|
||||||
|
echoLongTable($col_names, $from, $cond, $tail, $header_row, $print_row, $config);
|
||||||
|
}
|
||||||
|
@ -19,6 +19,8 @@ return [
|
|||||||
'blogs' => 'Blogs',
|
'blogs' => 'Blogs',
|
||||||
'announcements' => 'Announcements',
|
'announcements' => 'Announcements',
|
||||||
'all the announcements' => 'All the Announcements……',
|
'all the announcements' => 'All the Announcements……',
|
||||||
|
'solved' => 'Solved',
|
||||||
|
'top solver' => 'Top solver',
|
||||||
'help' => 'Help',
|
'help' => 'Help',
|
||||||
'search' => 'Search',
|
'search' => 'Search',
|
||||||
'news' => 'News',
|
'news' => 'News',
|
||||||
|
@ -19,6 +19,8 @@ return [
|
|||||||
'blogs' => '博客',
|
'blogs' => '博客',
|
||||||
'announcements' => '公告',
|
'announcements' => '公告',
|
||||||
'all the announcements' => '所有公告……',
|
'all the announcements' => '所有公告……',
|
||||||
|
'solved' => 'AC 数',
|
||||||
|
'top solver' => 'AC 数排行榜',
|
||||||
'help' => '帮助',
|
'help' => '帮助',
|
||||||
'search' => '搜索',
|
'search' => '搜索',
|
||||||
'news' => '最新动态',
|
'news' => '最新动态',
|
||||||
|
@ -51,6 +51,7 @@ Route::group([
|
|||||||
Route::any('/announcements', '/announcements.php');
|
Route::any('/announcements', '/announcements.php');
|
||||||
|
|
||||||
Route::any('/faq', '/faq.php');
|
Route::any('/faq', '/faq.php');
|
||||||
|
Route::any('/solverlist', '/ranklist.php?type=accepted');
|
||||||
|
|
||||||
Route::any('/captcha', '/captcha.php');
|
Route::any('/captcha', '/captcha.php');
|
||||||
Route::any('/login', '/login.php');
|
Route::any('/login', '/login.php');
|
||||||
|
Loading…
Reference in New Issue
Block a user