feat(web/contest): allow admins take part in contests

This commit is contained in:
Baoshuo Ren 2022-04-04 19:35:20 +08:00
parent e411ef91d3
commit dd417d4f2f
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 6 additions and 1 deletions

View File

@ -13,7 +13,7 @@
if (!Auth::check()) { if (!Auth::check()) {
redirectToLogin(); redirectToLogin();
} elseif (hasContestPermission($myUser, $contest) || hasRegistered($myUser, $contest) || $contest['cur_progress'] != CONTEST_NOT_STARTED) { } elseif (hasRegistered($myUser, $contest) || $contest['cur_progress'] != CONTEST_NOT_STARTED) {
redirectTo('/contests'); redirectTo('/contests');
} }

View File

@ -39,6 +39,11 @@
} else { } else {
$ban_in_contest = !isProblemVisibleToUser($problem, $myUser); $ban_in_contest = !isProblemVisibleToUser($problem, $myUser);
} }
} else {
if ($contest['cur_progress'] == CONTEST_IN_PROGRESS) {
$is_in_contest = true;
DB::update("update contests_registrants set has_participated = 1 where username = '{$myUser['username']}' and contest_id = {$contest['id']}");
}
} }
} else { } else {
if (!isProblemVisibleToUser($problem, $myUser)) { if (!isProblemVisibleToUser($problem, $myUser)) {