fix deployment db issue and widthrawal administration page
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Failing after 1m19s

This commit is contained in:
root
2026-08-20 20:18:00 -04:00
parent 889c037660
commit d3da699e55
19 changed files with 1170 additions and 194 deletions
+64 -7
View File
@@ -173,6 +173,7 @@ final class EnrollmentTransitionService
if ($decisionRow === null || $decision === null) {
$result['blockers'][] = EnrollmentEligibility::MISSING_DECISION_MESSAGE;
$result['flags'][] = $this->flag('DEFERRED_DELIBERATION', 'high', [
'rule_code' => $decisionRow === null ? 'NO_FINAL_DECISION' : 'UNRECOGNIZED_DECISION',
'reason' => 'Missing or unrecognized final deliberation decision.',
]);
return $result;
@@ -180,19 +181,19 @@ final class EnrollmentTransitionService
if ($decision === DeliberationDecision::EXPELLED) {
$result['blockers'][] = EnrollmentEligibility::EXPELLED_MESSAGE;
$result['flags'][] = $this->flag('RESTRICTED_ADMINISTRATIVE_REVIEW', 'high');
$result['flags'][] = $this->flag('RESTRICTED_ADMINISTRATIVE_REVIEW', 'high', ['rule_code' => 'EXPELLED']);
return $result;
}
if ($decision === DeliberationDecision::WITHDRAWN) {
$result['blockers'][] = EnrollmentEligibility::WITHDRAWN_MESSAGE;
$result['flags'][] = $this->flag('WITHDRAWAL_REVIEW_REQUIRED', 'normal');
$result['flags'][] = $this->flag('WITHDRAWAL_REVIEW_REQUIRED', 'normal', ['rule_code' => 'WITHDRAWN']);
return $result;
}
if ($decision === DeliberationDecision::DEFERRED_DECISION) {
$result['blockers'][] = EnrollmentEligibility::DEFERRED_MESSAGE;
$result['flags'][] = $this->flag('DEFERRED_DELIBERATION', 'high');
$result['flags'][] = $this->flag('DEFERRED_DELIBERATION', 'high', ['rule_code' => 'DEFERRED_DECISION']);
return $result;
}
@@ -705,6 +706,7 @@ final class EnrollmentTransitionService
$decisions = $this->latestDecisionsByStudent($sourceSchoolYear);
$enrolledIds = $this->activeTargetEnrollmentStudentIds($targetSchoolYear);
$targetReviewCodes = $this->targetEnrollmentReviewCodesByStudent($targetSchoolYear);
$bypassCodesByStudent = $this->activeBypassCodesByStudent($targetSchoolYear);
$written = 0;
@@ -720,20 +722,34 @@ final class EnrollmentTransitionService
$alreadyEnrolled = isset($enrolledIds[$studentId]);
$flags = [];
if ($decisionRow === null || $decision === null) {
if (! $alreadyEnrolled && isset($targetReviewCodes[$studentId])) {
$review = $targetReviewCodes[$studentId];
$code = (string) ($review['rule_code'] ?? 'WITHDRAWN');
$flags[] = $this->flag(
$code === 'DENIED' ? 'RESTRICTED_ADMINISTRATIVE_REVIEW' : 'WITHDRAWAL_REVIEW_REQUIRED',
$code === 'DENIED' ? 'high' : 'normal',
[
'rule_code' => $code,
'enrollment_status' => $review['enrollment_status'] ?? null,
'is_withdrawn' => $review['is_withdrawn'] ?? null,
]
);
} elseif ($decisionRow === null || $decision === null) {
if (! $alreadyEnrolled) {
$flags[] = $this->flag('DEFERRED_DELIBERATION', 'high', [
'rule_code' => $decisionRow === null ? 'NO_FINAL_DECISION' : 'UNRECOGNIZED_DECISION',
'reason' => 'Missing or unrecognized final deliberation decision.',
]);
}
} elseif ($decision === DeliberationDecision::EXPELLED && ! $alreadyEnrolled) {
$flags[] = $this->flag('RESTRICTED_ADMINISTRATIVE_REVIEW', 'high');
$flags[] = $this->flag('RESTRICTED_ADMINISTRATIVE_REVIEW', 'high', ['rule_code' => 'EXPELLED']);
} elseif ($decision === DeliberationDecision::WITHDRAWN && ! $alreadyEnrolled) {
$flags[] = $this->flag('WITHDRAWAL_REVIEW_REQUIRED', 'normal');
$flags[] = $this->flag('WITHDRAWAL_REVIEW_REQUIRED', 'normal', ['rule_code' => 'WITHDRAWN']);
} elseif ($decision === DeliberationDecision::DEFERRED_DECISION && ! $alreadyEnrolled) {
$flags[] = $this->flag('DEFERRED_DELIBERATION', 'high');
$flags[] = $this->flag('DEFERRED_DELIBERATION', 'high', ['rule_code' => 'DEFERRED_DECISION']);
} elseif ($decision === DeliberationDecision::MAKE_UP_EXAM) {
$flags[] = $this->flag('PENDING_MAKE_UP_EXAM_PROMOTION', 'high', [
'rule_code' => 'MAKE_UP_EXAM',
'current_class_section_name' => $student['class_section_name'] ?? ($decisionRow['class_section_name'] ?? null),
]);
}
@@ -990,6 +1006,47 @@ final class EnrollmentTransitionService
return $ids;
}
/**
* @return array<int, array{rule_code: string, enrollment_status: string, is_withdrawn: int}>
*/
private function targetEnrollmentReviewCodesByStudent(string $targetSchoolYear): array
{
if (! $this->db->tableExists('enrollments')) {
return [];
}
$select = ['student_id', 'enrollment_status', 'admission_status'];
if ($this->db->fieldExists('is_withdrawn', 'enrollments')) {
$select[] = 'is_withdrawn';
}
$rows = $this->db->table('enrollments')
->select(implode(', ', $select))
->where('school_year', $targetSchoolYear)
->orderBy('updated_at', 'DESC')
->orderBy('id', 'DESC')
->get()
->getResultArray();
$reviewCodes = [];
foreach ($rows as $row) {
$studentId = (int) ($row['student_id'] ?? 0);
if ($studentId <= 0 || isset($reviewCodes[$studentId]) || ! $this->deniedOrWithdrawnEnrollmentBlocksStandardEligibility($row)) {
continue;
}
$status = strtolower(trim((string) ($row['enrollment_status'] ?? '')));
$admission = strtolower(trim((string) ($row['admission_status'] ?? '')));
$reviewCodes[$studentId] = [
'rule_code' => $admission === 'denied' || $status === 'denied' ? 'DENIED' : 'WITHDRAWN',
'enrollment_status' => (string) ($row['enrollment_status'] ?? ''),
'is_withdrawn' => (int) ($row['is_withdrawn'] ?? 0),
];
}
return $reviewCodes;
}
private function syncSiblingLastNameFlags(
array $students,
array $enrolledIds,