From 738b819b5f8956f15f23f06a8d179937722a8323 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 12 Nov 2022 10:20:28 +0800 Subject: [PATCH] feat(web/submissions): hide older submissions when a registered unfinished contest has this problem --- web/app/models/UOJBlog.php | 2 +- web/app/models/UOJProblem.php | 16 ++++++++++++++++ web/app/models/UOJSubmission.php | 2 -- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/web/app/models/UOJBlog.php b/web/app/models/UOJBlog.php index 480e8db..caeb620 100644 --- a/web/app/models/UOJBlog.php +++ b/web/app/models/UOJBlog.php @@ -42,7 +42,7 @@ class UOJBlog { $contests = UOJContest::queryContestsHasProblem(UOJProblem::query($problem_id)); foreach ($contests as $contest) { - if ($contest->userHasRegistered($user) && $contest->progress() <= CONTEST_IN_PROGRESS) { + if ($contest->userHasRegistered($user) && $contest->progress() == CONTEST_IN_PROGRESS) { return false; } } diff --git a/web/app/models/UOJProblem.php b/web/app/models/UOJProblem.php index 402aa61..48fc537 100644 --- a/web/app/models/UOJProblem.php +++ b/web/app/models/UOJProblem.php @@ -326,6 +326,22 @@ class UOJProblem { } public function additionalSubmissionComponentsCannotBeSeenByUser(array $user = null, UOJSubmission $submission) { + $contests = UOJContest::queryContestsHasProblem($this); + + foreach ($contests as $contest) { + if ($contest->userHasRegistered($user) && $contest->progress() == CONTEST_IN_PROGRESS) { + if ($submission->userIsSubmitter($user)) { + if ($contest->getJudgeTypeInContest() == 'no-details') { + return ['low_level_details']; + } else { + return []; + } + } else { + return ['content', 'high_level_details', 'low_level_details']; + } + } + } + return []; } diff --git a/web/app/models/UOJSubmission.php b/web/app/models/UOJSubmission.php index d7499e9..34570ee 100644 --- a/web/app/models/UOJSubmission.php +++ b/web/app/models/UOJSubmission.php @@ -392,8 +392,6 @@ class UOJSubmission { $perm[$com] = false; } - // TODO: hide older submissions when a registered unfinished contest has this problem - return $perm; }