fix: 3ffa996631
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-02-08 11:32:59 +08:00
parent 3ffa996631
commit a894939f75
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
5 changed files with 29 additions and 19 deletions

View File

@ -453,7 +453,13 @@ function echoMySubmissions() {
function echoStandings($is_after_contest_query = false) { function echoStandings($is_after_contest_query = false) {
global $contest; 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() { function echoSelfReviews() {

View File

@ -78,7 +78,7 @@ function queryContestData($contest, $config = []) {
$prob_pos[$problems[] = (int)$row[0]] = $n_problems++; $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); $data = queryOIorIOIContestSubmissionData($contest, $problems, $prob_pos, $config);
} elseif ($contest['extra_config']['basic_rule'] == 'ACM') { } elseif ($contest['extra_config']['basic_rule'] == 'ACM') {
$data = queryACMContestSubmissionData($contest, $problems, $prob_pos, $config); $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]); $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') { } else if ($contest['extra_config']['basic_rule'] === 'ACM') {
// sub: id, submit_time, submitter, problem_pos, score // sub: id, submit_time, submitter, problem_pos, score
// id, submit_time (plus penalty), submitter, problem_pos, score, cnt, n_failures // 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 // standings: rank => score, penalty, [username, realname, null|array, null|color], virtual_rank, ?review

View File

@ -339,10 +339,11 @@ class UOJContest {
public function queryResult($cfg = []) { public function queryResult($cfg = []) {
$contest_data = queryContestData($this->info, $cfg); $contest_data = queryContestData($this->info, $cfg);
calcStandings($this->info, $contest_data, $score, $standings, $cfg); calcStandings($this->info, $contest_data, $score, $standings, $cfg);
return [ return [
'standings' => $standings, 'standings' => $standings,
'score' => $score, 'score' => $score,
'contest_data' => $contest_data 'contest_data' => $contest_data,
]; ];
} }

View File

@ -16,6 +16,7 @@
var problems = <?= json_encode($contest_data['problems']) ?>; var problems = <?= json_encode($contest_data['problems']) ?>;
var standings_config = <?= json_encode(isset($standings_config) ? $standings_config : ['_config' => true]) ?>; var standings_config = <?= json_encode(isset($standings_config) ? $standings_config : ['_config' => true]) ?>;
var myname = <?= json_encode(Auth::id()) ?>; var myname = <?= json_encode(Auth::id()) ?>;
var after_contest = <?= json_encode(isset($after_contest) && $after_contest) ?>;
var first_accepted = {}; var first_accepted = {};
$(document).ready(showStandings()); $(document).ready(showStandings());

View File

@ -1876,7 +1876,7 @@ function setACMStandingsTD(td, row, i, meta) {
// standings // standings
function showStandings() { function showStandings() {
if (contest_rule == 'OI' || contest_rule == 'IOI') { if (contest_rule == 'OI' || contest_rule == 'IOI' || after_contest) {
$("#standings").long_table( $("#standings").long_table(
standings, standings,
1, 1,
@ -1897,12 +1897,13 @@ function showStandings() {
} }
col_tr += '<td>' + row[3] + '</td>'; col_tr += '<td>' + row[3] + '</td>';
col_tr += '<td>' + getUserLink(row[2][0], row[2][1], row[2][3]) + '</td>'; col_tr += '<td>' + getUserLink(row[2][0], row[2][1], row[2][3]) + '</td>';
col_tr += '<td>' + '<div><span class="uoj-score" data-max="' + problems.length * 100 + '" style="color:' + getColOfScore(row[0] / problems.length) + '">' + row[0] + '</span></div>' + '<div class="small">' + getPenaltyTimeStr(row[1]) + '</div></td>'; col_tr += '<td>' + '<div><span class="uoj-score" data-max="' + problems.length * 100 + '" style="color:' + getColOfScore(row[0] / problems.length) + '">' + row[0] + '</span></div>' + (after_contest ? '' : '<div class="small">' + getPenaltyTimeStr(row[1]) + '</div>') + '</td>';
for (var i = 0; i < problems.length; i++) { for (var i = 0; i < problems.length; i++) {
col_tr += '<td>'; col_tr += '<td>';
col = score[row[2][0]][i]; col = score[row[2][0]][i];
if (col != undefined) { if (col != undefined) {
col_tr += '<div><a href="/submission/' + col[2] + '" class="uoj-score" style="color:' + getColOfScore(col[0]) + '">' + col[0] + '</a></div>'; col_tr += '<div><a href="/submission/' + col[2] + '" class="uoj-score" style="color:' + getColOfScore(col[0]) + '">' + col[0] + '</a></div>';
if (!after_contest) {
if (standings_version < 2) { if (standings_version < 2) {
col_tr += '<div class="small">' + getPenaltyTimeStr(col[1]) + '</div>'; col_tr += '<div class="small">' + getPenaltyTimeStr(col[1]) + '</div>';
} else { } else {
@ -1911,6 +1912,7 @@ function showStandings() {
} }
} }
} }
}
col_tr += '</td>'; col_tr += '</td>';
} }
col_tr += '</tr>'; col_tr += '</tr>';