mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 06:28:42 +00:00
refactor(web/contest): remove UOJContest::queryContestsHasProblem()
use UOJProblem::findInContests() instead.
This commit is contained in:
parent
738b819b5f
commit
8d87fda233
@ -38,11 +38,10 @@ class UOJBlog {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($problem_id = $this->getSolutionProblemId()) {
|
$problem = $this->getSolutionProblem();
|
||||||
$contests = UOJContest::queryContestsHasProblem(UOJProblem::query($problem_id));
|
if ($problem) {
|
||||||
|
foreach ($problem->findInContests() as $cp) {
|
||||||
foreach ($contests as $contest) {
|
if ($cp->contest->userHasRegistered($user) && $cp->contest->progress() == CONTEST_IN_PROGRESS) {
|
||||||
if ($contest->userHasRegistered($user) && $contest->progress() == CONTEST_IN_PROGRESS) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,6 +217,15 @@ class UOJBlog {
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSolutionProblem() {
|
||||||
|
return UOJProblem::query(DB::selectSingle([
|
||||||
|
DB::lc(), "select 1 from problems_solutions",
|
||||||
|
"where", [
|
||||||
|
"blog_id" => $this->info['id'],
|
||||||
|
],
|
||||||
|
]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UOJBlog::$table_for_content = 'blogs';
|
UOJBlog::$table_for_content = 'blogs';
|
||||||
|
@ -28,16 +28,6 @@ class UOJContest {
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function queryContestsHasProblem(UOJProblem $problem) {
|
|
||||||
return array_map(fn ($x) => UOJContest::query($x['contest_id']), DB::selectAll([
|
|
||||||
"select contest_id from contests_problems",
|
|
||||||
"where", [
|
|
||||||
"problem_id" => $problem->info['id'],
|
|
||||||
],
|
|
||||||
"order by contest_id",
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function userCanManageSomeContest(array $user = null) {
|
public static function userCanManageSomeContest(array $user = null) {
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -289,10 +289,8 @@ class UOJProblem {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contests = UOJContest::queryContestsHasProblem($this);
|
foreach ($this->findInContests() as $cp) {
|
||||||
|
if ($cp->contest->userHasRegistered($user) && $cp->contest->progress() == CONTEST_IN_PROGRESS) {
|
||||||
foreach ($contests as $contest) {
|
|
||||||
if ($contest->userHasRegistered($user) && $contest->progress() <= CONTEST_IN_PROGRESS) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,12 +324,10 @@ class UOJProblem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function additionalSubmissionComponentsCannotBeSeenByUser(array $user = null, UOJSubmission $submission) {
|
public function additionalSubmissionComponentsCannotBeSeenByUser(array $user = null, UOJSubmission $submission) {
|
||||||
$contests = UOJContest::queryContestsHasProblem($this);
|
foreach ($this->findInContests() as $cp) {
|
||||||
|
if ($cp->contest->userHasRegistered($user) && $cp->contest->progress() == CONTEST_IN_PROGRESS) {
|
||||||
foreach ($contests as $contest) {
|
|
||||||
if ($contest->userHasRegistered($user) && $contest->progress() == CONTEST_IN_PROGRESS) {
|
|
||||||
if ($submission->userIsSubmitter($user)) {
|
if ($submission->userIsSubmitter($user)) {
|
||||||
if ($contest->getJudgeTypeInContest() == 'no-details') {
|
if ($cp->contest->getJudgeTypeInContest() == 'no-details') {
|
||||||
return ['low_level_details'];
|
return ['low_level_details'];
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
|
Loading…
Reference in New Issue
Block a user