add test batches

This commit is contained in:
root
2026-06-08 23:45:55 -04:00
parent c792b8be05
commit 8d4d610b82
1480 changed files with 22587 additions and 10762 deletions
@@ -13,13 +13,14 @@ class AttendanceViolationStudentResolverService
protected Student $studentModel,
protected StudentClass $studentClassModel,
protected AttendanceData $attendanceDataModel
) {}
) {
}
public function resolveForSchoolYear(string $schoolYear, ?string $semester = null): array
{
$debug = [
'class_students' => 0,
'student_ids' => 0,
'student_ids' => 0,
];
$classStudentsQuery = $this->studentClassModel->query();
@@ -40,9 +41,9 @@ class AttendanceViolationStudentResolverService
->orderByDesc('id')
->first();
if ($latestTerm && ! empty($latestTerm->school_year)) {
if ($latestTerm && !empty($latestTerm->school_year)) {
$schoolYear = (string) $latestTerm->school_year;
if (! empty($latestTerm->semester)) {
if (!empty($latestTerm->semester)) {
$semester = (string) $latestTerm->semester;
}
@@ -72,14 +73,14 @@ class AttendanceViolationStudentResolverService
if (empty($studentIds) && empty($studentCodes)) {
return [
'school_year' => $schoolYear,
'semester' => $semester,
'student_ids' => [],
'student_codes' => [],
'students' => [],
'student_code_to_id' => [],
'existing_ids' => [],
'debug' => $debug,
'school_year' => $schoolYear,
'semester' => $semester,
'student_ids' => [],
'student_codes' => [],
'students' => [],
'student_code_to_id'=> [],
'existing_ids' => [],
'debug' => $debug,
];
}
@@ -90,14 +91,14 @@ class AttendanceViolationStudentResolverService
[$studentCodeToId, $existingIds] = $this->buildLookupMaps($students);
return [
'school_year' => $schoolYear,
'semester' => $semester,
'student_ids' => $studentIds,
'student_codes' => $studentCodes,
'students' => $students,
'school_year' => $schoolYear,
'semester' => $semester,
'student_ids' => $studentIds,
'student_codes' => $studentCodes,
'students' => $students,
'student_code_to_id' => $studentCodeToId,
'existing_ids' => $existingIds,
'debug' => $debug,
'existing_ids' => $existingIds,
'debug' => $debug,
];
}
@@ -113,12 +114,12 @@ class AttendanceViolationStudentResolverService
return null;
}
if (! isset($existingIds[$sid])) {
if (!isset($existingIds[$sid])) {
$students[] = [
'id' => $sid,
'id' => $sid,
'school_id' => (string) $sid,
'firstname' => (string) $sid,
'lastname' => '',
'lastname' => '',
'parent_id' => 0,
];
$existingIds[$sid] = true;
@@ -138,12 +139,12 @@ class AttendanceViolationStudentResolverService
$sid = abs(crc32($code)) ?: random_int(3000000, 3999999);
$studentCodeToId[$code] = $sid;
if (! isset($existingIds[$sid])) {
if (!isset($existingIds[$sid])) {
$students[] = [
'id' => $sid,
'id' => $sid,
'school_id' => $code,
'firstname' => $code,
'lastname' => '',
'lastname' => '',
'parent_id' => 0,
];
$existingIds[$sid] = true;
@@ -184,7 +185,7 @@ class AttendanceViolationStudentResolverService
$attendanceStudents = DB::table($this->attendanceDataModel->getTable())
->selectRaw('DISTINCT student_id')
->when(! empty($schoolYear), fn ($q) => $q->where('school_year', $schoolYear))
->when(!empty($schoolYear), fn ($q) => $q->where('school_year', $schoolYear))
->orderBy('student_id')
->get();
@@ -206,7 +207,7 @@ class AttendanceViolationStudentResolverService
protected function filterInactiveIdentifiers(array $studentIds, array $studentCodes): array
{
if (! empty($studentIds)) {
if (!empty($studentIds)) {
$inactiveRows = $this->studentModel->query()
->select('id')
->whereIn('id', $studentIds)
@@ -221,11 +222,11 @@ class AttendanceViolationStudentResolverService
$studentIds = array_values(array_filter(
$studentIds,
static fn ($id) => ! isset($inactiveIdSet[$id])
static fn ($id) => !isset($inactiveIdSet[$id])
));
}
if (! empty($studentCodes)) {
if (!empty($studentCodes)) {
$inactiveCodeRows = $this->studentModel->query()
->select('school_id')
->whereIn('school_id', $studentCodes)
@@ -240,7 +241,7 @@ class AttendanceViolationStudentResolverService
$studentCodes = array_values(array_filter(
$studentCodes,
static fn ($code) => $code !== '' && ! isset($inactiveCodeSet[$code])
static fn ($code) => $code !== '' && !isset($inactiveCodeSet[$code])
));
}
@@ -251,7 +252,7 @@ class AttendanceViolationStudentResolverService
{
$students = [];
if (! empty($studentIds)) {
if (!empty($studentIds)) {
$students = $this->studentModel->query()
->whereIn('id', $studentIds)
->where('is_active', 1)
@@ -259,7 +260,7 @@ class AttendanceViolationStudentResolverService
->toArray();
}
if (! empty($studentCodes)) {
if (!empty($studentCodes)) {
$byCode = $this->studentModel->query()
->whereIn('school_id', $studentCodes)
->where('is_active', 1)
@@ -270,7 +271,7 @@ class AttendanceViolationStudentResolverService
foreach ($byCode as $s) {
$sid = (int) ($s['id'] ?? 0);
if ($sid > 0 && ! isset($seen[$sid])) {
if ($sid > 0 && !isset($seen[$sid])) {
$students[] = $s;
$seen[$sid] = true;
}
@@ -292,14 +293,14 @@ class AttendanceViolationStudentResolverService
}
foreach ($studentCodes as $code) {
if (! isset($knownCodes[$code])) {
if (!isset($knownCodes[$code])) {
$virtualId = abs(crc32($code)) ?: random_int(1000000, 1999999);
$students[] = [
'id' => $virtualId,
'school_id' => $code,
'firstname' => $code,
'lastname' => '',
'parent_id' => 0,
'id' => $virtualId,
'school_id' => $code,
'firstname' => $code,
'lastname' => '',
'parent_id' => 0,
'class_name' => '',
];
}
@@ -316,13 +317,13 @@ class AttendanceViolationStudentResolverService
if (is_numeric($sidOrCode)) {
$sid = (int) $sidOrCode;
if ($sid > 0 && ! isset($existingIds[$sid])) {
if ($sid > 0 && !isset($existingIds[$sid])) {
$students[] = [
'id' => $sid,
'school_id' => (string) $sid,
'firstname' => (string) $sid,
'lastname' => '',
'parent_id' => 0,
'id' => $sid,
'school_id' => (string) $sid,
'firstname' => (string) $sid,
'lastname' => '',
'parent_id' => 0,
'class_name' => '',
];
$existingIds[$sid] = true;
@@ -330,14 +331,14 @@ class AttendanceViolationStudentResolverService
} else {
$code = (string) $sidOrCode;
if ($code !== '' && ! isset($studentCodeToId[$code])) {
if ($code !== '' && !isset($studentCodeToId[$code])) {
$virtualId = abs(crc32($code)) ?: random_int(2000000, 2999999);
$students[] = [
'id' => $virtualId,
'school_id' => $code,
'firstname' => $code,
'lastname' => '',
'parent_id' => 0,
'id' => $virtualId,
'school_id' => $code,
'firstname' => $code,
'lastname' => '',
'parent_id' => 0,
'class_name' => '',
];