mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-12-22 14:21:52 +00:00
Merge branch 'master' into remotejudge-prepare
This commit is contained in:
commit
8cfa371af5
@ -54,10 +54,10 @@ if ($is_manager) {
|
||||
isset($tabs_info[$cur_tab]) || UOJResponse::page404();
|
||||
|
||||
if (UOJContest::cur()->userCanStartFinalTest(Auth::user())) {
|
||||
if (CONTEST_PENDING_FINAL_TEST <= $contest['cur_progress']) {
|
||||
if (CONTEST_PENDING_FINAL_TEST == $contest['cur_progress']) {
|
||||
$start_test_form = new UOJBs4Form('start_test');
|
||||
$start_test_form->handle = function () {
|
||||
UOJContest::finalTest();
|
||||
UOJContest::cur()->finalTest();
|
||||
};
|
||||
$start_test_form->submit_button_config['class_str'] = 'btn btn-danger d-block w-100';
|
||||
$start_test_form->submit_button_config['smart_confirm'] = '';
|
||||
|
@ -596,11 +596,11 @@ EOD);
|
||||
</tr>
|
||||
EOD,
|
||||
function ($row) {
|
||||
$problem = UOJProblem::query($row['problem_id']);
|
||||
$problem = UOJContestProblem::query($row['problem_id'], UOJContest::cur());
|
||||
echo '<tr>';
|
||||
echo '<td>', $row['problem_id'], '</td>';
|
||||
echo '<td>', $problem->getLink(['with' => 'none']), '</td>';
|
||||
echo '<td>', isset($contest['extra_config']["problem_{$problem->info['id']}"]) ? $contest['extra_config']["problem_{$problem->info['id']}"] : 'default', '</td>';
|
||||
echo '<td>', $problem->getJudgeTypeInContest(), '</td>';
|
||||
echo '<td>';
|
||||
echo '<form class="d-inline-block" method="POST" target="_self" onsubmit=\'return confirm("你确定要将题目 #', $problem->info['id'], ' 从比赛中移除吗?")\'>';
|
||||
echo '<input type="hidden" name="_token" value="', crsf_token(), '">';
|
||||
|
@ -467,93 +467,6 @@ $rejudgege97_form->submit_button_config['class_str'] = 'btn btn-danger d-block w
|
||||
$rejudgege97_form->submit_button_config['text'] = '重测 >=97 的程序';
|
||||
$rejudgege97_form->submit_button_config['smart_confirm'] = '';
|
||||
|
||||
$view_type_form = new UOJBs4Form('view_type');
|
||||
$view_type_form->addVSelect(
|
||||
'view_content_type',
|
||||
array(
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC后',
|
||||
'ALL' => '所有人'
|
||||
),
|
||||
'查看提交文件:',
|
||||
$problem_extra_config['view_content_type']
|
||||
);
|
||||
$view_type_form->addVSelect(
|
||||
'view_all_details_type',
|
||||
array(
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC后',
|
||||
'ALL' => '所有人'
|
||||
),
|
||||
'查看全部详细信息:',
|
||||
$problem_extra_config['view_all_details_type']
|
||||
);
|
||||
$view_type_form->addVSelect(
|
||||
'view_details_type',
|
||||
array(
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC后',
|
||||
'ALL' => '所有人'
|
||||
),
|
||||
'查看测试点详细信息:',
|
||||
$problem_extra_config['view_details_type']
|
||||
);
|
||||
$view_type_form->handle = function () {
|
||||
global $problem, $problem_extra_config;
|
||||
|
||||
$config = $problem_extra_config;
|
||||
$config['view_content_type'] = $_POST['view_content_type'];
|
||||
$config['view_all_details_type'] = $_POST['view_all_details_type'];
|
||||
$config['view_details_type'] = $_POST['view_details_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => $problem['id']]
|
||||
]);
|
||||
};
|
||||
$view_type_form->submit_button_config['class_str'] = 'btn btn-warning d-block w-100 mt-2';
|
||||
|
||||
$solution_view_type_form = new UOJBs4Form('solution_view_type');
|
||||
$solution_view_type_form->addVSelect(
|
||||
'view_solution_type',
|
||||
array(
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC后',
|
||||
'ALL' => '所有人'
|
||||
),
|
||||
'查看题解:',
|
||||
$problem_extra_config['view_solution_type']
|
||||
);
|
||||
$solution_view_type_form->addVSelect(
|
||||
'submit_solution_type',
|
||||
array(
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC后',
|
||||
'ALL' => '所有人'
|
||||
),
|
||||
'提交题解:',
|
||||
$problem_extra_config['submit_solution_type']
|
||||
);
|
||||
$solution_view_type_form->handle = function () {
|
||||
global $problem, $problem_extra_config;
|
||||
|
||||
$config = $problem_extra_config;
|
||||
$config['view_solution_type'] = $_POST['view_solution_type'];
|
||||
$config['submit_solution_type'] = $_POST['submit_solution_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => $problem['id']]
|
||||
]);
|
||||
};
|
||||
$solution_view_type_form->submit_button_config['class_str'] = 'btn btn-warning d-block w-100 mt-2';
|
||||
|
||||
if ($problem['hackable']) {
|
||||
$test_std_form = new UOJBs4Form('test_std');
|
||||
$test_std_form->handle = function () use ($problem, $data_disp) {
|
||||
@ -619,8 +532,6 @@ if ($problem['hackable']) {
|
||||
}
|
||||
|
||||
$hackable_form->runAtServer();
|
||||
$view_type_form->runAtServer();
|
||||
$solution_view_type_form->runAtServer();
|
||||
$data_form->runAtServer();
|
||||
$clear_data_form->runAtServer();
|
||||
$rejudge_form->runAtServer();
|
||||
@ -754,18 +665,6 @@ $info_form->runAtServer();
|
||||
<?php $test_std_form->printHTML() ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="mt-2">
|
||||
<button id="button-display_view_type" type="button" class="btn btn-primary d-block w-100" onclick="$('#div-view_type').toggle('fast');">提交记录可视权限</button>
|
||||
<div class="mt-2" id="div-view_type" style="display:none; padding-left:5px; padding-right:5px;">
|
||||
<?php $view_type_form->printHTML(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<button id="button-solution_view_type" type="button" class="btn btn-primary d-block w-100" onclick="$('#div-solution_view_type').toggle('fast');">题解可视权限</button>
|
||||
<div class="mt-2" id="div-solution_view_type" style="display:none; padding-left:5px; padding-right:5px;">
|
||||
<?php $solution_view_type_form->printHTML(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<?php $data_form->printHTML(); ?>
|
||||
</div>
|
||||
|
@ -65,9 +65,12 @@ $problem_editor->runAtServer();
|
||||
|
||||
$difficulty_form = new UOJForm('difficulty');
|
||||
$difficulty_form->addSelect('difficulty', [
|
||||
'div_class' => 'flex-grow-1',
|
||||
'options' => [-1 => '暂无评定'] + array_combine(UOJProblem::$difficulty, UOJProblem::$difficulty),
|
||||
'default_value' => UOJProblem::info('difficulty'),
|
||||
]);
|
||||
$difficulty_form->config['form']['class'] = 'd-flex';
|
||||
$difficulty_form->config['submit_container']['class'] = 'ms-2';
|
||||
$difficulty_form->handle = function () {
|
||||
DB::update([
|
||||
"update problems",
|
||||
@ -151,6 +154,99 @@ if (UOJProblem::cur()->type() == 'remote') {
|
||||
};
|
||||
$re_crawl_form->runAtServer();
|
||||
}
|
||||
|
||||
$view_type_form = new UOJForm('view_type');
|
||||
$view_type_form->addSelect('view_content_type', [
|
||||
'div_class' => 'row align-items-center g-0',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看提交文件',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => $problem_extra_config['view_content_type'],
|
||||
]);
|
||||
$view_type_form->addSelect('view_all_details_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看全部详细信息',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人'
|
||||
],
|
||||
'default_value' => $problem_extra_config['view_all_details_type'],
|
||||
]);
|
||||
$view_type_form->addSelect('view_details_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看测试点详细信息',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'SELF' => '仅自己',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => $problem_extra_config['view_details_type'],
|
||||
]);
|
||||
$view_type_form->handle = function () {
|
||||
$config = UOJProblem::cur()->getExtraConfig();
|
||||
$config['view_content_type'] = $_POST['view_content_type'];
|
||||
$config['view_all_details_type'] = $_POST['view_all_details_type'];
|
||||
$config['view_details_type'] = $_POST['view_details_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => UOJProblem::info('id')]
|
||||
]);
|
||||
};
|
||||
$view_type_form->runAtServer();
|
||||
|
||||
$solution_view_type_form = new UOJForm('solution_view_type');
|
||||
$solution_view_type_form->addSelect('view_solution_type', [
|
||||
'div_class' => 'row align-items-center g-0',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '查看题解',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => $problem_extra_config['view_solution_type'],
|
||||
]);
|
||||
$solution_view_type_form->addSelect('submit_solution_type', [
|
||||
'div_class' => 'row align-items-center g-0 mt-3',
|
||||
'label_class' => 'form-label col-auto m-0 flex-grow-1',
|
||||
'select_class' => 'col-auto form-select w-auto',
|
||||
'label' => '提交题解',
|
||||
'options' => [
|
||||
'NONE' => '禁止',
|
||||
'ALL_AFTER_AC' => 'AC 后',
|
||||
'ALL' => '所有人',
|
||||
],
|
||||
'default_value' => $problem_extra_config['submit_solution_type'],
|
||||
]);
|
||||
$solution_view_type_form->handle = function () {
|
||||
$config = UOJProblem::cur()->getExtraConfig();
|
||||
$config['view_solution_type'] = $_POST['view_solution_type'];
|
||||
$config['submit_solution_type'] = $_POST['submit_solution_type'];
|
||||
$esc_config = json_encode($config);
|
||||
|
||||
DB::update([
|
||||
"update problems",
|
||||
"set", ["extra_config" => $esc_config],
|
||||
"where", ["id" => UOJProblem::info('id')]
|
||||
]);
|
||||
};
|
||||
$solution_view_type_form->runAtServer();
|
||||
?>
|
||||
|
||||
<?php echoUOJPageHeader('题面编辑 - ' . HTML::stripTags(UOJProblem::info('title'))) ?>
|
||||
@ -345,6 +441,24 @@ if (UOJProblem::cur()->type() == 'remote') {
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="card mt-3">
|
||||
<div class="card-header fw-bold">
|
||||
提交记录可视权限
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php $view_type_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-3">
|
||||
<div class="card-header fw-bold">
|
||||
题解可视权限
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php $solution_view_type_form->printHTML() ?>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
|
@ -53,65 +53,6 @@ class UOJContest {
|
||||
return isSuperUser($user) || UOJUser::checkPermission($user, 'contests.create');
|
||||
}
|
||||
|
||||
public static function finalTest() {
|
||||
$contest = self::info();
|
||||
|
||||
$res = DB::selectAll([
|
||||
"select id, problem_id, content, submitter, hide_score_to_others from submissions",
|
||||
"where", ["contest_id" => $contest['id']]
|
||||
]);
|
||||
foreach ($res as $submission) {
|
||||
$content = json_decode($submission['content'], true);
|
||||
if (isset($content['final_test_config'])) {
|
||||
$content['config'] = $content['final_test_config'];
|
||||
unset($content['final_test_config']);
|
||||
}
|
||||
if (isset($content['first_test_config'])) {
|
||||
unset($content['first_test_config']);
|
||||
}
|
||||
UOJSubmission::rejudgeById($submission['id'], [
|
||||
'reason_text' => HTML::stripTags($contest['name']) . ' 最终测试',
|
||||
'reason_url' => HTML::url(UOJContest::cur()->getUri()),
|
||||
'set_q' => [
|
||||
"content" => json_encode($content)
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
// warning: check if this command works well when the database is not MySQL
|
||||
DB::update([
|
||||
"update submissions",
|
||||
"set", [
|
||||
"score = hidden_score",
|
||||
"hidden_score = NULL",
|
||||
"hide_score_to_others = 0"
|
||||
], "where", [
|
||||
"contest_id" => $contest['id'],
|
||||
"hide_score_to_others" => 1
|
||||
]
|
||||
]);
|
||||
|
||||
$updated = [];
|
||||
foreach ($res as $submission) {
|
||||
$submitter = $submission['submitter'];
|
||||
$pid = $submission['problem_id'];
|
||||
if (isset($updated[$submitter]) && isset($updated[$submitter][$pid])) {
|
||||
continue;
|
||||
}
|
||||
updateBestACSubmissions($submitter, $pid);
|
||||
if (!isset($updated[$submitter])) {
|
||||
$updated[$submitter] = [];
|
||||
}
|
||||
$updated[$submitter][$pid] = true;
|
||||
}
|
||||
|
||||
DB::update([
|
||||
"update contests",
|
||||
"set", ["status" => 'testing'],
|
||||
"where", ["id" => $contest['id']]
|
||||
]);
|
||||
}
|
||||
|
||||
public static function announceOfficialResults() {
|
||||
// time config
|
||||
set_time_limit(0);
|
||||
@ -246,11 +187,121 @@ class UOJContest {
|
||||
$label = '开始最终测试';
|
||||
}
|
||||
|
||||
if ($this->progress() >= CONTEST_TESTING) {
|
||||
$label = '重新' . $label;
|
||||
return $label;
|
||||
}
|
||||
|
||||
public function finalTest() {
|
||||
ignore_user_abort(true);
|
||||
set_time_limit(0);
|
||||
|
||||
DB::update([
|
||||
"update contests",
|
||||
"set", ["status" => 'testing'],
|
||||
"where", ["id" => $this->info['id']]
|
||||
]);
|
||||
|
||||
if (DB::affected_rows() !== 1) {
|
||||
// 已经有其他人开始评测了,不进行任何操作
|
||||
return;
|
||||
}
|
||||
|
||||
return $label;
|
||||
$res = DB::selectAll([
|
||||
"select id, problem_id, content, result, submitter, hide_score_to_others from submissions",
|
||||
"where", ["contest_id" => $this->info['id']]
|
||||
]);
|
||||
foreach ($res as $submission) {
|
||||
$content = json_decode($submission['content'], true);
|
||||
|
||||
if (isset($content['final_test_config'])) {
|
||||
$content['config'] = $content['final_test_config'];
|
||||
unset($content['final_test_config']);
|
||||
}
|
||||
|
||||
if (isset($content['first_test_config'])) {
|
||||
unset($content['first_test_config']);
|
||||
}
|
||||
|
||||
$q = [
|
||||
'content' => json_encode($content),
|
||||
];
|
||||
|
||||
$problem_judge_type = $this->info['extra_config']["problem_{$submission['problem_id']}"] ?: $this->defaultProblemJudgeType();
|
||||
$result = json_decode($submission['result'], true);
|
||||
|
||||
switch ($problem_judge_type) {
|
||||
case 'sample':
|
||||
if (isset($result['final_result']) && $result['final_result']['status'] == 'Judged') {
|
||||
$q += [
|
||||
'result' => json_encode($result['final_result']),
|
||||
'score' => $result['final_result']['score'],
|
||||
'used_time' => $result['final_result']['time'],
|
||||
'used_memory' => $result['final_result']['memory'],
|
||||
'judge_time' => $this->info['end_time_str'],
|
||||
'status' => 'Judged',
|
||||
];
|
||||
|
||||
if ($submission['hide_score_to_others']) {
|
||||
$q['hidden_score'] = $q['score'];
|
||||
$q['score'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'no-details':
|
||||
case 'full':
|
||||
if ($result['status'] == 'Judged') {
|
||||
$q += [
|
||||
'result' => $submission['result'],
|
||||
'score' => $result['score'],
|
||||
'used_time' => $result['time'],
|
||||
'used_memory' => $result['memory'],
|
||||
'judge_time' => $this->info['end_time_str'],
|
||||
'status' => 'Judged',
|
||||
];
|
||||
|
||||
if ($submission['hide_score_to_others']) {
|
||||
$q['hidden_score'] = $q['score'];
|
||||
$q['score'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
UOJSubmission::rejudgeById($submission['id'], [
|
||||
'reason_text' => HTML::stripTags($this->info['name']) . ' 最终测试',
|
||||
'reason_url' => HTML::url(UOJContest::cur()->getUri()),
|
||||
'set_q' => $q,
|
||||
]);
|
||||
}
|
||||
|
||||
// warning: check if this command works well when the database is not MySQL
|
||||
DB::update([
|
||||
"update submissions",
|
||||
"set", [
|
||||
"score = hidden_score",
|
||||
"hidden_score = NULL",
|
||||
"hide_score_to_others = 0"
|
||||
], "where", [
|
||||
"contest_id" => $this->info['id'],
|
||||
"hide_score_to_others" => 1
|
||||
]
|
||||
]);
|
||||
|
||||
$updated = [];
|
||||
foreach ($res as $submission) {
|
||||
$submitter = $submission['submitter'];
|
||||
$pid = $submission['problem_id'];
|
||||
if (isset($updated[$submitter]) && isset($updated[$submitter][$pid])) {
|
||||
continue;
|
||||
}
|
||||
updateBestACSubmissions($submitter, $pid);
|
||||
if (!isset($updated[$submitter])) {
|
||||
$updated[$submitter] = [];
|
||||
}
|
||||
$updated[$submitter][$pid] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function queryJudgeProgress() {
|
||||
|
@ -13,25 +13,29 @@ if (!isset($ShowPageFooter)) {
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])) : ?>
|
||||
<footer class="bg-white text-muted pt-3 pb-4 mt-4" style="font-size: 0.9em">
|
||||
<div class="container d-lg-flex justify-content-lg-between">
|
||||
<p>
|
||||
© <?= date('Y') ?>
|
||||
<a class="text-decoration-none" href="<?= HTML::url('/') ?>">S2OJ</a>
|
||||
(build: <a class="text-decoration-none" href="https://github.com/renbaoshuo/S2OJ<?= UOJConfig::$data['profile']['s2oj-version'] == "dev" ? '' : '/tree/' . UOJConfig::$data['profile']['s2oj-version'] ?>"><?= UOJConfig::$data['profile']['s2oj-version'] ?></a>)
|
||||
<?= UOJLocale::get('server time') ?>: <?= UOJTime::$time_now_str ?>
|
||||
<?php if (UOJConfig::$data['profile']['ICP-license'] != '') : ?>
|
||||
| <a class="text-muted text-decoration-none" target="_blank" href="https://beian.miit.gov.cn">
|
||||
<?= UOJConfig::$data['profile']['ICP-license'] ?>
|
||||
</a>
|
||||
<?php endif ?>
|
||||
</p>
|
||||
<p>
|
||||
<div>
|
||||
<div>
|
||||
© <?= date('Y') ?>
|
||||
<a class="text-decoration-none" href="<?= HTML::url('/') ?>">S2OJ</a>
|
||||
(build: <a class="text-decoration-none" href="https://github.com/renbaoshuo/S2OJ<?= UOJConfig::$data['profile']['s2oj-version'] == "dev" ? '' : '/tree/' . UOJConfig::$data['profile']['s2oj-version'] ?>"><?= UOJConfig::$data['profile']['s2oj-version'] ?></a>)
|
||||
<?php if (UOJConfig::$data['profile']['ICP-license'] != '') : ?>
|
||||
| <a class="text-muted text-decoration-none" target="_blank" href="https://beian.miit.gov.cn">
|
||||
<?= UOJConfig::$data['profile']['ICP-license'] ?>
|
||||
</a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="small mt-1">
|
||||
<?= UOJLocale::get('server time') ?>: <?= UOJTime::$time_now_str ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-2 mt-lg-0">
|
||||
Based on
|
||||
<a class="text-decoration-none" href="https://uoj.ac" target="_blank">UOJ</a>,
|
||||
modified by
|
||||
<a class="text-decoration-none" href="https://baoshuo.ren" target="_blank">Baoshuo</a>
|
||||
for
|
||||
<a class="text-decoration-none" href="http://www.sjzez.com">SJZEZ</a>.
|
||||
</p>
|
||||
<a class="text-decoration-none" href="http://www.sjzez.com">SJZEZ</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<?php else : ?>
|
||||
|
Loading…
Reference in New Issue
Block a user