Skip to content

Commit

Permalink
fix(support IOI competition system):#6 (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Llf0703 authored and billchenchina committed Jun 11, 2019
1 parent c12d2c6 commit 133268d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
9 changes: 7 additions & 2 deletions uoj/1/app/controllers/contest_inside.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,13 @@ function echoContestFinished() {
</div>
<div class="col-sm-3">
<?php endif ?>
<p>此次比赛为OI赛制。</p>
<p><strong>注意:比赛时只显示测样例的结果。</strong></p>
<?php if (!isset($contest['extra_config']['contest_type']) || $contest['extra_config']['contest_type']=='OI'):?>
<p>此次比赛为OI赛制。</p>
<p><strong>注意:比赛时只显示测样例的结果。</strong></p>
<?php elseif ($contest['extra_config']['contest_type']=='IOI'):?>
<p>此次比赛为IOI赛制。</p>
<p><strong>注意:比赛时显示测试所有数据的结果,但无法看到详细信息。</strong></p>
<?php endif?>

<a href="/contest/<?=$contest['id']?>/registrants" class="btn btn-info btn-block"><?= UOJLocale::get('contests::contest registrants') ?></a>
<?php if (isSuperUser($myUser)): ?>
Expand Down
23 changes: 23 additions & 0 deletions uoj/1/app/controllers/contest_manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,25 @@ function ($x) {
DB::update("update contests set extra_config = '$esc_extra_config' where id = {$contest['id']}");
};
$version_form->runAtServer();

$contest_type_form = new UOJForm('contest_type');
$contest_type_form->addInput('contest_type', 'text', '赛制', $contest['extra_config']['contest_type'],
function ($x) {
if ($x != 'OI' && $x != 'ACM' && $x != 'IOI') {
return '不是合法的赛制名';
}
return '';
},
null
);
$contest_type_form->handle = function() {
global $contest;
$contest['extra_config']['contest_type'] = $_POST['contest_type'];
$esc_extra_config = json_encode($contest['extra_config']);
$esc_extra_config = DB::escape($esc_extra_config);
DB::update("update contests set extra_config = '$esc_extra_config' where id = {$contest['id']}");
};
$contest_type_form->runAtServer();
}

$time_form->runAtServer();
Expand Down Expand Up @@ -255,6 +274,10 @@ function ($x) {
<h3>版本控制</h3>
<?php $version_form->printHTML(); ?>
</div>
<div class="col-sm-12 top-buffer-sm">
<h3>赛制</h3>
<?php $contest_type_form->printHTML(); ?>
</div>
</div>
</div>
<?php endif ?>
Expand Down
2 changes: 1 addition & 1 deletion uoj/1/app/controllers/problem.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function handleUpload($zip_file_name, $content, $tot_size) {
global $problem, $contest, $myUser, $is_in_contest;

$content['config'][] = array('problem_id', $problem['id']);
if ($is_in_contest && !isset($contest['extra_config']["problem_{$problem['id']}"])) {
if ($is_in_contest && $contest['extra_config']["contest_type"]!='IOI' && !isset($contest['extra_config']["problem_{$problem['id']}"])) {
$content['final_test_config'] = $content['config'];
$content['config'][] = array('test_sample_only', 'on');
}
Expand Down
5 changes: 4 additions & 1 deletion uoj/1/app/controllers/submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@

if ($should_show_all_details) {
$styler = new SubmissionDetailsStyler();
if (!$should_show_details) {
if ((!$should_show_details || ($contest['extra_config']['contest_type']=='IOI' && $contest['cur_progress'] == CONTEST_IN_PROGRESS)) && !hasContestPermission($myUser, $contest)) {
$styler->fade_all_details = true;
$styler->show_small_tip = false;
if ($contest['extra_config']['contest_type']=='IOI' && $contest['cur_progress'] == CONTEST_IN_PROGRESS) {
$styler->ioi_contest_is_running = true;
}
}
}
?>
Expand Down
4 changes: 4 additions & 0 deletions uoj/1/app/libs/uoj-html-lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ private function _print($node) {
if ($this->styler->show_small_tip) {
echo '<div class="text-right text-muted">', '小提示:点击横条可展开更详细的信息', '</div>';
}
elseif ($this->styler->ioi_contest_is_running) {
echo '<div class="text-right text-muted">', 'IOI赛制比赛中不支持显示详细信息', '</div>';
}
$this->_print_c($node);
echo '</div>';
} elseif ($node->nodeName == 'subtask') {
Expand Down Expand Up @@ -721,6 +724,7 @@ class CustomTestSubmissionDetailsStyler {
public $show_small_tip = false;
public $collapse_in = true;
public $fade_all_details = false;
public $ioi_contest_is_running = false;
public function getTestInfoClass($info) {
if ($info == 'Success') {
return 'panel-uoj-accepted';
Expand Down

0 comments on commit 133268d

Please sign in to comment.