= $this->extend('layout/management_layout') ?> = $this->section('content') ?> 0 ? round($totalConfirmed / $totalPredicted * 100) : ($totalActual === 0 ? 100 : 0); $pct = static function (int $count, int $total): string { return $total > 0 ? number_format(($count / $total) * 100, 1) . '%' : '0.0%'; }; $genderKey = static function (?string $gender): string { $value = strtolower(trim((string)$gender)); return match (true) { in_array($value, ['male', 'm', 'boy', 'boys'], true) => 'boys', in_array($value, ['female', 'f', 'girl', 'girls'], true) => 'girls', default => 'other', }; }; $genderStats = static function (array $items) use ($genderKey): array { $stats = ['boys' => 0, 'girls' => 0, 'other' => 0]; foreach ($items as $item) { $stats[$genderKey($item['gender'] ?? '')]++; } return $stats; }; // Winner gender breakdown. // "Winner" means actual year-end trophy winner. $totalWinnerBoys = 0; $totalWinnerGirls = 0; $totalWinnerOther = 0; $allStudentsFlat = []; $passStudents = []; $trophyStudents = []; // Sticker names. // 2 columns x 7 rows = 14 stickers per page. // Stickers print name and class section. $stickerColumns = 2; $stickerRows = 7; $stickerWidthInches = 4.0; $stickerHeightInches = 1.33; $stickerPrintablePageWidthInches = 8.0; $stickerPrintablePageHeightInches = 10.5; $stickersPerPage = $stickerColumns * $stickerRows; $winnerStickers = []; foreach ($classResults as $cls) { foreach (($cls['students'] ?? []) as $s) { $allStudentsFlat[] = $s; if (isset($s['year_score']) && is_numeric($s['year_score']) && (float)$s['year_score'] >= 60) { $passStudents[] = $s; } if (empty($s['actual'])) { continue; } $trophyStudents[] = $s; $gender = strtolower(trim((string)($s['gender'] ?? ''))); if (in_array($gender, ['male', 'm', 'boy', 'boys'], true)) { $totalWinnerBoys++; } elseif (in_array($gender, ['female', 'f', 'girl', 'girls'], true)) { $totalWinnerGirls++; } else { $totalWinnerOther++; } $name = trim((string)($s['name'] ?? '')); $sectionName = trim((string)($cls['section_name'] ?? '')); if ($name !== '') { $winnerStickers[] = [ 'name' => $name, 'section' => $sectionName, ]; } } } $totalWinners = $totalWinnerBoys + $totalWinnerGirls + $totalWinnerOther; $winnerBoysPct = $totalWinners > 0 ? round(($totalWinnerBoys / $totalWinners) * 100, 1) : 0; $winnerGirlsPct = $totalWinners > 0 ? round(($totalWinnerGirls / $totalWinners) * 100, 1) : 0; $winnerOtherPct = $totalWinners > 0 ? round(($totalWinnerOther / $totalWinners) * 100, 1) : 0; $allGenderStats = $genderStats($allStudentsFlat); $passGenderStats = $genderStats($passStudents); $trophyGenderStats = $genderStats($trophyStudents); $totalPass = count($passStudents); ?>
Compares the Fall-score prediction (= (int)$selectedPercentile ?>th percentile) with the year-end result based on the average of Fall & Spring scores.
| # | Name | Gender | Fall | Spring | Year Avg | Predicted | Actual | Status |
|---|---|---|---|---|---|---|---|---|
| = $rank ?> | = esc($s['name']) ?> | = $isMale ? 'M' : 'F' ?> | = $s['fall_score'] !== null ? number_format($s['fall_score'], 1) : '—' ?> | = $s['spring_score'] !== null ? number_format($s['spring_score'], 1) : '—' ?> | = $s['year_score'] !== null ? number_format($s['year_score'], 1) : '—' ?> | = $s['predicted'] ? 'Yes' : 'No' ?> | = $s['actual'] ? 'Yes' : 'No' ?> | print '✓ Confirmed', 'surprise' => print '↑ Surprise', 'missed' => print '↓ Missed', default => print '—', }; ?> |
| Class | Students | Predicted | Actual | ✓ Confirmed | ↑ Surprises | ↓ Missed | Accuracy | Fall ≥ | Year ≥ |
|---|---|---|---|---|---|---|---|---|---|
| = esc($cls['section_name']) ?> | = $cls['student_count'] ?> | = $cls['predicted_count'] ?> | = $cls['actual_count'] ?> | = $cls['confirmed'] ?> | = $cls['surprises'] ?> | = $cls['missed'] ?> | = $cls['accuracy'] ?>% | = $cls['fall_threshold'] !== null ? number_format((float)$cls['fall_threshold'], 1) : '—' ?> | = $cls['year_threshold'] !== null ? number_format((float)$cls['year_threshold'], 1) : '—' ?> |
| Total | = $totalStudents ?> | = $totalPredicted ?> | = $totalActual ?> | = $totalConfirmed ?> | = $totalSurprise ?> | = $totalMissed ?> | = $overallAccuracy ?>% | ||
= (int)$selectedPercentile ?>th percentile — Predicted: = $totalPredicted ?> — Actual: = $totalActual ?> — Confirmed: = $totalConfirmed ?> — Accuracy: = $overallAccuracy ?>%
| Metric | Count | Percent | Boys | Boys % | Girls | Girls % |
|---|---|---|---|---|---|---|
| Total Students | = $totalStudents ?> | 100.0% | = $allGenderStats['boys'] ?> | = $pct($allGenderStats['boys'], $totalStudents) ?> | = $allGenderStats['girls'] ?> | = $pct($allGenderStats['girls'], $totalStudents) ?> |
| Pass | = $totalPass ?> | = $pct($totalPass, $totalStudents) ?> | = $passGenderStats['boys'] ?> | = $pct($passGenderStats['boys'], $totalPass) ?> | = $passGenderStats['girls'] ?> | = $pct($passGenderStats['girls'], $totalPass) ?> |
| Trophies | = $totalWinners ?> | = $pct($totalWinners, $totalStudents) ?> | = $trophyGenderStats['boys'] ?> | = $pct($trophyGenderStats['boys'], $totalWinners) ?> | = $trophyGenderStats['girls'] ?> | = $pct($trophyGenderStats['girls'], $totalWinners) ?> |
| # | Class | Name | G | Fall | Spring | Year Avg | Predicted | Actual | Status |
|---|---|---|---|---|---|---|---|---|---|
| = $rank ?> | = esc($cls['section_name']) ?> | = esc($s['name']) ?> | = $isMale ? 'M' : 'F' ?> | = $s['fall_score'] !== null ? number_format($s['fall_score'], 1) : '—' ?> | = $s['spring_score'] !== null ? number_format($s['spring_score'], 1) : '—' ?> | = $s['year_score'] !== null ? number_format($s['year_score'], 1) : '—' ?> | = $s['predicted'] ? 'Yes' : 'No' ?> | = $s['actual'] ? 'Yes' : 'No' ?> | = $statusLabel ?> |
| Class | Students | Predicted | Actual | ✓ Confirmed | ↑ Surprises | ↓ Missed | Accuracy | Fall ≥ | Year ≥ |
|---|---|---|---|---|---|---|---|---|---|
| = esc($cls['section_name']) ?> | = $cls['student_count'] ?> | = $cls['predicted_count'] ?> | = $cls['actual_count'] ?> | = $cls['confirmed'] ?> | = $cls['surprises'] ?> | = $cls['missed'] ?> | = $cls['accuracy'] ?>% | = $cls['fall_threshold'] !== null ? number_format((float)$cls['fall_threshold'], 1) : '—' ?> | = $cls['year_threshold'] !== null ? number_format((float)$cls['year_threshold'], 1) : '—' ?> |
| Total | = $totalStudents ?> | = $totalPredicted ?> | = $totalActual ?> | = $totalConfirmed ?> | = $totalSurprise ?> | = $totalMissed ?> | = $overallAccuracy ?>% | ||
Trophy Counts per Class
Prediction Accuracy per Class
Overall Outcome Breakdown
Winner Gender Breakdown
| Group | Winners | Percentage |
|---|---|---|
| Boys | = (int)$totalWinnerBoys ?> | = number_format($winnerBoysPct, 1) ?>% |
| Girls | = (int)$totalWinnerGirls ?> | = number_format($winnerGirlsPct, 1) ?>% |
| Total Winners | = (int)$totalWinners ?> | = $totalWinners > 0 ? '100.0%' : '0.0%' ?> |