Skip to content

Commit 523c2e5

Browse files
Implement new results rules
Fixes #2615
1 parent 8e829b3 commit 523c2e5

File tree

4 files changed

+112
-95
lines changed

4 files changed

+112
-95
lines changed

webapp/src/Controller/Jury/ImportExportController.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ protected function getResultsHtml(Request $request, bool $full = false): Respons
421421
}
422422
if ($row['rank'] === null) {
423423
$honorable[] = $row['team'];
424-
} elseif ($row['award'] === 'Ranked') {
425-
$ranked[] = $row;
424+
} elseif (in_array($row['award'], ['Highest Honors', 'High Honors', 'Honors'], true)) {
425+
$ranked[$row['award']][] = $row;
426426
} else {
427427
$awarded[] = $row;
428428
}
@@ -432,13 +432,16 @@ protected function getResultsHtml(Request $request, bool $full = false): Respons
432432

433433
$collator = new Collator('en_US');
434434
$collator->sort($honorable);
435-
usort($ranked, function (array $a, array $b) use ($collator): int {
436-
if ($a['rank'] !== $b['rank']) {
437-
return $a['rank'] <=> $b['rank'];
438-
}
435+
foreach ($ranked as $award => &$rankedTeams) {
436+
usort($rankedTeams, function (array $a, array $b) use ($collator): int {
437+
if ($a['rank'] !== $b['rank']) {
438+
return $a['rank'] <=> $b['rank'];
439+
}
439440

440-
return $collator->compare($a['team'], $b['team']);
441-
});
441+
return $collator->compare($a['team'], $b['team']);
442+
});
443+
}
444+
unset($rankedTeams);
442445

443446
$problems = $scoreboard->getProblems();
444447
$matrix = $scoreboard->getMatrix();

webapp/src/Service/ImportExportService.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@ public function getResultsData(int $sortOrder, bool $full = false): array
504504
}
505505
}
506506

507-
$ranks = [];
508-
$groupWinners = [];
509-
$data = [];
507+
$ranks = [];
508+
$groupWinners = [];
509+
$data = [];
510+
$lowestMedalPoints = 0;
510511

511512
foreach ($scoreboard->getScores() as $teamScore) {
512513
if ($teamScore->team->getCategory()->getSortorder() !== $sortOrder) {
@@ -522,10 +523,13 @@ public function getResultsData(int $sortOrder, bool $full = false): array
522523
$numPoints = $teamScore->numPoints;
523524
if ($rank <= $contest->getGoldMedals()) {
524525
$awardString = 'Gold Medal';
526+
$lowestMedalPoints = $teamScore->numPoints;
525527
} elseif ($rank <= $contest->getGoldMedals() + $contest->getSilverMedals()) {
526528
$awardString = 'Silver Medal';
529+
$lowestMedalPoints = $teamScore->numPoints;
527530
} elseif ($rank <= $contest->getGoldMedals() + $contest->getSilverMedals() + $contest->getBronzeMedals() + $contest->getB()) {
528531
$awardString = 'Bronze Medal';
532+
$lowestMedalPoints = $teamScore->numPoints;
529533
} elseif ($numPoints >= $median) {
530534
// Teams with equally solved number of problems get the same rank unless $full is true.
531535
if (!$full) {
@@ -534,7 +538,13 @@ public function getResultsData(int $sortOrder, bool $full = false): array
534538
}
535539
$rank = $ranks[$numPoints];
536540
}
537-
$awardString = 'Ranked';
541+
if ($numPoints === $lowestMedalPoints) {
542+
$awardString = 'Highest Honors';
543+
} elseif ($numPoints === $lowestMedalPoints - 1) {
544+
$awardString = 'High Honors';
545+
} else {
546+
$awardString = 'Honors';
547+
}
538548
} else {
539549
$awardString = 'Honorable';
540550
$rank = null;

webapp/templates/jury/export/results.html.twig

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,29 @@
2727
</tbody>
2828
</table>
2929

30-
<h2>Other ranked teams</h2>
31-
<table class="table">
32-
<thead>
33-
<tr>
34-
<th scope="col">Rank</th>
35-
<th scope="col">Team</th>
36-
<th scope="col">Solved problems</th>
37-
</tr>
38-
</thead>
39-
<tbody>
40-
{% for row in ranked %}
41-
<tr>
42-
<th scope="row">{{ row.rank }}</th>
43-
<th scope="row">{{ row.team }}</th>
44-
<td>{{ row.solved }}</td>
45-
</tr>
46-
{% endfor %}
47-
</tbody>
48-
</table>
30+
{% for award in ['Highest Honors', 'High Honors', 'Honors'] %}
31+
{% if ranked[award] is defined %}
32+
<h2>{{ award }}</h2>
33+
<table class="table">
34+
<thead>
35+
<tr>
36+
<th scope="col">Rank</th>
37+
<th scope="col">Team</th>
38+
<th scope="col">Solved problems</th>
39+
</tr>
40+
</thead>
41+
<tbody>
42+
{% for row in ranked[award] %}
43+
<tr>
44+
<th scope="row">{{ row.rank }}</th>
45+
<th scope="row">{{ row.team }}</th>
46+
<td>{{ row.solved }}</td>
47+
</tr>
48+
{% endfor %}
49+
</tbody>
50+
</table>
51+
{% endif %}
52+
{% endfor %}
4953

5054
<h2>Honorable mentions</h2>
5155
<table class="table">

webapp/tests/Unit/Service/ImportExportServiceTest.php

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,70 +1327,70 @@ public function testGetResultsData(bool $full): void
13271327
new ResultRow('870584', 10, 'Bronze Medal', 8, 1424, 291),
13281328
new ResultRow('870051', 11, 'Bronze Medal', 7, 842, 279),
13291329
new ResultRow('870647', 12, 'Bronze Medal', 7, 940, 259),
1330-
new ResultRow('870670', 13, 'Ranked', 7, 955, 291, 'Latin America'),
1331-
new ResultRow('870585', $full ? 14 : 13, 'Ranked', 7, 962, 290),
1332-
new ResultRow('870649', $full ? 14 : 13, 'Ranked', 7, 962, 290),
1333-
new ResultRow('870271', $full ? 16 : 13, 'Ranked', 7, 980, 283),
1334-
new ResultRow('870642', $full ? 17 : 13, 'Ranked', 7, 1021, 256),
1335-
new ResultRow('870045', $full ? 18 : 13, 'Ranked', 7, 1076, 271),
1336-
new ResultRow('870582', $full ? 19 : 13, 'Ranked', 7, 1128, 278),
1337-
new ResultRow('870654', $full ? 20 : 13, 'Ranked', 7, 1130, 284),
1338-
new ResultRow('868994', $full ? 21 : 13, 'Ranked', 7, 1381, 296),
1339-
new ResultRow('870644', 22, 'Ranked', 6, 510, 187),
1340-
new ResultRow('870646', $full ? 23 : 22, 'Ranked', 6, 642, 216),
1341-
new ResultRow('870680', $full ? 24 : 22, 'Ranked', 6, 645, 218),
1342-
new ResultRow('881825', $full ? 25 : 22, 'Ranked', 6, 680, 237),
1343-
new ResultRow('871349', $full ? 26 : 22, 'Ranked', 6, 683, 246),
1344-
new ResultRow('870692', $full ? 27 : 22, 'Ranked', 6, 708, 243),
1345-
new ResultRow('870041', $full ? 28 : 22, 'Ranked', 6, 718, 260),
1346-
new ResultRow('870268', $full ? 29 : 22, 'Ranked', 6, 765, 292),
1347-
new ResultRow('870681', $full ? 30 : 22, 'Ranked', 6, 932, 287),
1348-
new ResultRow('870040', $full ? 31 : 22, 'Ranked', 6, 968, 238),
1349-
new ResultRow('870044', $full ? 32 : 22, 'Ranked', 6, 1010, 275),
1350-
new ResultRow('870658', $full ? 33 : 22, 'Ranked', 6, 1046, 293),
1351-
new ResultRow('870038', $full ? 34 : 22, 'Ranked', 6, 1103, 282),
1352-
new ResultRow('870696', $full ? 35 : 22, 'Ranked', 6, 1189, 290),
1353-
new ResultRow('870650', 36, 'Ranked', 5, 398, 137),
1354-
new ResultRow('870672', $full ? 37 : 36, 'Ranked', 5, 489, 158),
1355-
new ResultRow('870656', $full ? 38 : 36, 'Ranked', 5, 496, 116),
1356-
new ResultRow('870043', $full ? 39 : 36, 'Ranked', 5, 522, 160),
1357-
new ResultRow('870648', $full ? 40 : 36, 'Ranked', 5, 573, 168),
1358-
new ResultRow('870652', $full ? 41 : 36, 'Ranked', 5, 578, 143),
1359-
new ResultRow('870627', $full ? 42 : 36, 'Ranked', 5, 579, 180, 'Asia West'),
1360-
new ResultRow('870639', $full ? 43 : 36, 'Ranked', 5, 582, 213),
1361-
new ResultRow('870273', $full ? 44 : 36, 'Ranked', 5, 592, 199),
1362-
new ResultRow('870653', $full ? 45 : 36, 'Ranked', 5, 630, 292),
1363-
new ResultRow('870659', $full ? 46 : 36, 'Ranked', 5, 644, 154),
1364-
new ResultRow('870683', $full ? 47 : 36, 'Ranked', 5, 653, 207),
1365-
new ResultRow('870874', $full ? 48 : 36, 'Ranked', 5, 660, 221),
1366-
new ResultRow('870052', $full ? 49 : 36, 'Ranked', 5, 662, 181),
1367-
new ResultRow('870270', $full ? 50 : 36, 'Ranked', 5, 683, 239),
1368-
new ResultRow('870046', $full ? 51 : 36, 'Ranked', 5, 737, 227),
1369-
new ResultRow('870050', $full ? 52 : 36, 'Ranked', 5, 739, 260),
1370-
new ResultRow('870637', $full ? 53 : 36, 'Ranked', 5, 742, 255),
1371-
new ResultRow('870048', $full ? 54 : 36, 'Ranked', 5, 743, 271),
1372-
new ResultRow('870630', $full ? 55 : 36, 'Ranked', 5, 747, 247),
1373-
new ResultRow('870272', $full ? 56 : 36, 'Ranked', 5, 747, 284),
1374-
new ResultRow('870667', $full ? 57 : 36, 'Ranked', 5, 770, 216),
1375-
new ResultRow('870686', $full ? 58 : 36, 'Ranked', 5, 795, 219),
1376-
new ResultRow('870578', $full ? 59 : 36, 'Ranked', 5, 807, 257),
1377-
new ResultRow('870579', $full ? 60 : 36, 'Ranked', 5, 822, 205),
1378-
new ResultRow('870267', $full ? 61 : 36, 'Ranked', 5, 833, 257),
1379-
new ResultRow('870674', $full ? 62 : 36, 'Ranked', 5, 837, 226),
1380-
new ResultRow('870691', $full ? 63 : 36, 'Ranked', 5, 839, 243),
1381-
new ResultRow('870264', $full ? 64 : 36, 'Ranked', 5, 850, 209),
1382-
new ResultRow('870635', $full ? 65 : 36, 'Ranked', 5, 862, 275),
1383-
new ResultRow('870590', $full ? 66 : 36, 'Ranked', 5, 867, 245),
1384-
new ResultRow('870269', $full ? 67 : 36, 'Ranked', 5, 878, 267),
1385-
new ResultRow('870668', $full ? 68 : 36, 'Ranked', 5, 889, 257),
1386-
new ResultRow('870263', $full ? 69 : 36, 'Ranked', 5, 891, 220),
1387-
new ResultRow('870065', $full ? 70 : 36, 'Ranked', 5, 908, 238, 'Africa and Arab'),
1388-
new ResultRow('870053', $full ? 71 : 36, 'Ranked', 5, 968, 260),
1389-
new ResultRow('870042', $full ? 72 : 36, 'Ranked', 5, 971, 292),
1390-
new ResultRow('870689', $full ? 73 : 36, 'Ranked', 5, 1008, 298),
1391-
new ResultRow('870685', $full ? 74 : 36, 'Ranked', 5, 1048, 267),
1392-
new ResultRow('870638', $full ? 75 : 36, 'Ranked', 5, 1164, 294),
1393-
new ResultRow('871379', $full ? 76 : 36, 'Ranked', 5, 1227, 273),
1330+
new ResultRow('870670', 13, 'Highest Honors', 7, 955, 291, 'Latin America'),
1331+
new ResultRow('870585', $full ? 14 : 13, 'Highest Honors', 7, 962, 290),
1332+
new ResultRow('870649', $full ? 14 : 13, 'Highest Honors', 7, 962, 290),
1333+
new ResultRow('870271', $full ? 16 : 13, 'Highest Honors', 7, 980, 283),
1334+
new ResultRow('870642', $full ? 17 : 13, 'Highest Honors', 7, 1021, 256),
1335+
new ResultRow('870045', $full ? 18 : 13, 'Highest Honors', 7, 1076, 271),
1336+
new ResultRow('870582', $full ? 19 : 13, 'Highest Honors', 7, 1128, 278),
1337+
new ResultRow('870654', $full ? 20 : 13, 'Highest Honors', 7, 1130, 284),
1338+
new ResultRow('868994', $full ? 21 : 13, 'Highest Honors', 7, 1381, 296),
1339+
new ResultRow('870644', 22, 'High Honors', 6, 510, 187),
1340+
new ResultRow('870646', $full ? 23 : 22, 'High Honors', 6, 642, 216),
1341+
new ResultRow('870680', $full ? 24 : 22, 'High Honors', 6, 645, 218),
1342+
new ResultRow('881825', $full ? 25 : 22, 'High Honors', 6, 680, 237),
1343+
new ResultRow('871349', $full ? 26 : 22, 'High Honors', 6, 683, 246),
1344+
new ResultRow('870692', $full ? 27 : 22, 'High Honors', 6, 708, 243),
1345+
new ResultRow('870041', $full ? 28 : 22, 'High Honors', 6, 718, 260),
1346+
new ResultRow('870268', $full ? 29 : 22, 'High Honors', 6, 765, 292),
1347+
new ResultRow('870681', $full ? 30 : 22, 'High Honors', 6, 932, 287),
1348+
new ResultRow('870040', $full ? 31 : 22, 'High Honors', 6, 968, 238),
1349+
new ResultRow('870044', $full ? 32 : 22, 'High Honors', 6, 1010, 275),
1350+
new ResultRow('870658', $full ? 33 : 22, 'High Honors', 6, 1046, 293),
1351+
new ResultRow('870038', $full ? 34 : 22, 'High Honors', 6, 1103, 282),
1352+
new ResultRow('870696', $full ? 35 : 22, 'High Honors', 6, 1189, 290),
1353+
new ResultRow('870650', 36, 'Honors', 5, 398, 137),
1354+
new ResultRow('870672', $full ? 37 : 36, 'Honors', 5, 489, 158),
1355+
new ResultRow('870656', $full ? 38 : 36, 'Honors', 5, 496, 116),
1356+
new ResultRow('870043', $full ? 39 : 36, 'Honors', 5, 522, 160),
1357+
new ResultRow('870648', $full ? 40 : 36, 'Honors', 5, 573, 168),
1358+
new ResultRow('870652', $full ? 41 : 36, 'Honors', 5, 578, 143),
1359+
new ResultRow('870627', $full ? 42 : 36, 'Honors', 5, 579, 180, 'Asia West'),
1360+
new ResultRow('870639', $full ? 43 : 36, 'Honors', 5, 582, 213),
1361+
new ResultRow('870273', $full ? 44 : 36, 'Honors', 5, 592, 199),
1362+
new ResultRow('870653', $full ? 45 : 36, 'Honors', 5, 630, 292),
1363+
new ResultRow('870659', $full ? 46 : 36, 'Honors', 5, 644, 154),
1364+
new ResultRow('870683', $full ? 47 : 36, 'Honors', 5, 653, 207),
1365+
new ResultRow('870874', $full ? 48 : 36, 'Honors', 5, 660, 221),
1366+
new ResultRow('870052', $full ? 49 : 36, 'Honors', 5, 662, 181),
1367+
new ResultRow('870270', $full ? 50 : 36, 'Honors', 5, 683, 239),
1368+
new ResultRow('870046', $full ? 51 : 36, 'Honors', 5, 737, 227),
1369+
new ResultRow('870050', $full ? 52 : 36, 'Honors', 5, 739, 260),
1370+
new ResultRow('870637', $full ? 53 : 36, 'Honors', 5, 742, 255),
1371+
new ResultRow('870048', $full ? 54 : 36, 'Honors', 5, 743, 271),
1372+
new ResultRow('870630', $full ? 55 : 36, 'Honors', 5, 747, 247),
1373+
new ResultRow('870272', $full ? 56 : 36, 'Honors', 5, 747, 284),
1374+
new ResultRow('870667', $full ? 57 : 36, 'Honors', 5, 770, 216),
1375+
new ResultRow('870686', $full ? 58 : 36, 'Honors', 5, 795, 219),
1376+
new ResultRow('870578', $full ? 59 : 36, 'Honors', 5, 807, 257),
1377+
new ResultRow('870579', $full ? 60 : 36, 'Honors', 5, 822, 205),
1378+
new ResultRow('870267', $full ? 61 : 36, 'Honors', 5, 833, 257),
1379+
new ResultRow('870674', $full ? 62 : 36, 'Honors', 5, 837, 226),
1380+
new ResultRow('870691', $full ? 63 : 36, 'Honors', 5, 839, 243),
1381+
new ResultRow('870264', $full ? 64 : 36, 'Honors', 5, 850, 209),
1382+
new ResultRow('870635', $full ? 65 : 36, 'Honors', 5, 862, 275),
1383+
new ResultRow('870590', $full ? 66 : 36, 'Honors', 5, 867, 245),
1384+
new ResultRow('870269', $full ? 67 : 36, 'Honors', 5, 878, 267),
1385+
new ResultRow('870668', $full ? 68 : 36, 'Honors', 5, 889, 257),
1386+
new ResultRow('870263', $full ? 69 : 36, 'Honors', 5, 891, 220),
1387+
new ResultRow('870065', $full ? 70 : 36, 'Honors', 5, 908, 238, 'Africa and Arab'),
1388+
new ResultRow('870053', $full ? 71 : 36, 'Honors', 5, 968, 260),
1389+
new ResultRow('870042', $full ? 72 : 36, 'Honors', 5, 971, 292),
1390+
new ResultRow('870689', $full ? 73 : 36, 'Honors', 5, 1008, 298),
1391+
new ResultRow('870685', $full ? 74 : 36, 'Honors', 5, 1048, 267),
1392+
new ResultRow('870638', $full ? 75 : 36, 'Honors', 5, 1164, 294),
1393+
new ResultRow('871379', $full ? 76 : 36, 'Honors', 5, 1227, 273),
13941394
new ResultRow('870056', null, 'Honorable', 2, 465, 299),
13951395
new ResultRow('870055', null, 'Honorable', 4, 465, 164),
13961396
new ResultRow('870063', null, 'Honorable', 1, 348, 288),

0 commit comments

Comments
 (0)