fix all issues before deploy
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Failing after 1m18s

This commit is contained in:
root
2026-08-25 03:10:44 -04:00
parent 5f5afe97ad
commit 9899af7b37
11 changed files with 515 additions and 37 deletions
@@ -4,6 +4,7 @@ namespace App\Services;
use App\Models\ConfigurationModel;
use App\Support\Enrollment\DeliberationDecision;
use App\Support\Enrollment\EnrollmentEligibility;
use CodeIgniter\Database\BaseConnection;
use DateTimeInterface;
@@ -132,6 +133,7 @@ final class EnrollmentRegistrationEmailService
$studentSummaries[] = [
'name' => trim((string) ($student['firstname'] ?? '') . ' ' . (string) ($student['lastname'] ?? '')) ?: 'Student #' . $studentId,
'adult_student' => ! empty($evaluation['adult_student']),
'issue_code' => $this->studentIssueCode($evaluation),
];
}
@@ -293,6 +295,13 @@ final class EnrollmentRegistrationEmailService
private function decisionMessage(string $name, array $evaluation, string $opens, string $deadline, array $schoolYear = []): string
{
if (! empty($evaluation['kg_missing_decision_eligible']) && ! $this->hasNonKgMissingDecisionBlocker($evaluation)) {
$placement = $this->placementText($evaluation);
$placementText = $placement !== '' ? ' The student placement for the new school year is: ' . $placement . '.' : '';
return 'KG students may complete registration now. ' . $name . ' is eligible for re-enrollment even though no final deliberation decision is recorded.' . $placementText;
}
if (($evaluation['can_enroll'] ?? false) === false && ! empty($evaluation['primary_parent_message'])) {
return (string) $evaluation['primary_parent_message'];
}
@@ -518,6 +527,18 @@ final class EnrollmentRegistrationEmailService
: 'Eligible';
}
if (! empty($evaluation['kg_missing_decision_eligible']) && ! $this->hasNonKgMissingDecisionBlocker($evaluation)) {
return 'Eligible';
}
if (
strtoupper(trim((string) ($evaluation['primary_block_reason'] ?? ''))) === 'ALREADY_ENROLLED'
|| in_array('ALREADY_ENROLLED', array_map('strval', $evaluation['blocking_rule_codes'] ?? []), true)
|| strtoupper(trim((string) ($evaluation['decision'] ?? ''))) === 'ALREADY_ENROLLED'
) {
return EnrollmentEligibility::alreadyEnrolledTitle($evaluation['enrollment_status'] ?? null);
}
if (! empty($evaluation['adult_student'])) {
return 'Not Eligible';
}
@@ -529,6 +550,53 @@ final class EnrollmentRegistrationEmailService
return 'Not Eligible';
}
private function hasNonKgMissingDecisionBlocker(array $evaluation): bool
{
$ignoredCodes = ['NO_FINAL_DECISION', 'UNRECOGNIZED_DECISION'];
$blockingCodes = array_values(array_filter(array_map(
static fn ($code): string => strtoupper(trim((string) $code)),
$evaluation['blocking_rule_codes'] ?? []
)));
$reviewCodes = array_values(array_filter(array_map(
static fn ($code): string => strtoupper(trim((string) $code)),
$evaluation['review_rule_codes'] ?? []
)));
$codes = array_values(array_unique(array_merge($blockingCodes, $reviewCodes)));
return array_values(array_diff($codes, $ignoredCodes)) !== [];
}
private function studentIssueCode(array $evaluation): string
{
if (! empty($evaluation['adult_student'])) {
return 'ADULT_STUDENT_PARENT_BLOCKED';
}
foreach (($evaluation['flags'] ?? []) as $flag) {
if (! is_array($flag)) {
continue;
}
$details = is_array($flag['details'] ?? null) ? $flag['details'] : [];
$ruleCode = strtoupper(trim((string) ($details['rule_code'] ?? '')));
if ($ruleCode !== '') {
return $ruleCode;
}
$flagType = strtoupper(trim((string) ($flag['flag_type'] ?? '')));
if ($flagType !== '') {
return $flagType;
}
}
$primaryBlockReason = strtoupper(trim((string) ($evaluation['primary_block_reason'] ?? '')));
if ($primaryBlockReason !== '') {
return $primaryBlockReason;
}
return '';
}
private function placementText(array $evaluation): string
{
$placement = match ((string) ($evaluation['placement_status'] ?? '')) {
@@ -623,6 +691,10 @@ final class EnrollmentRegistrationEmailService
return $fallback;
}
if (in_array(strtoupper($grade), ['KG', 'K', 'KINDERGARTEN'], true)) {
return 'KG';
}
return preg_match('/^grade\b/i', $grade) === 1 ? $grade : 'Grade ' . $grade;
}
}