2016-07-18 16:39:37 +00:00
< ? php
requirePHPLib ( 'form' );
2022-03-17 04:00:03 +00:00
2022-10-04 06:06:03 +00:00
$REQUIRE_LIB [ 'bootstrap5' ] = '' ;
2022-09-21 10:35:30 +00:00
$REQUIRE_LIB [ 'mathjax' ] = '' ;
2022-10-07 09:29:26 +00:00
if ( ! Auth :: check () && UOJConfig :: $data [ 'switch' ][ 'force-login' ]) {
2022-10-06 12:28:43 +00:00
redirectToLogin ();
2022-03-17 04:00:03 +00:00
}
2016-07-18 16:39:37 +00:00
if ( ! validateUInt ( $_GET [ 'id' ]) || ! ( $contest = queryContest ( $_GET [ 'id' ]))) {
become404Page ();
}
genMoreContestInfo ( $contest );
2018-07-09 02:40:30 +00:00
if ( ! hasContestPermission ( Auth :: user (), $contest )) {
2016-07-18 16:39:37 +00:00
if ( $contest [ 'cur_progress' ] == CONTEST_NOT_STARTED ) {
header ( " Location: /contest/ { $contest [ 'id' ] } /register " );
die ();
} elseif ( $contest [ 'cur_progress' ] == CONTEST_IN_PROGRESS ) {
2018-07-09 02:40:30 +00:00
if ( $myUser == null || ! hasRegistered ( Auth :: user (), $contest )) {
2016-07-18 16:39:37 +00:00
becomeMsgPage ( " <h1>比赛正在进行中</h1><p>很遗憾,您尚未报名。比赛结束后再来看吧~</p> " );
}
2022-04-03 10:18:17 +00:00
} else {
if ( ! isNormalUser ( $myUser )) {
become403Page ();
}
2016-07-18 16:39:37 +00:00
}
}
if ( isset ( $_GET [ 'tab' ])) {
$cur_tab = $_GET [ 'tab' ];
} else {
$cur_tab = 'dashboard' ;
}
2018-07-09 02:40:30 +00:00
$tabs_info = array (
'dashboard' => array (
'name' => UOJLocale :: get ( 'contests::contest dashboard' ),
'url' => " /contest/ { $contest [ 'id' ] } "
),
'submissions' => array (
'name' => UOJLocale :: get ( 'contests::contest submissions' ),
'url' => " /contest/ { $contest [ 'id' ] } /submissions "
),
'standings' => array (
'name' => UOJLocale :: get ( 'contests::contest standings' ),
'url' => " /contest/ { $contest [ 'id' ] } /standings "
2022-04-13 08:23:24 +00:00
),
2022-09-19 11:27:57 +00:00
);
if ( $contest [ 'cur_progress' ] > CONTEST_TESTING ) {
$tabs_info [ 'after_contest_standings' ] = array (
2022-04-13 08:23:24 +00:00
'name' => UOJLocale :: get ( 'contests::after contest standings' ),
'url' => " /contest/ { $contest [ 'id' ] } /after_contest_standings "
2022-09-19 11:27:57 +00:00
);
$tabs_info [ 'self_reviews' ] = array (
'name' => UOJLocale :: get ( 'contests::contest self reviews' ),
'url' => " /contest/ { $contest [ 'id' ] } /self_reviews "
);
}
2018-07-09 02:40:30 +00:00
if ( hasContestPermission ( Auth :: user (), $contest )) {
$tabs_info [ 'backstage' ] = array (
'name' => UOJLocale :: get ( 'contests::contest backstage' ),
'url' => " /contest/ { $contest [ 'id' ] } /backstage "
);
2016-07-18 16:39:37 +00:00
}
2018-07-09 02:40:30 +00:00
if ( ! isset ( $tabs_info [ $cur_tab ])) {
become404Page ();
}
if ( isset ( $_POST [ 'check_notice' ])) {
$result = DB :: query ( " select * from contests_notice where contest_id = ' ${ contest['id'] } ' order by time desc limit 10 " );
$ch = array ();
$flag = false ;
try {
while ( $row = DB :: fetch ( $result )) {
if ( new DateTime ( $row [ 'time' ]) > new DateTime ( $_POST [ 'last_time' ])) {
$ch [] = $row [ 'title' ] . ': ' . $row [ 'content' ];
2016-07-18 16:39:37 +00:00
}
}
2018-07-09 02:40:30 +00:00
} catch ( Exception $e ) {
2016-07-18 16:39:37 +00:00
}
2018-07-09 02:40:30 +00:00
global $myUser ;
2022-10-04 06:06:03 +00:00
$result = DB :: query ( " select * from contests_asks where contest_id=' ${ contest['id'] } ' and username=' ${ myUser['username'] } ' order by reply_time desc limit 10 " );
2018-07-09 02:40:30 +00:00
try {
while ( $row = DB :: fetch ( $result )) {
if ( new DateTime ( $row [ 'reply_time' ]) > new DateTime ( $_POST [ 'last_time' ])) {
$ch [] = $row [ 'question' ] . ': ' . $row [ 'answer' ];
2016-07-18 16:39:37 +00:00
}
}
2018-07-09 02:40:30 +00:00
} catch ( Exception $e ) {
2016-07-18 16:39:37 +00:00
}
2018-07-09 02:40:30 +00:00
if ( $ch ) {
die ( json_encode ( array ( 'msg' => $ch , 'time' => UOJTime :: $time_now_str )));
} else {
die ( json_encode ( array ( 'time' => UOJTime :: $time_now_str )));
2016-07-18 16:39:37 +00:00
}
}
2022-09-21 11:26:13 +00:00
if ( isSuperUser ( $myUser ) || isContestJudger ( $myUser )) {
if ( CONTEST_PENDING_FINAL_TEST <= $contest [ 'cur_progress' ]) {
2016-07-18 16:39:37 +00:00
$start_test_form = new UOJForm ( 'start_test' );
$start_test_form -> handle = function () {
global $contest ;
2017-11-25 15:29:18 +00:00
$result = DB :: query ( " select id, problem_id, content from submissions where contest_id = { $contest [ 'id' ] } " );
while ( $submission = DB :: fetch ( $result , MYSQLI_ASSOC )) {
2016-07-18 16:39:37 +00:00
if ( ! isset ( $contest [ 'extra_config' ][ " problem_ { $submission [ 'problem_id' ] } " ])) {
2020-06-25 12:41:16 +00:00
$content = json_decode ( $submission [ 'content' ], true );
2016-07-18 16:39:37 +00:00
if ( isset ( $content [ 'final_test_config' ])) {
$content [ 'config' ] = $content [ 'final_test_config' ];
unset ( $content [ 'final_test_config' ]);
}
if ( isset ( $content [ 'first_test_config' ])) {
unset ( $content [ 'first_test_config' ]);
}
2017-11-25 15:29:18 +00:00
$esc_content = DB :: escape ( json_encode ( $content ));
2016-07-18 16:39:37 +00:00
DB :: update ( " update submissions set judge_time = NULL, result = '', score = NULL, status = 'Waiting Rejudge', content = ' $esc_content ' where id = { $submission [ 'id' ] } " );
}
}
2017-11-25 15:29:18 +00:00
DB :: query ( " update contests set status = 'testing' where id = { $contest [ 'id' ] } " );
2016-07-18 16:39:37 +00:00
};
2022-10-04 06:06:03 +00:00
$start_test_form -> submit_button_config [ 'class_str' ] = 'btn btn-danger d-block w-100' ;
2016-07-18 16:39:37 +00:00
$start_test_form -> submit_button_config [ 'smart_confirm' ] = '' ;
if ( $contest [ 'cur_progress' ] < CONTEST_TESTING ) {
$start_test_form -> submit_button_config [ 'text' ] = '开始最终测试' ;
} else {
$start_test_form -> submit_button_config [ 'text' ] = '重新开始最终测试' ;
}
$start_test_form -> runAtServer ();
}
if ( $contest [ 'cur_progress' ] >= CONTEST_TESTING ) {
$publish_result_form = new UOJForm ( 'publish_result' );
$publish_result_form -> handle = function () {
// time config
set_time_limit ( 0 );
ignore_user_abort ( true );
global $contest ;
2018-07-09 02:40:30 +00:00
$contest_data = queryContestData ( $contest );
calcStandings ( $contest , $contest_data , $score , $standings , true );
2016-07-18 16:39:37 +00:00
for ( $i = 0 ; $i < count ( $standings ); $i ++ ) {
$user = queryUser ( $standings [ $i ][ 2 ][ 0 ]);
$user_link = getUserLink ( $user [ 'username' ]);
2017-11-25 15:29:18 +00:00
DB :: query ( " update contests_registrants set rank = { $standings [ $i ][ 3 ] } where contest_id = { $contest [ 'id' ] } and username = ' { $standings [ $i ][ 2 ][ 0 ] } ' " );
2016-07-18 16:39:37 +00:00
}
2017-11-25 15:29:18 +00:00
DB :: query ( " update contests set status = 'finished' where id = { $contest [ 'id' ] } " );
2016-07-18 16:39:37 +00:00
};
2022-10-04 06:06:03 +00:00
$publish_result_form -> submit_button_config [ 'class_str' ] = 'btn btn-danger d-block w-100' ;
2016-07-18 16:39:37 +00:00
$publish_result_form -> submit_button_config [ 'smart_confirm' ] = '' ;
$publish_result_form -> submit_button_config [ 'text' ] = '公布成绩' ;
$publish_result_form -> runAtServer ();
}
}
2018-07-09 02:40:30 +00:00
if ( $cur_tab == 'dashboard' ) {
if ( $contest [ 'cur_progress' ] <= CONTEST_IN_PROGRESS ) {
$post_question = new UOJForm ( 'post_question' );
$post_question -> addVTextArea ( 'qcontent' , '问题' , '' ,
function ( $content ) {
if ( ! Auth :: check ()) {
return '您尚未登录' ;
}
if ( ! $content || strlen ( $content ) == 0 ) {
return '问题不能为空' ;
}
if ( strlen ( $content ) > 140 * 4 ) {
return '问题太长' ;
}
return '' ;
},
null
);
$post_question -> handle = function () {
global $contest ;
$content = DB :: escape ( $_POST [ 'qcontent' ]);
$username = Auth :: id ();
DB :: query ( " insert into contests_asks (contest_id, question, username, post_time, is_hidden) values (' { $contest [ 'id' ] } ', ' $content ', ' $username ', now(), 1) " );
};
$post_question -> runAtServer ();
} else {
$post_question = null ;
}
} elseif ( $cur_tab == 'backstage' ) {
if ( isSuperUser ( Auth :: user ())) {
$post_notice = new UOJForm ( 'post_notice' );
$post_notice -> addInput ( 'title' , 'text' , '标题' , '' ,
function ( $title ) {
if ( ! $title ) {
return '标题不能为空' ;
}
return '' ;
},
null
);
$post_notice -> addTextArea ( 'content' , '正文' , '' ,
function ( $content ) {
if ( ! $content ) {
return '公告不能为空' ;
}
return '' ;
},
null
);
$post_notice -> handle = function () {
global $contest ;
$title = DB :: escape ( $_POST [ 'title' ]);
$content = DB :: escape ( $_POST [ 'content' ]);
DB :: insert ( " insert into contests_notice (contest_id, title, content, time) values (' { $contest [ 'id' ] } ', ' $title ', ' $content ', now()) " );
};
$post_notice -> runAtServer ();
} else {
$post_notice = null ;
}
if ( hasContestPermission ( Auth :: user (), $contest )) {
$reply_question = new UOJForm ( 'reply_question' );
$reply_question -> addHidden ( 'rid' , '0' ,
function ( $id ) {
2020-06-25 12:41:16 +00:00
global $contest ;
2018-07-09 02:40:30 +00:00
if ( ! validateUInt ( $id )) {
return '无效ID' ;
}
$q = DB :: selectFirst ( " select * from contests_asks where id = $id " );
if ( $q [ 'contest_id' ] != $contest [ 'id' ]) {
2020-06-25 12:41:16 +00:00
return '无效ID' ;
2018-07-09 02:40:30 +00:00
}
return '' ;
},
null
);
$reply_question -> addVSelect ( 'rtype' , [
'public' => '公开' ,
'private' => '非公开' ,
'statement' => '请仔细阅读题面(非公开)' ,
'no_comment' => '无可奉告(非公开)' ,
'no_play' => '请认真比赛(非公开)' ,
], '回复类型' , 'private' );
$reply_question -> addVTextArea ( 'rcontent' , '回复' , '' ,
function ( $content ) {
2020-06-25 12:41:16 +00:00
if ( ! Auth :: check ()) {
return '您尚未登录' ;
}
switch ( $_POST [ 'rtype' ]) {
2022-09-18 04:58:35 +00:00
case 'public' :
case 'private' :
if ( strlen ( $content ) == 0 ) {
return '回复不能为空' ;
}
2018-07-09 02:40:30 +00:00
break ;
2022-09-18 04:58:35 +00:00
}
2018-07-09 02:40:30 +00:00
return '' ;
},
null
);
$reply_question -> handle = function () {
global $contest ;
$content = DB :: escape ( $_POST [ 'rcontent' ]);
$is_hidden = 1 ;
switch ( $_POST [ 'rtype' ]) {
case 'statement' :
$content = '请仔细阅读题面' ;
break ;
case 'no_comment' :
$content = '无可奉告 ╮(╯▽╰)╭ ' ;
break ;
case 'no_play' :
$content = '请认真比赛 ( ̄口 ̄)!!' ;
break ;
case 'public' :
$is_hidden = 0 ;
break ;
default :
break ;
}
DB :: update ( " update contests_asks set answer = ' $content ', reply_time = now(), is_hidden = { $is_hidden } where id = { $_POST [ 'rid' ] } " );
};
$reply_question -> runAtServer ();
} else {
$reply_question = null ;
}
2022-09-19 23:49:45 +00:00
} elseif ( $cur_tab == 'self_reviews' ) {
if ( hasParticipated ( Auth :: user (), $contest )) {
$self_reviews_update_form = new UOJForm ( 'self_review_update' );
$self_reviews_update_form -> ctrl_enter_submit = true ;
$contest_problems = DB :: selectAll ( " select problem_id from contests_problems where contest_id = { $contest [ 'id' ] } order by dfn, problem_id " );
for ( $i = 0 ; $i < count ( $contest_problems ); $i ++ ) {
$contest_problems [ $i ][ 'problem' ] = queryProblemBrief ( $contest_problems [ $i ][ 'problem_id' ]);
}
for ( $i = 0 ; $i < count ( $contest_problems ); $i ++ ) {
$content = DB :: selectFirst ( " select content from contests_reviews where contest_id = { $contest [ 'id' ] } and problem_id = { $contest_problems [ $i ][ 'problem_id' ] } and poster = ' { $myUser [ 'username' ] } ' " )[ 'content' ];
$self_reviews_update_form -> addVTextArea ( 'self_review_update__problem_' . chr ( ord ( 'A' ) + $i ), '<b>' . chr ( ord ( 'A' ) + $i ) . '</b>: ' . $contest_problems [ $i ][ 'problem' ][ 'title' ], $content ,
function ( $content ) {
2022-10-10 09:30:01 +00:00
if ( strlen ( $content ) > 200 ) {
return '总结不能超过200字' ;
}
2022-09-19 23:49:45 +00:00
return '' ;
},
null ,
true
);
}
$content = DB :: selectFirst ( " select content from contests_reviews where contest_id = { $contest [ 'id' ] } and problem_id = -1 and poster = ' { $myUser [ 'username' ] } ' " )[ 'content' ];
$self_reviews_update_form -> addVTextArea ( 'self_review_update__overall' , '比赛总结' , $content ,
function ( $content ) {
2022-10-10 09:30:01 +00:00
if ( strlen ( $content ) > 200 ) {
return '总结不能超过200字' ;
}
2022-09-19 23:49:45 +00:00
return '' ;
},
null ,
true
);
$self_reviews_update_form -> handle = function () {
global $contest , $contest_problems , $myUser ;
for ( $i = 0 ; $i < count ( $contest_problems ); $i ++ ) {
if ( isset ( $_POST [ 'self_review_update__problem_' . chr ( ord ( 'A' ) + $i )])) {
$esc_content = DB :: escape ( $_POST [ 'self_review_update__problem_' . chr ( ord ( 'A' ) + $i )]);
$problem_id = $contest_problems [ $i ][ 'problem_id' ];
DB :: query ( " replace into contests_reviews (contest_id, problem_id, poster, content) values ( { $contest [ 'id' ] } , $problem_id , ' { $myUser [ 'username' ] } ', ' $esc_content ') " );
}
}
2022-09-20 00:28:38 +00:00
if ( isset ( $_POST [ 'self_review_update__overall' ])) {
2022-09-19 23:49:45 +00:00
$esc_content = DB :: escape ( $_POST [ 'self_review_update__overall' ]);
DB :: query ( " replace into contests_reviews (contest_id, problem_id, poster, content) values ( { $contest [ 'id' ] } , -1, ' { $myUser [ 'username' ] } ', ' $esc_content ') " );
}
};
$self_reviews_update_form -> runAtServer ();
}
2018-07-09 02:40:30 +00:00
}
2016-07-18 16:39:37 +00:00
function echoDashboard () {
2022-10-04 06:06:03 +00:00
global $contest , $post_notice , $post_question , $reply_question , $REQUIRE_LIB ;
2018-07-09 02:40:30 +00:00
$myname = Auth :: id ();
2022-09-28 06:48:30 +00:00
$contest_problems = DB :: selectAll ( " select contests_problems.problem_id, best_ac_submissions.submission_id from contests_problems left join best_ac_submissions on contests_problems.problem_id = best_ac_submissions.problem_id and submitter = ' { $myname } ' where contest_id = { $contest [ 'id' ] } order by contests_problems.dfn, contests_problems.problem_id " );
2016-07-18 16:39:37 +00:00
for ( $i = 0 ; $i < count ( $contest_problems ); $i ++ ) {
2018-07-09 02:40:30 +00:00
$contest_problems [ $i ][ 'problem' ] = queryProblemBrief ( $contest_problems [ $i ][ 'problem_id' ]);
2016-07-18 16:39:37 +00:00
}
2018-07-09 02:40:30 +00:00
$contest_notice = DB :: selectAll ( " select * from contests_notice where contest_id = { $contest [ 'id' ] } order by time desc " );
2016-07-18 16:39:37 +00:00
2018-07-09 02:40:30 +00:00
if ( Auth :: check ()) {
$my_questions = DB :: selectAll ( " select * from contests_asks where contest_id = { $contest [ 'id' ] } and username = ' { $myname } ' order by post_time desc " );
$my_questions_pag = new Paginator ([
'data' => $my_questions
]);
} else {
$my_questions_pag = null ;
2016-07-18 16:39:37 +00:00
}
2018-07-09 02:40:30 +00:00
$others_questions_pag = new Paginator ([
'col_names' => array ( '*' ),
'table_name' => 'contests_asks' ,
'cond' => " contest_id = { $contest [ 'id' ] } and username != ' { $myname } ' and is_hidden = 0 " ,
'tail' => 'order by reply_time desc' ,
'page_len' => 10
]);
uojIncludeView ( 'contest-dashboard' , [
'contest' => $contest ,
'contest_notice' => $contest_notice ,
'contest_problems' => $contest_problems ,
'post_question' => $post_question ,
'my_questions_pag' => $my_questions_pag ,
2022-10-04 06:06:03 +00:00
'others_questions_pag' => $others_questions_pag ,
'REQUIRE_LIB' => $REQUIRE_LIB ,
2018-07-09 02:40:30 +00:00
]);
}
function echoBackstage () {
global $contest , $post_notice , $reply_question ;
$questions_pag = new Paginator ([
'col_names' => array ( '*' ),
'table_name' => 'contests_asks' ,
'cond' => " contest_id = { $contest [ 'id' ] } " ,
'tail' => 'order by post_time desc' ,
'page_len' => 50
]);
if ( $contest [ 'cur_progress' ] < CONTEST_TESTING ) {
$contest_data = queryContestData ( $contest , [ 'pre_final' => true ]);
calcStandings ( $contest , $contest_data , $score , $standings );
$standings_data = [
'contest' => $contest ,
'standings' => $standings ,
'score' => $score ,
'contest_data' => $contest_data
];
} else {
$standings_data = null ;
}
uojIncludeView ( 'contest-backstage' , [
'contest' => $contest ,
'post_notice' => $post_notice ,
'reply_question' => $reply_question ,
'questions_pag' => $questions_pag ,
'standings_data' => $standings_data
]);
2016-07-18 16:39:37 +00:00
}
function echoMySubmissions () {
global $contest , $myUser ;
$show_all_submissions_status = Cookie :: get ( 'show_all_submissions' ) !== null ? 'checked="checked" ' : '' ;
$show_all_submissions = UOJLocale :: get ( 'contests::show all submissions' );
echo <<< EOD
2022-10-04 06:06:03 +00:00
< div class = " text-end " >
< div class = " form-check d-inline-block " >
< input type = " checkbox " class = " form-check-input " id = " input-show_all_submissions " $show_all_submissions_status />
< label class = " form-check-label " for = " input-show_all_submissions " >
$show_all_submissions
</ label >
</ div >
2016-07-18 16:39:37 +00:00
</ div >
< script type = " text/javascript " >
$ ( '#input-show_all_submissions' ) . click ( function () {
if ( this . checked ) {
$ . cookie ( 'show_all_submissions' , '' );
} else {
$ . removeCookie ( 'show_all_submissions' );
}
location . reload ();
});
</ script >
EOD ;
2022-10-04 06:06:03 +00:00
$config = array (
'judge_time_hidden' => '' ,
'table_config' => array (
2022-10-08 07:42:30 +00:00
'div_classes' => array ( 'card' , 'mb-3' , 'table-responsive' ),
2022-10-04 06:06:03 +00:00
'table_classes' => array ( 'table' , 'mb-0' , 'uoj-table' , 'text-center' )
),
);
2016-07-18 16:39:37 +00:00
if ( Cookie :: get ( 'show_all_submissions' ) !== null ) {
2022-10-04 06:06:03 +00:00
echoSubmissionsList ( " contest_id = { $contest [ 'id' ] } " , 'order by id desc' , $config , $myUser );
2016-07-18 16:39:37 +00:00
} else {
2022-10-04 06:06:03 +00:00
echoSubmissionsList ( " submitter = ' { $myUser [ 'username' ] } ' and contest_id = { $contest [ 'id' ] } " , 'order by id desc' , $config , $myUser );
2016-07-18 16:39:37 +00:00
}
}
2022-04-13 08:23:24 +00:00
function echoStandings ( $is_after_contest_query = false ) {
2016-07-18 16:39:37 +00:00
global $contest ;
2022-04-13 08:23:24 +00:00
$contest_data = queryContestData ( $contest , array (), $is_after_contest_query );
2018-07-09 02:40:30 +00:00
calcStandings ( $contest , $contest_data , $score , $standings );
uojIncludeView ( 'contest-standings' , [
'contest' => $contest ,
'standings' => $standings ,
'score' => $score ,
'contest_data' => $contest_data
]);
2016-07-18 16:39:37 +00:00
}
2022-09-19 11:27:57 +00:00
function echoReviews () {
global $contest ;
$contest_data = queryContestData ( $contest , array ());
calcStandings ( $contest , $contest_data , $score , $standings , false , true );
uojIncludeView ( 'contest-standings' , [
'contest' => $contest ,
'standings' => $standings ,
'score' => $score ,
'contest_data' => $contest_data ,
'show_self_reviews' => true
]);
}
2016-07-18 16:39:37 +00:00
$page_header = HTML :: stripTags ( $contest [ 'name' ]) . ' - ' ;
2022-09-18 04:58:35 +00:00
?>
2016-07-18 16:39:37 +00:00
< ? php echoUOJPageHeader ( HTML :: stripTags ( $contest [ 'name' ]) . ' - ' . $tabs_info [ $cur_tab ][ 'name' ] . ' - ' . UOJLocale :: get ( 'contests::contest' )) ?>
2022-10-04 06:06:03 +00:00
2022-10-07 10:16:17 +00:00
< div class = " text-center d-md-none mb-3 " >
2022-10-04 06:06:03 +00:00
< h1 class = " h2 " >< ? = $contest [ 'name' ] ?> </h1>
2022-10-07 10:16:17 +00:00
< div class = " small text-muted " >
< ? php if ( $contest [ 'cur_progress' ] <= CONTEST_NOT_STARTED ) : ?>
< ? = UOJLocale :: get ( 'contests::not started' ) ?>
< ? php elseif ( $contest [ 'cur_progress' ] <= CONTEST_IN_PROGRESS ) : ?>
< ? = UOJLocale :: get ( 'contests::in progress' ) ?>
< ? php elseif ( $contest [ 'cur_progress' ] <= CONTEST_PENDING_FINAL_TEST ) : ?>
< ? = UOJLocale :: get ( 'contests::pending final test' ) ?>
< ? php elseif ( $contest [ 'cur_progress' ] <= CONTEST_TESTING ) : ?>
< ? = UOJLocale :: get ( 'contests::final testing' ) ?>
< ? php else : ?>
2022-10-07 10:32:25 +00:00
< ? = UOJLocale :: get ( 'contests::ended' ) ?>
2022-10-07 10:16:17 +00:00
< ? php endif ?>
</ div >
2016-07-18 16:39:37 +00:00
</ div >
2022-10-04 06:06:03 +00:00
2016-07-18 16:39:37 +00:00
< div class = " row " >
2022-09-19 11:27:57 +00:00
< ? php if ( $cur_tab == 'standings' || $cur_tab == 'after_contest_standings' || $cur_tab == 'self_reviews' ) : ?>
2022-10-04 06:06:03 +00:00
< div class = " col-12 " >
2016-07-18 16:39:37 +00:00
< ? php else : ?>
2022-10-04 06:06:03 +00:00
< div class = " col-md-9 " >
2016-07-18 16:39:37 +00:00
< ? php endif ?>
2022-10-04 06:06:03 +00:00
< ? = HTML :: tablist ( $tabs_info , $cur_tab , 'nav-pills' ) ?>
< ? php if ( $cur_tab == 'standings' || $cur_tab == 'after_contest_standings' || $cur_tab == 'self_reviews' ) : ?>
2022-10-07 10:16:17 +00:00
< div class = " d-none d-md-block text-center " >
< h1 class = " h2 mt-2 mb-3 " >< ? = $contest [ 'name' ] ?> </h1>
< div class = " small text-muted " >
< ? php if ( $contest [ 'cur_progress' ] <= CONTEST_NOT_STARTED ) : ?>
< ? = UOJLocale :: get ( 'contests::not started' ) ?>
< ? php elseif ( $contest [ 'cur_progress' ] <= CONTEST_IN_PROGRESS ) : ?>
< ? = UOJLocale :: get ( 'contests::in progress' ) ?>
< ? php elseif ( $contest [ 'cur_progress' ] <= CONTEST_PENDING_FINAL_TEST ) : ?>
< ? = UOJLocale :: get ( 'contests::pending final test' ) ?>
< ? php elseif ( $contest [ 'cur_progress' ] <= CONTEST_TESTING ) : ?>
< ? = UOJLocale :: get ( 'contests::final testing' ) ?>
< ? php else : ?>
2022-10-08 05:45:02 +00:00
< ? = UOJLocale :: get ( 'contests::ended' ) ?>
2022-10-07 10:16:17 +00:00
< ? php endif ?>
</ div >
</ div >
2022-10-04 06:06:03 +00:00
< ? php endif ?>
< div class = " mt-3 " >
2016-07-18 16:39:37 +00:00
< ? php
2022-09-18 04:58:35 +00:00
if ( $cur_tab == 'dashboard' ) {
echoDashboard ();
} elseif ( $cur_tab == 'submissions' ) {
echoMySubmissions ();
} elseif ( $cur_tab == 'standings' ) {
echoStandings ();
} elseif ( $cur_tab == 'after_contest_standings' ) {
echoStandings ( true );
} elseif ( $cur_tab == 'backstage' ) {
echoBackstage ();
2022-09-19 11:27:57 +00:00
} elseif ( $cur_tab == 'self_reviews' ) {
echoReviews ();
2022-09-18 04:58:35 +00:00
}
?>
2016-07-18 16:39:37 +00:00
</ div >
</ div >
2022-10-04 06:06:03 +00:00
< ? php if ( $cur_tab == 'standings' || $cur_tab == 'after_contest_standings' ) : ?>
< ? php elseif ( $cur_tab == 'self_reviews' ) : ?>
< ? php if ( isset ( $self_reviews_update_form )) : ?>
2016-07-18 16:39:37 +00:00
< hr />
2022-10-04 06:06:03 +00:00
< div class = " col-md-6 " >
< h4 > 修改我的赛后总结 </ h4 >
2022-10-12 11:19:54 +00:00
< div class = " small " > 赛后总结支持 Markdown 语法。 </ div >
2022-10-04 06:06:03 +00:00
< ? php $self_reviews_update_form -> printHTML (); ?>
</ div >
< ? php endif ?>
< ? php else : ?>
< div class = " d-md-none " >
< hr />
</ div >
< div class = " col-md-3 " >
< div class = " card card-default mb-2 " >
< div class = " card-body " >
< h3 class = " h5 card-title text-center " >
< a class = " text-decoration-none text-body " href = " /contest/<?= $contest['id'] ?> " >
< ? = $contest [ 'name' ] ?>
</ a >
</ h3 >
< div class = " card-text text-center text-muted " >
< ? php if ( $contest [ 'cur_progress' ] <= CONTEST_IN_PROGRESS ) : ?>
< span id = " contest-countdown " ></ span >
< script type = " text/javascript " >
$ ( '#contest-countdown' ) . countdown ( < ? = $contest [ 'end_time' ] -> getTimestamp () - UOJTime :: $time_now -> getTimestamp () ?> , function(){}, '1.75rem', false);
checkContestNotice ( < ? = $contest [ 'id' ] ?> , '<?= UOJTime::$time_now_str ?>');
</ script >
< ? php elseif ( $contest [ 'cur_progress' ] <= CONTEST_TESTING ) : ?>
< ? php if ( $contest [ 'cur_progress' ] < CONTEST_TESTING ) : ?>
< ? = UOJLocale :: get ( 'contests::contest pending final test' ) ?>
< ? php else : ?>
< ? php
$total = DB :: selectCount ( " select count(*) from submissions where contest_id = { $contest [ 'id' ] } " );
$n_judged = DB :: selectCount ( " select count(*) from submissions where contest_id = { $contest [ 'id' ] } and status = 'Judged' " );
$rop = $total == 0 ? 100 : ( int )( $n_judged / $total * 100 );
?>
< ? = UOJLocale :: get ( 'contests::contest final testing' ) ?>
( < ? = $rop ?> %)
< ? php endif ?>
< ? php else : ?>
< ? = UOJLocale :: get ( 'contests::contest ended' ) ?>
< ? php endif ?>
</ div >
2022-09-19 23:49:45 +00:00
</ div >
2022-10-04 06:06:03 +00:00
< div class = " card-footer bg-transparent " >
比赛评价: < ? = getClickZanBlock ( 'C' , $contest [ 'id' ], $contest [ 'zan' ]) ?>
</ div >
</ div >
< ? php if ( ! isset ( $contest [ 'extra_config' ][ 'contest_type' ]) || $contest [ 'extra_config' ][ 'contest_type' ] == 'OI' ) : ?>
< p > 此次比赛为 OI 赛制。 </ p >
2022-09-19 23:49:45 +00:00
< p >< strong > 注意:比赛时只显示测样例的结果。 </ strong ></ p >
< ? php elseif ( $contest [ 'extra_config' ][ 'contest_type' ] == 'IOI' ) : ?>
2022-10-04 06:06:03 +00:00
< p > 此次比赛为 IOI 赛制。 </ p >
2022-09-19 23:49:45 +00:00
< p >< strong > 注意:比赛时显示测试所有数据的结果,但无法看到详细信息。 </ strong ></ p >
2022-10-04 06:06:03 +00:00
< ? php endif ?>
2016-07-18 16:39:37 +00:00
2022-10-07 05:09:56 +00:00
< a href = " /contest/<?= $contest['id'] ?>/registrants " class = " btn btn-secondary d-block mt-2 " >
2022-10-04 06:06:03 +00:00
< ? = UOJLocale :: get ( 'contests::contest registrants' ) ?>
</ a >
2016-07-18 16:39:37 +00:00
< ? php if ( isSuperUser ( $myUser )) : ?>
2022-10-04 06:06:03 +00:00
< a href = " /contest/<?= $contest['id'] ?>/manage " class = " btn btn-primary d-block mt-2 " >
管理
</ a >
2022-09-23 00:13:21 +00:00
< ? php endif ?>
2016-07-18 16:39:37 +00:00
< ? php if ( isset ( $start_test_form )) : ?>
2022-10-04 06:06:03 +00:00
< div class = " mt-2 " >
2016-07-18 16:39:37 +00:00
< ? php $start_test_form -> printHTML (); ?>
</ div >
< ? php endif ?>
< ? php if ( isset ( $publish_result_form )) : ?>
2022-10-04 06:06:03 +00:00
< div class = " mt-2 " >
2016-07-18 16:39:37 +00:00
< ? php $publish_result_form -> printHTML (); ?>
</ div >
< ? php endif ?>
2022-10-04 06:06:03 +00:00
< ? php if ( $contest [ 'extra_config' ][ 'links' ]) : ?>
2022-10-06 12:22:31 +00:00
< div class = " card card-default border-info mt-3 " >
2022-09-19 23:49:45 +00:00
< div class = " card-header bg-info " >
2022-10-06 12:22:31 +00:00
< h3 class = " h4 card-title " > 比赛资料 </ h3 >
2022-09-19 23:49:45 +00:00
</ div >
2022-10-06 12:22:31 +00:00
< div class = " list-group list-group-flush " >
2022-10-04 06:06:03 +00:00
< ? php foreach ( $contest [ 'extra_config' ][ 'links' ] as $link ) : ?>
2022-09-19 23:49:45 +00:00
< a href = " /blogs/<?= $link[1] ?> " class = " list-group-item " >< ? = $link [ 0 ] ?> </a>
2022-10-04 06:06:03 +00:00
< ? php endforeach ?>
2022-09-19 23:49:45 +00:00
</ div >
2016-07-18 16:39:37 +00:00
</ div >
2022-10-04 06:06:03 +00:00
< ? php endif ?>
2022-10-06 12:22:31 +00:00
</ div >
2022-10-04 06:06:03 +00:00
< ? php endif ?>
2016-07-18 16:39:37 +00:00
</ div >
2022-10-04 06:06:03 +00:00
2022-03-17 03:02:44 +00:00
< ? php echoUOJPageFooter () ?>