From dd417d4f2fbd212de5cf77a61b06ddd64e703ac5 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 4 Apr 2022 19:35:20 +0800 Subject: [PATCH] feat(web/contest): allow admins take part in contests --- web/app/controllers/contest_registration.php | 2 +- web/app/controllers/problem.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/app/controllers/contest_registration.php b/web/app/controllers/contest_registration.php index c15fd1e..6f96e71 100644 --- a/web/app/controllers/contest_registration.php +++ b/web/app/controllers/contest_registration.php @@ -13,7 +13,7 @@ if (!Auth::check()) { 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'); } diff --git a/web/app/controllers/problem.php b/web/app/controllers/problem.php index 2c3ed19..9d2c554 100644 --- a/web/app/controllers/problem.php +++ b/web/app/controllers/problem.php @@ -39,6 +39,11 @@ } else { $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 { if (!isProblemVisibleToUser($problem, $myUser)) {