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
{
$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 [
'assigned_grade_id' => $targetClass['id'] ?? null,
'assigned_grade_name' => $targetClass['class_name'] ?? ($grade !== '' ? $grade : null),
'assigned_class_section_id' => $targetSection['class_section_id'] ?? null,
'placement_status' => $targetSection === null ? 'manual_class_required' : 'same_class_assigned',
'assigned_grade_id' => null,
'assigned_grade_name' => $grade !== '' ? $grade : null,
'assigned_class_section_id' => null,
'placement_status' => 'manual_class_required',
'flags' => [],
];
}
@@ -35,16 +35,17 @@
<table id="enrollmentTable" class="table table-bordered table-striped mt-4 align-middle">
<thead>
<tr>
<th>Registration Date</th>
<th>Parent/Guardian</th>
<th>Register Date</th>
<th>Parent</th>
<th>Student Name</th>
<th>School ID</th>
<th>Age</th>
<th>New Student</th>
<th>Current Class</th>
<th>Actual Status</th>
<th>Update Enrollment Status</th>
<th>Assign Class</th>
<th>Age</th>
<th>New Student</th>
<th>Registered Class</th>
<th>Current Class</th>
<th>Actual Status</th>
<th>Update Status</th>
<th>Assign Class</th>
</tr>
</thead>
<tbody>
@@ -100,11 +101,14 @@
<?php endif; ?>
</td>
<!-- Class -->
<td><?= esc($student['class_section'] ?? 'Class not Assigned') ?></td>
<!-- Registered Class -->
<td><?= esc(trim((string)($student['registration_grade'] ?? '')) !== '' ? (string)$student['registration_grade'] : '-') ?></td>
<!-- Enrollment Status -->
<td>
<!-- Class -->
<td><?= esc($student['class_section'] ?? 'Class not Assigned') ?></td>
<!-- Enrollment Status -->
<td>
<?php
$status = $student['enrollment_status'] ?? 'not enrolled';
switch ($status) {
@@ -185,11 +189,11 @@
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="10">No students available.</td>
</tr>
<?php endif; ?>
<?php else: ?>
<tr>
<td colspan="11">No students available.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
@@ -383,10 +387,10 @@
dom: "<'row mb-2'<'col-sm-6'l><'col-sm-6'f>>" + "t" +
"<'row mt-2'<'col-sm-5'i><'col-sm-7'p>>",
// Disable sort/search on interactive columns (status select, assign select)
columnDefs: [
{ targets: [8, 9], orderable: false, searchable: false },
{ targets: [0, 1, 2, 3, 4, 5, 6, 7], render: function(data, type) {
// Disable sort/search on interactive columns (status select, assign select)
columnDefs: [
{ targets: [9, 10], orderable: false, searchable: false },
{ targets: [0, 1, 2, 3, 4, 5, 6, 7, 8], render: function(data, type) {
if (type === 'filter' || type === 'sort' || type === 'type') {
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->method('tableExists')->willReturnCallback(static fn (string $table): bool => $table === 'classSection');
$db->method('fieldExists')->willReturn(false);
$db->method('table')->willReturnCallback(static function (string $table) use ($classBuilder, $sectionBuilder) {
return $table === 'classes' ? $classBuilder : $sectionBuilder;
});
$db->expects($this->never())->method('table');
$service = new EnrollmentTransitionService($db);
@@ -88,9 +74,10 @@ final class EnrollmentTransitionServiceTest extends TestCase
'2026-2027',
]);
$this->assertSame(3, (int) $placement['assigned_grade_id']);
$this->assertSame(30, (int) $placement['assigned_class_section_id']);
$this->assertSame('same_class_assigned', $placement['placement_status']);
$this->assertNull($placement['assigned_grade_id']);
$this->assertSame('3', $placement['assigned_grade_name']);
$this->assertNull($placement['assigned_class_section_id']);
$this->assertSame('manual_class_required', $placement['placement_status']);
}
public function testClassLookupFallsBackToGlobalRowsWhenSchoolYearSpecificRowIsMissing(): void