add tests batch 20

This commit is contained in:
root
2026-06-09 01:03:53 -04:00
parent 95efb9652e
commit 6be4875c5e
1502 changed files with 13797 additions and 11313 deletions
@@ -11,7 +11,9 @@ use Illuminate\Support\Facades\DB;
class TeacherDashboardService
{
public function __construct(private TeacherConfigService $configService) {}
public function __construct(private TeacherConfigService $configService)
{
}
public function classView(int $userId, ?int $requestedClassSectionId = null): array
{
@@ -27,7 +29,7 @@ class TeacherDashboardService
->map(fn ($r) => strtolower((string) $r))
->all();
if (! array_intersect($roles, ['teacher', 'teacher_assistant'])) {
if (!array_intersect($roles, ['teacher', 'teacher_assistant'])) {
throw new \RuntimeException('Access denied.');
}
@@ -48,24 +50,24 @@ class TeacherDashboardService
$activeClassSectionId = null;
if ($requestedClassSectionId && in_array($requestedClassSectionId, $classSectionIds, true)) {
$activeClassSectionId = $requestedClassSectionId;
} elseif (! empty($classSectionIds)) {
} elseif (!empty($classSectionIds)) {
$activeClassSectionId = $classSectionIds[0];
}
$studentsBySection = [];
if (! empty($classSectionIds)) {
if (!empty($classSectionIds)) {
$students = StudentClass::getStudentsByClassSectionIds($classSectionIds);
if (! empty($students)) {
if (!empty($students)) {
$studentIds = array_values(array_unique(array_map(
static fn (array $row) => (int) ($row['student_id'] ?? 0),
$students
)));
$studentIds = array_values(array_filter($studentIds));
$conditionsByStudent = ! empty($studentIds)
$conditionsByStudent = !empty($studentIds)
? StudentMedicalCondition::getMedicalByStudentIds($studentIds)
: [];
$allergiesByStudent = ! empty($studentIds)
$allergiesByStudent = !empty($studentIds)
? StudentAllergy::getAllergiesByStudentIds($studentIds)
: [];
@@ -87,7 +89,7 @@ class TeacherDashboardService
}
$assignedNames = [];
if (! empty($classSectionIds)) {
if (!empty($classSectionIds)) {
$rows = DB::table('teacher_class as tc')
->select('tc.class_section_id', 'tc.position', 'u.firstname', 'u.lastname')
->join('users as u', 'u.id', '=', 'tc.teacher_id')
@@ -101,7 +103,7 @@ class TeacherDashboardService
foreach ($rows as $row) {
$sid = (int) ($row->class_section_id ?? 0);
$pos = strtolower((string) ($row->position ?? ''));
$name = trim(($row->firstname ?? '').' '.($row->lastname ?? ''));
$name = trim(($row->firstname ?? '') . ' ' . ($row->lastname ?? ''));
if ($sid === 0 || $name === '') {
continue;
}