fix(problem): no submission_requirement warning
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-01 20:27:05 +08:00
parent 32851eaf57
commit 09ee452c07
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 12 additions and 14 deletions

View File

@ -101,7 +101,7 @@ if (UOJContest::cur()) {
$submission_requirement = UOJProblem::cur()->getSubmissionRequirement(); $submission_requirement = UOJProblem::cur()->getSubmissionRequirement();
$custom_test_requirement = UOJProblem::cur()->getCustomTestRequirement(); $custom_test_requirement = UOJProblem::cur()->getCustomTestRequirement();
$custom_test_enabled = $custom_test_requirement && $pre_submit_check_ret === true; $custom_test_enabled = $custom_test_requirement && $pre_submit_check_ret === true && UOJProblem::info('type') != 'remote';
function handleUpload($zip_file_name, $content, $tot_size) { function handleUpload($zip_file_name, $content, $tot_size) {
global $is_participating; global $is_participating;
@ -171,11 +171,8 @@ if ($custom_test_enabled) {
$custom_test_form->runAtServer(); $custom_test_form->runAtServer();
} }
$can_use_zip_upload = true; if (empty($submission_requirement)) {
foreach ($submission_requirement as $req) { $no_more_submission = '当前题目未配置提交文件,请联系管理员!';
if ($req['type'] == 'source code') {
$can_use_zip_upload = false;
}
} }
if ($pre_submit_check_ret === true && !$no_more_submission) { if ($pre_submit_check_ret === true && !$no_more_submission) {
@ -274,12 +271,12 @@ if (UOJContest::cur()) {
</div> </div>
<div class="tab-pane" id="submit"> <div class="tab-pane" id="submit">
<?php if ($pre_submit_check_ret !== true) : ?> <?php if ($pre_submit_check_ret !== true) : ?>
<h3 class="text-warning"><?= $pre_submit_check_ret ?></h3> <p class="text-warning h4"><?= $pre_submit_check_ret ?></p>
<?php elseif ($no_more_submission) : ?> <?php elseif ($no_more_submission) : ?>
<h3 class="text-warning"><?= $no_more_submission ?></h3> <p class="text-warning h4"><?= $no_more_submission ?></p>
<?php else : ?> <?php else : ?>
<?php if ($submission_warning) : ?> <?php if ($submission_warning) : ?>
<h3 class="text-warning"><?= $submission_warning ?></h3> <p class="text-warning h4"><?= $submission_warning ?></p>
<?php endif ?> <?php endif ?>
<?php if (isset($zip_answer_form)) : ?> <?php if (isset($zip_answer_form)) : ?>
<?php $zip_answer_form->printHTML(); ?> <?php $zip_answer_form->printHTML(); ?>

View File

@ -460,10 +460,6 @@ class UOJProblem {
return $key === null ? $extra_config : $extra_config[$key]; return $key === null ? $extra_config : $extra_config[$key];
} }
public function getCustomTestRequirement() { public function getCustomTestRequirement() {
if ($this->info['type'] == 'remote') {
return [];
}
$extra_config = json_decode($this->info['extra_config'], true); $extra_config = json_decode($this->info['extra_config'], true);
if (isset($extra_config['custom_test_requirement'])) { if (isset($extra_config['custom_test_requirement'])) {
@ -559,11 +555,16 @@ class UOJProblem {
} }
public function userCanUploadSubmissionViaZip(array $user = null) { public function userCanUploadSubmissionViaZip(array $user = null) {
foreach ($this->getSubmissionRequirement() as $req) { $submission_requirement = $this->getSubmissionRequirement();
if (empty($submission_requirement)) return false;
foreach ($submission_requirement as $req) {
if ($req['type'] == 'source code') { if ($req['type'] == 'source code') {
return false; return false;
} }
} }
return true; return true;
} }