fix parent pages and teachers and admin
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped

This commit is contained in:
root
2026-07-09 13:56:22 -04:00
parent 21c9322127
commit 02ba2fe6b6
34 changed files with 2306 additions and 99 deletions
@@ -9,6 +9,8 @@ use App\Services\Files\ExamDraftDownloadNameService;
use App\Services\Files\FileServeService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class FilesController extends BaseApiController
{
@@ -71,6 +73,7 @@ class FilesController extends BaseApiController
public function examDraftFinal(FileNameRequest $request, string $name): Response|JsonResponse
{
$name = $this->resolveFinalExamFileName($name);
$downloadName = $this->draftNameService->build($name, 'finals');
return $this->serveFile(
@@ -102,4 +105,37 @@ class FilesController extends BaseApiController
return $this->fileService->serveInline($baseDir, $name, $allowedExtensions, $request, $downloadName, $nosniff);
}
private function resolveFinalExamFileName(string $name): string
{
if (! ctype_digit($name) || ! Schema::hasTable('exam_drafts')) {
return $name;
}
$query = DB::table('exam_drafts')->where('id', (int) $name);
if (Schema::hasColumn('exam_drafts', 'final_pdf_file')) {
$query->select('final_file', 'final_pdf_file');
} else {
$query->select('final_file');
}
$row = $query->first();
if (! $row) {
return $name;
}
$pdfFile = trim((string) ($row->final_pdf_file ?? ''));
if ($this->looksLikeExamFileName($pdfFile)) {
return $pdfFile;
}
$finalFile = trim((string) ($row->final_file ?? ''));
return $this->looksLikeExamFileName($finalFile) ? $finalFile : $name;
}
private function looksLikeExamFileName(string $name): bool
{
return preg_match('/\.(doc|docx|pdf)\z/i', $name) === 1;
}
}