Compare commits

..

No commits in common. "b020bc7354b10937bca0e5406ca9783af5cb8ee6" and "36255cb7052da54f52a346352bbe7776d6fe2f2a" have entirely different histories.

3 changed files with 93 additions and 101 deletions

View File

@ -427,7 +427,6 @@ function echoMySubmissions() {
$options[] = ['value' => 'all', 'text' => '所有题目'];
for ($i = 0; $i < count($problems); $i++) {
$problem = UOJContestProblem::query($problems[$i]);
$problem->problem_number = $i;
$options[] = [
'value' => $problem->getLetter(),
'text' => $problem->getTitle(['with' => 'letter', 'simplify' => true]),

View File

@ -153,11 +153,6 @@ if ($cur_tab == 'profile') {
dieWithAlert('移除成功!');
}
if (UOJContest::cur()->getProblemsCount() >= 26) {
$add_problem_form_msg = '比赛中的题目数量已达上限。';
} else if (UOJContest::cur()->progress() > CONTEST_IN_PROGRESS) {
$add_problem_form_msg = '比赛已结束。';
} else {
$add_problem_form = new UOJForm('add_problem');
$add_problem_form->addInput('problem_id', [
'label' => '题目 ID',
@ -228,11 +223,31 @@ if ($cur_tab == 'profile') {
"set", ["extra_config" => $esc_extra_config],
"where", ["id" => UOJContest::info('id')]
]);
dieWithJsonData(['status' => 'success', 'message' => "题目 #{$vdata['problem_id']} 添加成功!"]);
};
$add_problem_form->config['submit_button']['text'] = '添加';
$add_problem_form->config['submit_button']['class'] = 'btn btn-secondary mt-3';
$add_problem_form->runAtServer();
$add_problem_form->setAjaxSubmit(<<<EOD
function(res) {
if (res.status === 'success') {
$('#result-alert')
.html('添加成功!' + (res.message || ''))
.addClass('alert-success')
.removeClass('alert-danger')
.show();
} else {
$('#result-alert')
.html('添加失败。' + (res.message || ''))
.removeClass('alert-success')
.addClass('alert-danger')
.show();
}
$(window).scrollTop(0);
}
EOD);
$add_problem_form->runAtServer();
} elseif ($cur_tab == 'managers') {
$managers_form = newAddDelCmdForm(
'managers',
@ -517,7 +532,7 @@ if ($cur_tab == 'profile') {
<div class="col mt-3 mt-md-0">
<h5>注意事项</h5>
<ul class="mb-0">
<li>请为选手预留合理的做题时间。一般而言CSP NOIP 的比赛时长为 4 小时,NOI 的比赛时长为 5 小时。</li>
<li>请为选手预留合理的做题时间。一般而言CSP NOIP 的比赛时长为 4 小时,省选 / NOI 的比赛时长为 5 小时。</li>
</ul>
</div>
</div>
@ -578,21 +593,7 @@ if ($cur_tab == 'profile') {
<div id="result-alert" class="alert" role="alert" style="display: none"></div>
<div class="row row-cols-1 row-cols-md-2">
<div class="col">
<?php if (isset($add_problem_form)) : ?>
<?php $add_problem_form->printHTML() ?>
<?php else : ?>
<div class="alert alert-warning d-flex align-items-center my-0" role="alert">
<div class="flex-shrink-0 me-3">
<i class="fs-4 bi bi-exclamation-triangle-fill"></i>
</div>
<div>
<div class="fw-bold mb-2">当前比赛无法添加新题目</div>
<?php if (isset($add_problem_form_msg)) : ?>
<div class="small"><?= $add_problem_form_msg ?></div>
<?php endif ?>
</div>
</div>
<?php endif ?>
</div>
<div class="col">
<h5>注意事项</h5>
@ -600,7 +601,6 @@ if ($cur_tab == 'profile') {
<li>推荐在比赛结束前将题目设置为隐藏。</li>
<li>对于「评测设置」选项,一般情况下保持默认(即只测样例)即可。</li>
<li> ACM 赛制中,如果设置一道题目为 bonus 题,那么获得 100 分后会总罚时会减少 20 分钟,但排名时不会将此题记入该选手通过的题目总数中。</li>
<li>一场比赛中最多添加 26 道题目。</li>
</ul>
</div>
</div>

View File

@ -512,13 +512,6 @@ class UOJContest {
]));
}
public function getProblemsCount() {
return DB::selectCount([
DB::lc(), "select count(*) from contests_problems",
"where", ['contest_id' => $this->info['id']]
]);
}
public function hasProblem(UOJProblem $problem) {
return DB::selectFirst([
DB::lc(), "select 1 from contests_problems",