mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 12:58:40 +00:00
feat: add a page to show all self reviews of a user
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1ecf4e54b1
commit
1b26049ee0
@ -85,6 +85,7 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<a type="button" class="btn btn-success btn-sm" href="<?= HTML::blog_url($user['username'], '/') ?>"><span class="glyphicon glyphicon-arrow-right"></span> <?= UOJLocale::get('visit his blog', $username) ?></a>
|
<a type="button" class="btn btn-success btn-sm" href="<?= HTML::blog_url($user['username'], '/') ?>"><span class="glyphicon glyphicon-arrow-right"></span> <?= UOJLocale::get('visit his blog', $username) ?></a>
|
||||||
|
<a type="button" class="btn btn-success btn-sm" href="<?= HTML::url('/user/self_reviews/' . $user['username']) ?>"><span class="glyphicon glyphicon-arrow-right"></span> 查看 <?= $username ?> 的所有赛后总结</a>
|
||||||
|
|
||||||
<div class="top-buffer-lg"></div>
|
<div class="top-buffer-lg"></div>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
|
92
web/app/controllers/user_self_reviews.php
Normal file
92
web/app/controllers/user_self_reviews.php
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
if (!Auth::check()) {
|
||||||
|
become403Page(UOJLocale::get('need login'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isNormalUser($myUser)) {
|
||||||
|
become403Page();
|
||||||
|
}
|
||||||
|
|
||||||
|
requirePHPLib('form');
|
||||||
|
|
||||||
|
$username = $_GET['username'];
|
||||||
|
|
||||||
|
if (!validateUsername($username) || !($user = queryUser($username))) {
|
||||||
|
become404Page();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php echoUOJPageHeader(UOJLocale::get('contests::contest self reviews')) ?>
|
||||||
|
|
||||||
|
<h2 style="margin-top: 24px">
|
||||||
|
<?= $username == $myUser['username'] ? '我' : $username . ' ' ?>的所有赛后总结
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$col_names = array('contest_id');
|
||||||
|
$from = 'contests_registrants';
|
||||||
|
$cond = "username = '$username' and has_participated = 1";
|
||||||
|
$tail = '';
|
||||||
|
$config = array(
|
||||||
|
'page_len' => 10,
|
||||||
|
'table_classes' => array('table', 'table-bordered', 'table-text-center', 'table-vertical-middle'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$header_row = '';
|
||||||
|
$header_row .= '<tr>';
|
||||||
|
$header_row .= '<th style="width: 28em;">'.UOJLocale::get('contests::contest name').'</th>';
|
||||||
|
$header_row .= '<th style="width: 14em;">'.UOJLocale::get('problems::problem').'</th>';
|
||||||
|
$header_row .= '<th style="width: 35em;">'.UOJLocale::get('contests::problem self review').'</th>';
|
||||||
|
$header_row .= '<th style="width: 35em;">'.UOJLocale::get('contests::contest self review').'</th>';
|
||||||
|
$header_row .= '</tr>';
|
||||||
|
|
||||||
|
$print_row = function($row) {
|
||||||
|
global $username;
|
||||||
|
|
||||||
|
$contest_id = $row['contest_id'];
|
||||||
|
$contest = queryContest($contest_id);
|
||||||
|
$contest_problems = queryContestProblems($contest_id);
|
||||||
|
$n_contest_problems = count($contest_problems);
|
||||||
|
|
||||||
|
$result = '';
|
||||||
|
$dom_sanitize_config = DOM_SANITIZE_CONFIG;
|
||||||
|
|
||||||
|
for ($i = 0; $i < $n_contest_problems; $i++) {
|
||||||
|
$problem_id = $contest_problems[$i]['problem_id'];
|
||||||
|
$problem = queryProblemBrief($problem_id);
|
||||||
|
$problem_self_review = DB::selectFirst("select content from contests_reviews where contest_id = $contest_id and problem_id = $problem_id and poster = '$username'");
|
||||||
|
|
||||||
|
$result .= '<tr>';
|
||||||
|
|
||||||
|
if ($i == 0) {
|
||||||
|
$result .= '<td rowspan="' . $n_contest_problems . '"><a href="' . HTML::url("/contest/$contest_id") . '">' . $contest['name'] . '</a></td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$problem_review_id = "review-$contest_id-$i";
|
||||||
|
$result .= '<td>' . chr(ord('A') + $i) . '. <a href="/problem/' . $problem_id . '">' . $problem['title'] . '</a></td>';
|
||||||
|
$result .= '<td><div id="' . $problem_review_id . '"></div></td>';
|
||||||
|
$esc_problem_self_review = rawurlencode($problem_self_review != null ? $problem_self_review['content'] : '');
|
||||||
|
$result .= '<script type="text/javascript">'
|
||||||
|
. "$(function() { $('#$problem_review_id').html(DOMPurify.sanitize('{$esc_problem_self_review}', $dom_sanitize_config)); });"
|
||||||
|
. '</script>';
|
||||||
|
|
||||||
|
if ($i == 0) {
|
||||||
|
$contest_review_id = "review-$contest_id-overall";
|
||||||
|
$contest_self_review = DB::selectFirst("select content from contests_reviews where contest_id = $contest_id and problem_id = -1 and poster = '$username'");
|
||||||
|
$esc_contest_self_review = rawurlencode($contest_self_review != null ? $contest_self_review['content'] : '');
|
||||||
|
$result .= '<td rowspan="' . $n_contest_problems . '"><div id="' . $contest_review_id . '"></div></td>';
|
||||||
|
$result .= '<script type="text/javascript">'
|
||||||
|
. "$(function() { $('#$contest_review_id').html(DOMPurify.sanitize('{$esc_contest_self_review}', $dom_sanitize_config)); });"
|
||||||
|
. '</script>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$result .= '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $result;
|
||||||
|
};
|
||||||
|
|
||||||
|
echoLongTable($col_names, $from, $cond, $tail, $header_row, $print_row, $config);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php echoUOJPageFooter() ?>
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('DOM_SANITIZE_CONFIG', "{ALLOWED_TAGS: ['a', 'b', 'i', 'u', 'em', 'strong', 'sub', 'sup', 'small', 'del'], ALLOWED_ATTR: ['href']}");
|
define('DOM_SANITIZE_CONFIG', "{ALLOWED_TAGS: ['a', 'b', 'i', 'u', 'em', 'strong', 'sub', 'sup', 'small', 'del', 'br'], ALLOWED_ATTR: ['href']}");
|
||||||
|
|
||||||
function uojHandleAtSign($str, $uri) {
|
function uojHandleAtSign($str, $uri) {
|
||||||
$referrers = array();
|
$referrers = array();
|
||||||
|
@ -105,6 +105,9 @@ function queryContest($id) {
|
|||||||
function queryContestProblem($id) {
|
function queryContestProblem($id) {
|
||||||
return DB::selectFirst("select * from contest_problems where contest_id = $id", MYSQLI_ASSOC);
|
return DB::selectFirst("select * from contest_problems where contest_id = $id", MYSQLI_ASSOC);
|
||||||
}
|
}
|
||||||
|
function queryContestProblems($id) {
|
||||||
|
return DB::selectAll("select * from contests_problems where contest_id = $id order by dfn, problem_id", MYSQLI_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
function queryGroup($id) {
|
function queryGroup($id) {
|
||||||
return DB::selectFirst("select * from groups where id = $id", MYSQLI_ASSOC);
|
return DB::selectFirst("select * from groups where id = $id", MYSQLI_ASSOC);
|
||||||
|
@ -27,5 +27,7 @@ return [
|
|||||||
'contest final testing' => 'Final testing',
|
'contest final testing' => 'Final testing',
|
||||||
'contest ended' => 'Contest Ended',
|
'contest ended' => 'Contest Ended',
|
||||||
'contest registrants' => 'Registrants',
|
'contest registrants' => 'Registrants',
|
||||||
|
'problem self review' => 'Problem self review',
|
||||||
|
'contest self review' => 'Contest self review',
|
||||||
'contest self reviews' => 'Contest self reviews'
|
'contest self reviews' => 'Contest self reviews'
|
||||||
];
|
];
|
||||||
|
@ -27,5 +27,7 @@ return [
|
|||||||
'contest final testing' => '正在测评',
|
'contest final testing' => '正在测评',
|
||||||
'contest ended' => '比赛已结束',
|
'contest ended' => '比赛已结束',
|
||||||
'contest registrants' => '报名选手列表',
|
'contest registrants' => '报名选手列表',
|
||||||
|
'problem self review' => '题目总结',
|
||||||
|
'contest self review' => '比赛总结',
|
||||||
'contest self reviews' => '赛后总结'
|
'contest self reviews' => '赛后总结'
|
||||||
];
|
];
|
||||||
|
@ -67,6 +67,7 @@ Route::group([
|
|||||||
Route::any('/forgot-password', '/forgot_pw.php');
|
Route::any('/forgot-password', '/forgot_pw.php');
|
||||||
Route::any('/reset-password', '/reset_pw.php');
|
Route::any('/reset-password', '/reset_pw.php');
|
||||||
Route::any('/user/profile/{username}', '/user_info.php');
|
Route::any('/user/profile/{username}', '/user_info.php');
|
||||||
|
Route::any('/user/self_reviews/{username}', '/user_self_reviews.php');
|
||||||
Route::any('/user/modify-profile', '/change_user_info.php');
|
Route::any('/user/modify-profile', '/change_user_info.php');
|
||||||
Route::any('/user/msg', '/user_msg.php');
|
Route::any('/user/msg', '/user_msg.php');
|
||||||
Route::any('/user/system-msg', '/user_system_msg.php');
|
Route::any('/user/system-msg', '/user_system_msg.php');
|
||||||
|
Loading…
Reference in New Issue
Block a user