Skip to content

Commit 1a7c94e

Browse files
cubercslvmcj
authored andcommitted
test(export): add test for medal medal categories
Signed-off-by: cubercsl <2014cais01@gmail.com>
1 parent 19bc91e commit 1a7c94e

20 files changed

+550
-14
lines changed

webapp/src/Service/ImportExportService.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,21 @@ public function getResultsData(
533533
$skippedTeams++;
534534
}
535535

536+
if ($numPoints === 0) {
537+
// Teams with 0 points won't get a medal, a rank or an honor.
538+
// They will always get an honorable mention.
539+
$data[] = new ResultRow(
540+
$teamScore->team->getIcpcId(),
541+
null,
542+
'Honorable',
543+
$teamScore->numPoints,
544+
$teamScore->totalTime,
545+
$maxTime,
546+
null
547+
);
548+
continue;
549+
}
550+
536551
if (!$skip && $rank - $skippedTeams <= $contest->getGoldMedals()) {
537552
$awardString = 'Gold Medal';
538553
$lowestMedalPoints = $teamScore->numPoints;
@@ -551,8 +566,9 @@ public function getResultsData(
551566
$rank = $ranks[$numPoints];
552567
}
553568
if ($honors) {
554-
if ($numPoints >= $lowestMedalPoints) {
555-
// Some teams out of the medal categories may get more points than the lowest medalist.
569+
if ($numPoints === $lowestMedalPoints
570+
|| $rank - $skippedTeams <= $contest->getGoldMedals() + $contest->getSilverMedals() + $contest->getBronzeMedals() + $contest->getB()) {
571+
// Some teams out of the medal categories but ranked higher than bronze medallists may get more points.
556572
$awardString = 'Highest Honors';
557573
} elseif ($numPoints === $lowestMedalPoints - 1) {
558574
$awardString = 'High Honors';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
results 1
2+
10001 1 Gold Medal 4 36 20 Sample Group A
3+
10002 2 Gold Medal 2 5 3
4+
10003 2 Gold Medal 2 5 3
5+
10004 4 Highest Honors 1 12 12 Sample Group B
6+
10005 5 Highest Honors 1 13 13
7+
10006 6 Highest Honors 1 14 14
8+
10007 7 Bronze Medal 1 15 15 Sample Group C
9+
10008 Honorable 0 0 0
10+
10009 Honorable 0 0 0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
results 1
2+
10001 1 Gold Medal 4 36 20 Sample Group A
3+
10002 2 Gold Medal 2 5 3
4+
10003 2 Gold Medal 2 5 3
5+
10004 4 Ranked 1 12 12 Sample Group B
6+
10005 5 Ranked 1 13 13
7+
10006 6 Ranked 1 14 14
8+
10007 7 Bronze Medal 1 15 15 Sample Group C
9+
10008 Honorable 0 0 0
10+
10009 Honorable 0 0 0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
results 1
2+
10001 1 Gold Medal 4 36 20 Sample Group A
3+
10002 2 Gold Medal 2 5 3
4+
10003 2 Gold Medal 2 5 3
5+
10004 4 Highest Honors 1 12 12 Sample Group B
6+
10005 4 Highest Honors 1 13 13
7+
10006 4 Highest Honors 1 14 14
8+
10007 7 Bronze Medal 1 15 15 Sample Group C
9+
10008 Honorable 0 0 0
10+
10009 Honorable 0 0 0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
results 1
2+
10001 1 Gold Medal 4 36 20 Sample Group A
3+
10002 2 Gold Medal 2 5 3
4+
10003 2 Gold Medal 2 5 3
5+
10004 4 Ranked 1 12 12 Sample Group B
6+
10005 4 Ranked 1 13 13
7+
10006 4 Ranked 1 14 14
8+
10007 7 Bronze Medal 1 15 15 Sample Group C
9+
10008 Honorable 0 0 0
10+
10009 Honorable 0 0 0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"hidden": false,
4+
"categoryid": 5,
5+
"id": "10001",
6+
"icpc_id": "10001",
7+
"name": "Sample Group A",
8+
"sortorder": 0,
9+
"color": null,
10+
"allow_self_registration": false
11+
},
12+
{
13+
"hidden": false,
14+
"categoryid": 6,
15+
"id": "10002",
16+
"icpc_id": "10002",
17+
"name": "Sample Group B",
18+
"sortorder": 0,
19+
"color": null,
20+
"allow_self_registration": false
21+
},
22+
{
23+
"hidden": false,
24+
"categoryid": 7,
25+
"id": "10003",
26+
"icpc_id": "10003",
27+
"name": "Sample Group C",
28+
"sortorder": 0,
29+
"color": null,
30+
"allow_self_registration": false
31+
}
32+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"medals": {
3+
"gold": 2,
4+
"silver": 1,
5+
"bronze": 1
6+
},
7+
"medal_categories": [
8+
"10001",
9+
"10003"
10+
]
11+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[
2+
{
3+
"ordinal": 0,
4+
"probid": 1,
5+
"short_name": "A",
6+
"rgb": "#FF0000",
7+
"color": "red",
8+
"label": "A",
9+
"time_limit": 1.0,
10+
"statement": [
11+
{
12+
"href": "contests/sample_contests/problems/sample-problem-a/statement",
13+
"mime": "application/pdf",
14+
"filename": "A.pdf"
15+
}
16+
],
17+
"id": "sample-problem-a",
18+
"name": "Sample Problem A",
19+
"test_data_count": 50
20+
},
21+
{
22+
"ordinal": 1,
23+
"probid": 2,
24+
"short_name": "B",
25+
"rgb": "#00FF00",
26+
"color": "lime",
27+
"label": "B",
28+
"time_limit": 2.0,
29+
"statement": [
30+
{
31+
"href": "contests/sample_contests/problems/sample-problem-b/statement",
32+
"mime": "application/pdf",
33+
"filename": "B.pdf"
34+
}
35+
],
36+
"id": "sample-problem-b",
37+
"name": "Sample Problem B",
38+
"test_data_count": 32
39+
},
40+
{
41+
"ordinal": 2,
42+
"probid": 3,
43+
"short_name": "C",
44+
"rgb": "#0000FF",
45+
"color": "blue",
46+
"label": "C",
47+
"time_limit": 3.0,
48+
"statement": [
49+
{
50+
"href": "contests/sample_contests/problems/sample-problem-c/statement",
51+
"mime": "application/pdf",
52+
"filename": "C.pdf"
53+
}
54+
],
55+
"id": "sample-problem-c",
56+
"name": "Sample Problem C",
57+
"test_data_count": 78
58+
},
59+
{
60+
"ordinal": 3,
61+
"probid": 4,
62+
"short_name": "D",
63+
"rgb": "#FFFF00",
64+
"color": "yellow",
65+
"label": "D",
66+
"time_limit": 4.0,
67+
"statement": [
68+
{
69+
"href": "contests/sample_contests/problems/sample-problem-d/statement",
70+
"mime": "application/pdf",
71+
"filename": "D.pdf"
72+
}
73+
],
74+
"id": "sample-problem-d",
75+
"name": "Sample Problem D",
76+
"test_data_count": 100
77+
}
78+
]

0 commit comments

Comments
 (0)