@@ -510,6 +510,10 @@ public function getResultsData(
510510 $ data = [];
511511 $ lowestMedalPoints = 0 ;
512512
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+
513517 foreach ($ scoreboard ->getScores () as $ teamScore ) {
514518 if ($ teamScore ->team ->getCategory ()->getSortorder () !== $ sortOrder ) {
515519 continue ;
@@ -522,13 +526,20 @@ public function getResultsData(
522526
523527 $ rank = $ teamScore ->rank ;
524528 $ 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 ()) {
526537 $ awardString = 'Gold Medal ' ;
527538 $ lowestMedalPoints = $ teamScore ->numPoints ;
528- } elseif ($ rank <= $ contest ->getGoldMedals () + $ contest ->getSilverMedals ()) {
539+ } elseif (! $ skip && $ rank - $ skippedTeams <= $ contest ->getGoldMedals () + $ contest ->getSilverMedals ()) {
529540 $ awardString = 'Silver Medal ' ;
530541 $ 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 ()) {
532543 $ awardString = 'Bronze Medal ' ;
533544 $ lowestMedalPoints = $ teamScore ->numPoints ;
534545 } elseif ($ numPoints >= $ median ) {
@@ -540,7 +551,8 @@ public function getResultsData(
540551 $ rank = $ ranks [$ numPoints ];
541552 }
542553 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.
544556 $ awardString = 'Highest Honors ' ;
545557 } elseif ($ numPoints === $ lowestMedalPoints - 1 ) {
546558 $ awardString = 'High Honors ' ;
0 commit comments