fadd column to enrollment table
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 55s
Tests / PHPUnit (push) Successful in 1m26s

This commit is contained in:
root
2026-08-30 22:27:05 -04:00
parent 849a4579e9
commit 6ae90d757b
3 changed files with 35 additions and 48 deletions
+4 -8
View File
@@ -825,16 +825,12 @@ final class EnrollmentTransitionService
private function firstEnrollmentPlacement(array $student, string $targetSchoolYear): array private function firstEnrollmentPlacement(array $student, string $targetSchoolYear): array
{ {
$grade = $this->classBaseName((string) ($student['registration_grade'] ?? '')); $grade = $this->classBaseName((string) ($student['registration_grade'] ?? ''));
$targetClass = $grade !== '' ? $this->classByName($grade, $targetSchoolYear) : null;
$targetSection = is_array($targetClass)
? $this->baseSectionForClass((int) ($targetClass['id'] ?? 0), $targetSchoolYear)
: null;
return [ return [
'assigned_grade_id' => $targetClass['id'] ?? null, 'assigned_grade_id' => null,
'assigned_grade_name' => $targetClass['class_name'] ?? ($grade !== '' ? $grade : null), 'assigned_grade_name' => $grade !== '' ? $grade : null,
'assigned_class_section_id' => $targetSection['class_section_id'] ?? null, 'assigned_class_section_id' => null,
'placement_status' => $targetSection === null ? 'manual_class_required' : 'same_class_assigned', 'placement_status' => 'manual_class_required',
'flags' => [], 'flags' => [],
]; ];
} }
@@ -35,15 +35,16 @@
<table id="enrollmentTable" class="table table-bordered table-striped mt-4 align-middle"> <table id="enrollmentTable" class="table table-bordered table-striped mt-4 align-middle">
<thead> <thead>
<tr> <tr>
<th>Registration Date</th> <th>Register Date</th>
<th>Parent/Guardian</th> <th>Parent</th>
<th>Student Name</th> <th>Student Name</th>
<th>School ID</th> <th>School ID</th>
<th>Age</th> <th>Age</th>
<th>New Student</th> <th>New Student</th>
<th>Registered Class</th>
<th>Current Class</th> <th>Current Class</th>
<th>Actual Status</th> <th>Actual Status</th>
<th>Update Enrollment Status</th> <th>Update Status</th>
<th>Assign Class</th> <th>Assign Class</th>
</tr> </tr>
</thead> </thead>
@@ -100,6 +101,9 @@
<?php endif; ?> <?php endif; ?>
</td> </td>
<!-- Registered Class -->
<td><?= esc(trim((string)($student['registration_grade'] ?? '')) !== '' ? (string)$student['registration_grade'] : '-') ?></td>
<!-- Class --> <!-- Class -->
<td><?= esc($student['class_section'] ?? 'Class not Assigned') ?></td> <td><?= esc($student['class_section'] ?? 'Class not Assigned') ?></td>
@@ -187,7 +191,7 @@
<?php endforeach; ?> <?php endforeach; ?>
<?php else: ?> <?php else: ?>
<tr> <tr>
<td colspan="10">No students available.</td> <td colspan="11">No students available.</td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>
@@ -385,8 +389,8 @@
// Disable sort/search on interactive columns (status select, assign select) // Disable sort/search on interactive columns (status select, assign select)
columnDefs: [ columnDefs: [
{ targets: [8, 9], orderable: false, searchable: false }, { targets: [9, 10], orderable: false, searchable: false },
{ targets: [0, 1, 2, 3, 4, 5, 6, 7], render: function(data, type) { { targets: [0, 1, 2, 3, 4, 5, 6, 7, 8], render: function(data, type) {
if (type === 'filter' || type === 'sort' || type === 'type') { if (type === 'filter' || type === 'sort' || type === 'type') {
return stripHtml(data); return stripHtml(data);
} }
@@ -62,24 +62,10 @@ final class EnrollmentTransitionServiceTest extends TestCase
])); ]));
} }
public function testFirstEnrollmentPlacementUsesRegistrationGradeBaseSection(): void public function testFirstEnrollmentPlacementKeepsRegistrationGradeAsReferenceOnly(): void
{ {
$classBuilder = $this->builderReturning(['id' => 3, 'class_name' => '3']);
$classBuilder->method('where')->willReturnSelf();
$sectionBuilder = $this->builderReturning([
'class_section_id' => 30,
'class_id' => 3,
'class_section_name' => '3',
]);
$sectionBuilder->method('where')->willReturnSelf();
$db = $this->createMock(BaseConnection::class); $db = $this->createMock(BaseConnection::class);
$db->method('tableExists')->willReturnCallback(static fn (string $table): bool => $table === 'classSection'); $db->expects($this->never())->method('table');
$db->method('fieldExists')->willReturn(false);
$db->method('table')->willReturnCallback(static function (string $table) use ($classBuilder, $sectionBuilder) {
return $table === 'classes' ? $classBuilder : $sectionBuilder;
});
$service = new EnrollmentTransitionService($db); $service = new EnrollmentTransitionService($db);
@@ -88,9 +74,10 @@ final class EnrollmentTransitionServiceTest extends TestCase
'2026-2027', '2026-2027',
]); ]);
$this->assertSame(3, (int) $placement['assigned_grade_id']); $this->assertNull($placement['assigned_grade_id']);
$this->assertSame(30, (int) $placement['assigned_class_section_id']); $this->assertSame('3', $placement['assigned_grade_name']);
$this->assertSame('same_class_assigned', $placement['placement_status']); $this->assertNull($placement['assigned_class_section_id']);
$this->assertSame('manual_class_required', $placement['placement_status']);
} }
public function testClassLookupFallsBackToGlobalRowsWhenSchoolYearSpecificRowIsMissing(): void public function testClassLookupFallsBackToGlobalRowsWhenSchoolYearSpecificRowIsMissing(): void