From 09ee452c0765f66fd7d530ef4db9540f9cf03a67 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 1 Feb 2023 20:27:05 +0800 Subject: [PATCH] fix(problem): no submission_requirement warning --- web/app/controllers/problem.php | 15 ++++++--------- web/app/models/UOJProblem.php | 11 ++++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/web/app/controllers/problem.php b/web/app/controllers/problem.php index 1575b6d..bd23685 100644 --- a/web/app/controllers/problem.php +++ b/web/app/controllers/problem.php @@ -101,7 +101,7 @@ if (UOJContest::cur()) { $submission_requirement = UOJProblem::cur()->getSubmissionRequirement(); $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) { global $is_participating; @@ -171,11 +171,8 @@ if ($custom_test_enabled) { $custom_test_form->runAtServer(); } -$can_use_zip_upload = true; -foreach ($submission_requirement as $req) { - if ($req['type'] == 'source code') { - $can_use_zip_upload = false; - } +if (empty($submission_requirement)) { + $no_more_submission = '当前题目未配置提交文件,请联系管理员!'; } if ($pre_submit_check_ret === true && !$no_more_submission) { @@ -274,12 +271,12 @@ if (UOJContest::cur()) {
-

+

-

+

-

+

printHTML(); ?> diff --git a/web/app/models/UOJProblem.php b/web/app/models/UOJProblem.php index d5ca165..f836e3b 100644 --- a/web/app/models/UOJProblem.php +++ b/web/app/models/UOJProblem.php @@ -460,10 +460,6 @@ class UOJProblem { return $key === null ? $extra_config : $extra_config[$key]; } public function getCustomTestRequirement() { - if ($this->info['type'] == 'remote') { - return []; - } - $extra_config = json_decode($this->info['extra_config'], true); if (isset($extra_config['custom_test_requirement'])) { @@ -559,11 +555,16 @@ class UOJProblem { } 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') { return false; } } + return true; }