mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 15:28:42 +00:00
feat(web): prepare remote judge
This commit is contained in:
parent
7b7f01dca1
commit
d6997b8475
@ -622,8 +622,10 @@ CREATE TABLE `problems` (
|
||||
`ac_num` int NOT NULL DEFAULT '0',
|
||||
`submit_num` int NOT NULL DEFAULT '0',
|
||||
`difficulty` int NOT NULL DEFAULT '-1',
|
||||
`judge_type` varchar(20) NOT NULL DEFAULT 'local',
|
||||
`assigned_to_judger` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'any',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `judge_type` (`judge_type`),
|
||||
KEY `assigned_to_judger` (`assigned_to_judger`),
|
||||
KEY `uploader` (`uploader`),
|
||||
KEY `difficulty` (`difficulty`),
|
||||
@ -648,6 +650,7 @@ UNLOCK TABLES;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `problems_contents` (
|
||||
`id` int NOT NULL,
|
||||
`remote_content` longtext COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`statement` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`statement_md` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
|
@ -130,17 +130,39 @@ if (isset($_POST['update-status'])) {
|
||||
die();
|
||||
}
|
||||
|
||||
$problem_ban_list = DB::selectAll([
|
||||
$assignCond = [];
|
||||
|
||||
$problem_ban_list = array_map(fn ($x) => $x['id'], DB::selectAll([
|
||||
"select id from problems",
|
||||
"where", [
|
||||
["assigned_to_judger", "!=", "any"],
|
||||
["assigned_to_judger", "!=", $_POST['judger_name']]
|
||||
]
|
||||
]);
|
||||
foreach ($problem_ban_list as &$val) {
|
||||
$val = $val['id'];
|
||||
]));
|
||||
|
||||
if ($problem_ban_list) {
|
||||
$assignCond[] = ["problem_id", "not in", DB::rawtuple($problem_ban_list)];
|
||||
}
|
||||
|
||||
if ($_POST['judger_name'] == "remote_judger") {
|
||||
$problem_ban_list = array_map(fn ($x) => $x['id'], DB::selectAll([
|
||||
"select id from problems",
|
||||
"where", [
|
||||
["judge_type", "!=", "remote"],
|
||||
],
|
||||
]));
|
||||
} else {
|
||||
$problem_ban_list = array_map(fn ($x) => $x['id'], DB::selectAll([
|
||||
"select id from problems",
|
||||
"where", [
|
||||
["judge_type", "!=", "local"],
|
||||
],
|
||||
]));
|
||||
}
|
||||
|
||||
if ($problem_ban_list) {
|
||||
$assignCond[] = ["problem_id", "not in", DB::rawtuple($problem_ban_list)];
|
||||
}
|
||||
$assignCond = $problem_ban_list ? [["problem_id", "not in", DB::rawtuple($problem_ban_list)]] : [];
|
||||
|
||||
$submission = null;
|
||||
$hack = null;
|
||||
|
@ -87,11 +87,18 @@ class UOJSubmission {
|
||||
$judge_reason = '';
|
||||
|
||||
$content['config'][] = ['problem_id', UOJProblem::info('id')];
|
||||
|
||||
if (UOJProblem::info('judge_type') == 'remote') {
|
||||
$content['config'][] = ['remote_online_judge', UOJProblem::cur()->getExtraConfig('remote_online_judge')];
|
||||
$content['config'][] = ['remote_problem_id', UOJProblem::cur()->getExtraConfig('remote_problem_id')];
|
||||
}
|
||||
|
||||
if ($is_contest_submission && UOJContestProblem::cur()->getJudgeTypeInContest() == 'sample') {
|
||||
$content['final_test_config'] = $content['config'];
|
||||
$content['config'][] = ['test_sample_only', 'on'];
|
||||
$judge_reason = json_encode(['text' => '样例测评']);
|
||||
}
|
||||
|
||||
$content_json = json_encode($content);
|
||||
|
||||
$language = static::getAndRememberSubmissionLanguage($content);
|
||||
@ -407,9 +414,14 @@ class UOJSubmission {
|
||||
}
|
||||
|
||||
public function userCanRejudge(array $user = null) {
|
||||
if ($this->problem->info['judge_type'] == 'remote') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSuperUser($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->userCanManageProblemOrContest($user) && $this->hasFullyJudged();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user