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,7 +13,8 @@ class AdministratorAbsenceController extends Controller
{
public function __construct(
protected AdministratorAbsenceService $service
) {}
) {
}
public function index(): JsonResponse
{
@@ -33,7 +34,7 @@ class AdministratorAbsenceController extends Controller
}
$payload = $request->all();
if (! array_key_exists('dates', $payload) || ! array_key_exists('reason', $payload)) {
if (!array_key_exists('dates', $payload) || !array_key_exists('reason', $payload)) {
$json = json_decode($request->getContent() ?: '', true);
if (is_array($json)) {
$payload = array_merge($payload, $json);
@@ -11,7 +11,8 @@ class AdministratorDashboardController extends Controller
{
public function __construct(
protected AdministratorDashboardService $service
) {}
) {
}
public function metrics(): JsonResponse
{
@@ -24,4 +25,4 @@ class AdministratorDashboardController extends Controller
$this->service->userSearch((string) $request->query('query', ''))
);
}
}
}
@@ -14,7 +14,8 @@ class AdministratorEnrollmentController extends Controller
{
public function __construct(
protected AdministratorEnrollmentService $service
) {}
) {
}
public function index(Request $request): JsonResponse
{
@@ -38,13 +39,13 @@ class AdministratorEnrollmentController extends Controller
}
$payload = $request->all();
if (! array_key_exists('enrollment_status', $payload)) {
if (!array_key_exists('enrollment_status', $payload)) {
$json = json_decode($request->getContent() ?: '', true);
if (is_array($json) && array_key_exists('enrollment_status', $json)) {
$payload['enrollment_status'] = $json['enrollment_status'];
}
}
if (! array_key_exists('enrollment_status', $payload)) {
if (!array_key_exists('enrollment_status', $payload)) {
$payload['enrollment_status'] = $request->query('enrollment_status');
}
@@ -12,7 +12,8 @@ class AdministratorNotificationController extends Controller
{
public function __construct(
protected AdministratorNotificationService $service
) {}
) {
}
public function alerts(): JsonResponse
{
@@ -22,7 +23,7 @@ class AdministratorNotificationController extends Controller
public function saveAlerts(Request $request): JsonResponse
{
$payload = $request->all();
if (! array_key_exists('subjects', $payload)) {
if (!array_key_exists('subjects', $payload)) {
$json = json_decode($request->getContent() ?: '', true);
if (is_array($json)) {
$payload = array_merge($payload, $json);
@@ -59,7 +60,7 @@ class AdministratorNotificationController extends Controller
public function savePrintRecipients(Request $request): JsonResponse
{
$payload = $request->all();
if (! array_key_exists('notify', $payload)) {
if (!array_key_exists('notify', $payload)) {
$json = json_decode($request->getContent() ?: '', true);
if (is_array($json)) {
$payload = array_merge($payload, $json);
@@ -16,18 +16,18 @@ use App\Http\Resources\Promotions\PromotionReminderResource;
use App\Http\Resources\Promotions\StudentPromotionResource;
use App\Models\PromotionAuditLog;
use App\Models\PromotionReminderLog;
use App\Models\SectionPlacementBatch;
use App\Models\StudentPromotionRecord;
use App\Services\Promotions\LevelProgressionService;
use App\Services\Promotions\Placement\SectionPlacementPreviewService;
use App\Services\Promotions\PromotionAuditService;
use App\Services\Promotions\PromotionEligibilityService;
use App\Services\Promotions\PromotionEnrollmentService;
use App\Services\Promotions\PromotionQueryService;
use App\Services\Promotions\PromotionReminderService;
use App\Services\Promotions\PromotionStatusService;
use Illuminate\Http\JsonResponse;
use App\Services\Promotions\Placement\SectionPlacementPreviewService;
use App\Models\SectionPlacementBatch;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpFoundation\Response;
@@ -54,7 +54,6 @@ class AdministratorPromotionController extends BaseApiController
public function index(AdminListPromotionsRequest $request): JsonResponse
{
$result = $this->query->list($request->filters());
return response()->json([
'ok' => true,
'data' => StudentPromotionResource::collection($result['data']),
@@ -74,7 +73,6 @@ class AdministratorPromotionController extends BaseApiController
if ($record instanceof JsonResponse) {
return $record;
}
return response()->json([
'ok' => true,
'data' => new StudentPromotionResource($this->query->detail($record)),
@@ -84,7 +82,6 @@ class AdministratorPromotionController extends BaseApiController
public function summary(AdminListPromotionsRequest $request): JsonResponse
{
$counts = $this->query->countsByStatus($request->filters());
return response()->json([
'ok' => true,
'counts_by_status' => $counts,
@@ -128,7 +125,6 @@ class AdministratorPromotionController extends BaseApiController
};
} catch (\Throwable $e) {
Log::error('Promotion eligibility evaluation failed', ['exception' => $e]);
return response()->json([
'ok' => false,
'message' => 'Failed to evaluate promotion eligibility.',
@@ -141,6 +137,7 @@ class AdministratorPromotionController extends BaseApiController
]);
}
public function createPlacementPreview(Request $request): JsonResponse
{
$payload = $request->validate([
@@ -160,7 +157,6 @@ class AdministratorPromotionController extends BaseApiController
);
} catch (\Throwable $e) {
Log::error('Section placement preview generation failed', ['exception' => $e]);
return response()->json([
'ok' => false,
'message' => $e->getMessage(),
@@ -176,7 +172,7 @@ class AdministratorPromotionController extends BaseApiController
public function showPlacementBatch(int $batchId): JsonResponse
{
$batch = SectionPlacementBatch::query()->find($batchId);
if (! $batch) {
if (!$batch) {
return response()->json(['ok' => false, 'message' => 'Placement batch not found.'], Response::HTTP_NOT_FOUND);
}
@@ -192,7 +188,6 @@ class AdministratorPromotionController extends BaseApiController
$batch = $this->sectionPlacement->finalize($batchId, $this->getCurrentUserId());
} catch (\Throwable $e) {
Log::error('Section placement finalization failed', ['batch_id' => $batchId, 'exception' => $e]);
return response()->json([
'ok' => false,
'message' => $e->getMessage(),
@@ -216,7 +211,7 @@ class AdministratorPromotionController extends BaseApiController
$userId = $this->getCurrentUserId();
try {
$updated = ! empty($payload['force'])
$updated = !empty($payload['force'])
? $this->statusService->forceStatus($record, $payload['status'], $userId, $payload['notes'] ?? null)
: $this->statusService->transition($record, $payload['status'], $userId, $payload['notes'] ?? null);
} catch (\InvalidArgumentException $e) {
@@ -249,7 +244,7 @@ class AdministratorPromotionController extends BaseApiController
return $record;
}
$records = collect([$record]);
} elseif ($applyTo === 'filter' && ! empty($payload['promotion_ids'])) {
} elseif ($applyTo === 'filter' && !empty($payload['promotion_ids'])) {
$records = StudentPromotionRecord::query()
->whereIn('promotion_id', $payload['promotion_ids'])
->get();
@@ -310,7 +305,6 @@ class AdministratorPromotionController extends BaseApiController
'promotion_id' => $promotionId,
'exception' => $e,
]);
return response()->json([
'ok' => false,
'message' => 'Failed to send reminder.',
@@ -327,7 +321,6 @@ class AdministratorPromotionController extends BaseApiController
{
$userId = $this->getCurrentUserId();
$result = $this->reminders->dispatchScheduledReminders(null, $userId);
return response()->json([
'ok' => true,
'result' => $result,
@@ -344,7 +337,6 @@ class AdministratorPromotionController extends BaseApiController
->forPromotion((int) $record->getKey())
->orderByDesc('id')
->get();
return response()->json([
'ok' => true,
'reminders' => PromotionReminderResource::collection($rows),
@@ -361,7 +353,6 @@ class AdministratorPromotionController extends BaseApiController
->forPromotion((int) $record->getKey())
->orderByDesc('id')
->get();
return response()->json([
'ok' => true,
'entries' => PromotionAuditLogResource::collection($rows),
@@ -371,7 +362,6 @@ class AdministratorPromotionController extends BaseApiController
public function expireDeadlines(): JsonResponse
{
$result = $this->enrollmentService->markExpiredDeadlines(null, $this->getCurrentUserId());
return response()->json([
'ok' => true,
'result' => $result,
@@ -414,7 +404,6 @@ class AdministratorPromotionController extends BaseApiController
public function levelProgressions(): JsonResponse
{
$rows = $this->progression->list(false);
return response()->json([
'ok' => true,
'levels' => LevelProgressionResource::collection($rows),
@@ -424,7 +413,6 @@ class AdministratorPromotionController extends BaseApiController
public function upsertLevelProgression(UpsertLevelProgressionRequest $request): JsonResponse
{
$row = $this->progression->upsertMapping($request->validated());
return response()->json([
'ok' => true,
'level' => new LevelProgressionResource($row),
@@ -434,7 +422,6 @@ class AdministratorPromotionController extends BaseApiController
public function seedLevelProgressions(): JsonResponse
{
$created = $this->progression->seedDefaults();
return response()->json([
'ok' => true,
'created' => $created,
@@ -444,13 +431,12 @@ class AdministratorPromotionController extends BaseApiController
private function findOrFail(int $promotionId): StudentPromotionRecord|JsonResponse
{
$record = StudentPromotionRecord::query()->find($promotionId);
if (! $record) {
if (!$record) {
return response()->json([
'ok' => false,
'message' => 'Promotion record not found.',
], Response::HTTP_NOT_FOUND);
}
return $record;
}
}
@@ -13,7 +13,8 @@ class AdministratorTeacherSubmissionController extends Controller
{
public function __construct(
protected AdministratorTeacherSubmissionService $service
) {}
) {
}
public function index(Request $request): JsonResponse
{
@@ -18,7 +18,8 @@ class EmergencyContactController extends Controller
public function __construct(
private EmergencyContactDirectoryService $directoryService,
private EmergencyContactCrudService $crudService
) {}
) {
}
public function index(Request $request): JsonResponse
{
@@ -37,10 +38,10 @@ class EmergencyContactController extends Controller
$payload = $validator->validated();
$parentIds = [];
if (! empty($payload['parent_ids'])) {
if (!empty($payload['parent_ids'])) {
$parentIds = array_values(array_unique(array_map('intval', $payload['parent_ids'])));
}
if (! empty($payload['parent_id'])) {
if (!empty($payload['parent_id'])) {
$parentIds[] = (int) $payload['parent_id'];
}
$parentIds = array_values(array_unique(array_filter($parentIds)));
@@ -61,6 +61,9 @@ class TeacherClassAssignmentController extends BaseApiController
], $status);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);