info; $problem_content = UOJProblem::cur()->queryContent(); if (UOJRequest::get('contest_id')) { UOJContest::init(UOJRequest::get('contest_id')) || UOJResponse::page404(); UOJProblem::upgradeToContestProblem() || UOJResponse::page404(); } UOJProblem::cur()->userCanView(Auth::user(), ['ensure' => true]); $pre_submit_check_ret = UOJProblem::cur()->preSubmitCheck(); $is_participating = false; $no_more_submission = false; $submission_warning = null; if (UOJContest::cur()) { if (UOJContest::cur()->userCanParticipateNow(Auth::user())) { if (!UOJContest::cur()->userHasMarkedParticipated(Auth::user())) { redirectTo(UOJContest::cur()->getUri("/confirm")); } $is_participating = true; $submit_time_limit = UOJContestProblem::cur()->submitTimeLimit(); $max_cnt = UOJContest::cur()->maxSubmissionCountPerProblem(); if ($submit_time_limit != -1) { $cur_contest_time = (UOJTime::$time_now->getTimestamp() - UOJContest::info('start_time')->getTimestamp()) / 60; if ($cur_contest_time > $submit_time_limit) { $no_more_submission = "本题只能在比赛的前 {$submit_time_limit} 分钟提交,没法再交咯"; } } if (!$no_more_submission) { if ($max_cnt != -1) { $cnt = UOJContestProblem::cur()->queryUserSubmissionCountInContest(Auth::user()); if ($cnt >= $max_cnt) { $no_more_submission = "提交次数已达到 {$cnt} 次,没法再交咯"; } } } if (!$no_more_submission) { if ($max_cnt != -1) { $warning1 = "已使用 {$cnt}/{$max_cnt} 次提交机会"; } else { $warning1 = null; } if ($submit_time_limit != -1) { $warning2 = "注意本题只能在比赛的前 {$submit_time_limit} 分钟提交"; } else { $warning2 = null; } if ($warning1 && $warning2) { $submission_warning = "{$warning1}({$warning2})"; } else { $submission_warning = $warning1 !== null ? $warning1 : $warning2; } } } // 比赛导航 $tabs_info = [ 'dashboard' => [ 'name' => UOJLocale::get('contests::contest dashboard'), 'url' => UOJContest::cur()->getUri(), ], 'submissions' => [ 'name' => UOJLocale::get('contests::contest submissions'), 'url' => UOJContest::cur()->getUri('/submissions'), ], 'standings' => [ 'name' => UOJLocale::get('contests::contest standings'), 'url' => UOJContest::cur()->getUri('/standings'), ], ]; if (UOJContest::cur()->progress() > CONTEST_TESTING) { $tabs_info['after_contest_standings'] = [ 'name' => UOJLocale::get('contests::after contest standings'), 'url' => UOJContest::cur()->getUri('/after_contest_standings'), ]; $tabs_info['self_reviews'] = [ 'name' => UOJLocale::get('contests::contest self reviews'), 'url' => UOJContest::cur()->getUri('/self_reviews'), ]; } if (UOJContest::cur()->userCanManage(Auth::user())) { $tabs_info['backstage'] = [ 'name' => UOJLocale::get('contests::contest backstage'), 'url' => UOJContest::cur()->getUri('/backstage'), ]; } } $submission_requirement = UOJProblem::cur()->getSubmissionRequirement(); $custom_test_requirement = UOJProblem::cur()->getCustomTestRequirement(); $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; $remote_oj = UOJProblem::cur()->getExtraConfig('remote_online_judge'); $remote_provider = UOJRemoteProblem::$providers[$remote_oj]; if (UOJProblem::info('type') == 'remote') { $submit_type = in_array($_POST['answer_remote_submit_type'], $remote_provider['submit_type']) ? $_POST['answer_remote_submit_type'] : $remote_provider['submit_type'][0]; $content['remote_judge'] = true; $content['config'][] = ['remote_submit_type', $submit_type]; if ($submit_type != 'bot') { $content['no_rejudge'] = true; $content['config'][] = ['remote_account_data', $_POST['answer_remote_account_data']]; } if ($submit_type == 'archive') { $content['remote_submission_id'] = $_POST['answer_remote_submission_id']; $content['config'][] = ['remote_submission_id', $_POST['answer_remote_submission_id']]; $content['config'] = array_values(array_filter( $content['config'], function ($row) { return !strEndWith($row[0], '_language'); }, )); $zip_file = new ZipArchive(); $zip_file->open(UOJContext::storagePath() . $zip_file_name, ZipArchive::OVERWRITE); $zip_file->addFromString('answer.code', ''); $zip_file->close(); $tot_size = 0; } } $id = UOJSubmission::onUpload($zip_file_name, $content, $tot_size, $is_participating); if ($is_participating) { // redirect by UOJForm } else { redirectTo("/submission/$id"); } } function handleCustomTestUpload($zip_file_name, $content, $tot_size) { UOJCustomTestSubmission::onUpload($zip_file_name, $content, $tot_size); } if ($custom_test_enabled) { UOJCustomTestSubmission::init(UOJProblem::cur(), Auth::user()); if (UOJRequest::get('get') == 'custom-test-status-details') { if (!UOJCustomTestSubmission::cur()) { echo json_encode(null); } elseif (!UOJCustomTestSubmission::cur()->hasJudged()) { echo json_encode([ 'judged' => false, 'waiting' => true, 'html' => UOJCustomTestSubmission::cur()->getStatusDetailsHTML(), ]); } else { ob_start(); $styler = new CustomTestSubmissionDetailsStyler(); if (!UOJCustomTestSubmission::cur()->userPermissionCodeCheck(Auth::user(), UOJProblem::cur()->getExtraConfig('view_details_type'))) { $styler->fade_all_details = true; } echoJudgmentDetails(UOJCustomTestSubmission::cur()->getResult('details'), $styler, 'custom_test_details'); $result = ob_get_contents(); ob_end_clean(); echo json_encode([ 'judged' => true, 'waiting' => false, 'html' => UOJCustomTestSubmission::cur()->getStatusDetailsHTML(), 'result' => $result ]); } die(); } $custom_test_form = newSubmissionForm( 'custom_test', $custom_test_requirement, 'FS::randomAvailableTmpFileName', 'handleCustomTestUpload' ); $custom_test_form->appendHTML('
'); $custom_test_form->succ_href = 'none'; $custom_test_form->extra_validator = function () { if (UOJCustomTestSubmission::cur() && !UOJCustomTestSubmission::cur()->hasJudged()) { return '上一个测评尚未结束'; } return ''; }; $custom_test_form->setAjaxSubmit(<<= $pre_submit_check_ret ?>
= $no_more_submission ?>
= $submission_warning ?>
printHTML(); ?>