From a894939f75d451a76b5969d3123bc856a8fe51a1 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 8 Feb 2023 11:32:59 +0800 Subject: [PATCH] fix: 3ffa99663189a6ac54ef949ceed8984554ebf5a5 --- web/app/controllers/contest_inside.php | 8 +++++++- web/app/libs/uoj-contest-lib.php | 22 +++++++++++----------- web/app/models/UOJContest.php | 3 ++- web/app/views/contest-standings.php | 1 + web/js/uoj.js | 14 ++++++++------ 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/web/app/controllers/contest_inside.php b/web/app/controllers/contest_inside.php index c023195..e65f3b6 100644 --- a/web/app/controllers/contest_inside.php +++ b/web/app/controllers/contest_inside.php @@ -453,7 +453,13 @@ function echoMySubmissions() { function echoStandings($is_after_contest_query = false) { global $contest; - uojIncludeView('contest-standings', ['contest' => $contest] + UOJContest::cur()->queryResult(['after_contest' => $is_after_contest_query])); + + uojIncludeView('contest-standings', [ + 'contest' => $contest, + 'after_contest' => $is_after_contest_query, + ] + UOJContest::cur()->queryResult([ + 'after_contest' => $is_after_contest_query, + ])); } function echoSelfReviews() { diff --git a/web/app/libs/uoj-contest-lib.php b/web/app/libs/uoj-contest-lib.php index 1422394..d8f129a 100644 --- a/web/app/libs/uoj-contest-lib.php +++ b/web/app/libs/uoj-contest-lib.php @@ -78,7 +78,7 @@ function queryContestData($contest, $config = []) { $prob_pos[$problems[] = (int)$row[0]] = $n_problems++; } - if ($contest['extra_config']['basic_rule'] == 'OI' || $contest['extra_config']['basic_rule'] == 'IOI') { + if ($contest['extra_config']['basic_rule'] == 'OI' || $contest['extra_config']['basic_rule'] == 'IOI' || $config['after_contest']) { $data = queryOIorIOIContestSubmissionData($contest, $problems, $prob_pos, $config); } elseif ($contest['extra_config']['basic_rule'] == 'ACM') { $data = queryACMContestSubmissionData($contest, $problems, $prob_pos, $config); @@ -290,6 +290,16 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $cfg = []) } $score[$sub[2]][$sub[3]] = array($sub[4], $penalty, $sub[0]); } + } else if ($contest['extra_config']['basic_rule'] === 'IOI' || $cfg['after_contest']) { + foreach ($contest_data['data'] as $sub) { + $penalty = (new DateTime($sub[1]))->getTimestamp() - $contest['start_time']->getTimestamp(); + if ($sub[4] == 0) { + $penalty = 0; + } + if (!isset($score[$sub[2]][$sub[3]]) || $score[$sub[2]][$sub[3]][0] < $sub[4]) { + $score[$sub[2]][$sub[3]] = array($sub[4], $penalty, $sub[0]); + } + } } else if ($contest['extra_config']['basic_rule'] === 'ACM') { // sub: id, submit_time, submitter, problem_pos, score // id, submit_time (plus penalty), submitter, problem_pos, score, cnt, n_failures @@ -388,16 +398,6 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $cfg = []) } } } - } else if ($contest['extra_config']['basic_rule'] === 'IOI') { - foreach ($contest_data['data'] as $sub) { - $penalty = (new DateTime($sub[1]))->getTimestamp() - $contest['start_time']->getTimestamp(); - if ($sub[4] == 0) { - $penalty = 0; - } - if (!isset($score[$sub[2]][$sub[3]]) || $score[$sub[2]][$sub[3]][0] < $sub[4]) { - $score[$sub[2]][$sub[3]] = array($sub[4], $penalty, $sub[0]); - } - } } // standings: rank => score, penalty, [username, realname, null|array, null|color], virtual_rank, ?review diff --git a/web/app/models/UOJContest.php b/web/app/models/UOJContest.php index 41cb363..f50562d 100644 --- a/web/app/models/UOJContest.php +++ b/web/app/models/UOJContest.php @@ -339,10 +339,11 @@ class UOJContest { public function queryResult($cfg = []) { $contest_data = queryContestData($this->info, $cfg); calcStandings($this->info, $contest_data, $score, $standings, $cfg); + return [ 'standings' => $standings, 'score' => $score, - 'contest_data' => $contest_data + 'contest_data' => $contest_data, ]; } diff --git a/web/app/views/contest-standings.php b/web/app/views/contest-standings.php index 84d52c2..098c3f0 100644 --- a/web/app/views/contest-standings.php +++ b/web/app/views/contest-standings.php @@ -16,6 +16,7 @@ var problems = ; var standings_config = true]) ?>; var myname = ; + var after_contest = ; var first_accepted = {}; $(document).ready(showStandings()); diff --git a/web/js/uoj.js b/web/js/uoj.js index 8efaa1d..edb5ebf 100644 --- a/web/js/uoj.js +++ b/web/js/uoj.js @@ -1876,7 +1876,7 @@ function setACMStandingsTD(td, row, i, meta) { // standings function showStandings() { - if (contest_rule == 'OI' || contest_rule == 'IOI') { + if (contest_rule == 'OI' || contest_rule == 'IOI' || after_contest) { $("#standings").long_table( standings, 1, @@ -1897,17 +1897,19 @@ function showStandings() { } col_tr += '' + row[3] + ''; col_tr += '' + getUserLink(row[2][0], row[2][1], row[2][3]) + ''; - col_tr += '' + '
' + row[0] + '
' + '
' + getPenaltyTimeStr(row[1]) + '
'; + col_tr += '' + '
' + row[0] + '
' + (after_contest ? '' : '
' + getPenaltyTimeStr(row[1]) + '
') + ''; for (var i = 0; i < problems.length; i++) { col_tr += ''; col = score[row[2][0]][i]; if (col != undefined) { col_tr += '
' + col[0] + '
'; - if (standings_version < 2) { - col_tr += '
' + getPenaltyTimeStr(col[1]) + '
'; - } else { - if (col[0] > 0) { + if (!after_contest) { + if (standings_version < 2) { col_tr += '
' + getPenaltyTimeStr(col[1]) + '
'; + } else { + if (col[0] > 0) { + col_tr += '
' + getPenaltyTimeStr(col[1]) + '
'; + } } } }