@@ -510,6 +510,10 @@ public function getResultsData(
510
510
$ data = [];
511
511
$ lowestMedalPoints = 0 ;
512
512
513
+ // For every team that we skip because it is not in a medal category, we need to include one
514
+ // additional rank. So keep track of the number of skipped teams
515
+ $ skippedTeams = 0 ;
516
+
513
517
foreach ($ scoreboard ->getScores () as $ teamScore ) {
514
518
if ($ teamScore ->team ->getCategory ()->getSortorder () !== $ sortOrder ) {
515
519
continue ;
@@ -522,13 +526,20 @@ public function getResultsData(
522
526
523
527
$ rank = $ teamScore ->rank ;
524
528
$ numPoints = $ teamScore ->numPoints ;
525
- if ($ rank <= $ contest ->getGoldMedals ()) {
529
+ $ skip = false ;
530
+
531
+ if (!$ contest ->getMedalCategories ()->contains ($ teamScore ->team ->getCategory ())) {
532
+ $ skip = true ;
533
+ $ skippedTeams ++;
534
+ }
535
+
536
+ if (!$ skip && $ rank - $ skippedTeams <= $ contest ->getGoldMedals ()) {
526
537
$ awardString = 'Gold Medal ' ;
527
538
$ lowestMedalPoints = $ teamScore ->numPoints ;
528
- } elseif ($ rank <= $ contest ->getGoldMedals () + $ contest ->getSilverMedals ()) {
539
+ } elseif (! $ skip && $ rank - $ skippedTeams <= $ contest ->getGoldMedals () + $ contest ->getSilverMedals ()) {
529
540
$ awardString = 'Silver Medal ' ;
530
541
$ lowestMedalPoints = $ teamScore ->numPoints ;
531
- } elseif ($ rank <= $ contest ->getGoldMedals () + $ contest ->getSilverMedals () + $ contest ->getBronzeMedals () + $ contest ->getB ()) {
542
+ } elseif (! $ skip && $ rank - $ skippedTeams <= $ contest ->getGoldMedals () + $ contest ->getSilverMedals () + $ contest ->getBronzeMedals () + $ contest ->getB ()) {
532
543
$ awardString = 'Bronze Medal ' ;
533
544
$ lowestMedalPoints = $ teamScore ->numPoints ;
534
545
} elseif ($ numPoints >= $ median ) {
@@ -540,7 +551,8 @@ public function getResultsData(
540
551
$ rank = $ ranks [$ numPoints ];
541
552
}
542
553
if ($ honors ) {
543
- if ($ numPoints === $ lowestMedalPoints ) {
554
+ if ($ numPoints >= $ lowestMedalPoints ) {
555
+ // Some teams out of the medal categories may get more points than the lowest medalist.
544
556
$ awardString = 'Highest Honors ' ;
545
557
} elseif ($ numPoints === $ lowestMedalPoints - 1 ) {
546
558
$ awardString = 'High Honors ' ;
0 commit comments