Skip to content

Commit

Permalink
Split Gender and Grade columns
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Jul 13, 2024
1 parent 45021f0 commit 8a31c9d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions app/Controllers/Competition.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ public function results($id) {
'Nama',
);

if ($this->hasGradeAndGenderInfo($contestants)) {
if ($this->hasGenderInfo($contestants)) {
$heading[] = 'J.K.';
}

if ($this->hasGradeInfo($contestants)) {
$heading[] = 'Kls.';
}

Expand Down Expand Up @@ -199,8 +202,11 @@ public function results($id) {
['data' => linkPerson($c['PersonID'], $c['Name']), 'class' => $clazz],
);

if ($this->hasGradeAndGenderInfo($contestants)) {
if ($this->hasGenderInfo($contestants)) {
$row[] = ['data' => $c['Gender'], 'class' => 'col-gender ' . $clazz];
}

if ($this->hasGradeInfo($contestants)) {
$row[] = ['data' => $c['Grade'], 'class' => 'col-grade ' . $clazz];
}

Expand Down Expand Up @@ -374,9 +380,18 @@ private function getPastContestants($competition) {
return $result;
}

private function hasGradeAndGenderInfo($contestants) {
private function hasGenderInfo($contestants) {
foreach ($contestants as $c) {
if ($c['Gender']) {
return true;
}
}
return false;
}

private function hasGradeInfo($contestants) {
foreach ($contestants as $c) {
if ($c['Gender'] || $c['Grade']) {
if ($c['Grade']) {
return true;
}
}
Expand Down

0 comments on commit 8a31c9d

Please sign in to comment.