fix gitlab tests
This commit is contained in:
@@ -4,7 +4,6 @@ namespace App\Services\Exams;
|
||||
|
||||
use App\Models\ClassSection;
|
||||
use App\Models\ExamDraft;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ExamDraftAdminService
|
||||
@@ -12,7 +11,8 @@ class ExamDraftAdminService
|
||||
public function __construct(
|
||||
private ExamDraftConfigService $configService,
|
||||
private ExamDraftFileService $fileService
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function list(): array
|
||||
{
|
||||
@@ -29,7 +29,7 @@ class ExamDraftAdminService
|
||||
|
||||
if ($teacherUserColumn !== '') {
|
||||
$draftsQuery
|
||||
->leftJoin('users as u', 'u.id', '=', "ed.{$teacherUserColumn}")
|
||||
->leftJoin('users as u', "u.id", '=', "ed.{$teacherUserColumn}")
|
||||
->addSelect(
|
||||
'u.firstname as teacher_first',
|
||||
'u.lastname as teacher_last'
|
||||
@@ -82,15 +82,15 @@ class ExamDraftAdminService
|
||||
$legacyByClass = [];
|
||||
if ($context['has_legacy'] ?? false) {
|
||||
foreach ($drafts as $row) {
|
||||
$isLegacy = ! empty($row['is_legacy']);
|
||||
if (! $isLegacy) {
|
||||
$isLegacy = !empty($row['is_legacy']);
|
||||
if (!$isLegacy) {
|
||||
continue;
|
||||
}
|
||||
$cid = (int) ($row['class_section_id'] ?? 0);
|
||||
if (! isset($legacyByClass[$cid])) {
|
||||
if (!isset($legacyByClass[$cid])) {
|
||||
$legacyByClass[$cid] = [
|
||||
'class_section_id' => $cid,
|
||||
'class_section_name' => $row['class_section_name'] ?? 'Class '.$cid,
|
||||
'class_section_name' => $row['class_section_name'] ?? 'Class ' . $cid,
|
||||
'items' => [],
|
||||
];
|
||||
}
|
||||
@@ -111,7 +111,7 @@ class ExamDraftAdminService
|
||||
];
|
||||
}
|
||||
|
||||
public function uploadLegacy(int $adminId, array $payload, UploadedFile $file): array
|
||||
public function uploadLegacy(int $adminId, array $payload, \Illuminate\Http\UploadedFile $file): array
|
||||
{
|
||||
$context = $this->configService->context();
|
||||
$adminUserColumn = (string) ($context['admin_user_column'] ?? '');
|
||||
@@ -148,7 +148,7 @@ class ExamDraftAdminService
|
||||
|
||||
$finalFilename = $stored['extension'] === 'pdf'
|
||||
? $stored['original']
|
||||
: (pathinfo($stored['original'], PATHINFO_FILENAME).'.pdf');
|
||||
: (pathinfo($stored['original'], PATHINFO_FILENAME) . '.pdf');
|
||||
|
||||
$payload = [
|
||||
'class_section_id' => $classSectionId,
|
||||
@@ -193,7 +193,7 @@ class ExamDraftAdminService
|
||||
return ['ok' => true, 'draft' => $draft->toArray()];
|
||||
}
|
||||
|
||||
public function review(int $adminId, array $payload, ?UploadedFile $file): array
|
||||
public function review(int $adminId, array $payload, ?\Illuminate\Http\UploadedFile $file): array
|
||||
{
|
||||
$draftId = (int) ($payload['draft_id'] ?? 0);
|
||||
if ($draftId <= 0) {
|
||||
@@ -201,7 +201,7 @@ class ExamDraftAdminService
|
||||
}
|
||||
|
||||
$draft = ExamDraft::query()->find($draftId);
|
||||
if (! $draft) {
|
||||
if (!$draft) {
|
||||
return ['ok' => false, 'message' => 'Submission not found.'];
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ class ExamDraftAdminService
|
||||
$statusInput = trim((string) ($payload['review_status'] ?? ''));
|
||||
$currentStatus = (string) ($draft->status ?? 'draft');
|
||||
$status = $this->normalizeStatus($statusInput !== '' ? $statusInput : $currentStatus, $currentStatus);
|
||||
if (! in_array($status, ExamDraftConfigService::STATUS_OPTIONS, true)) {
|
||||
if (!in_array($status, ExamDraftConfigService::STATUS_OPTIONS, true)) {
|
||||
$status = 'reviewed';
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ class ExamDraftAdminService
|
||||
if ($pdfName !== null && ($this->configService->context()['has_final_pdf'] ?? false)) {
|
||||
$update['final_pdf_file'] = $pdfName;
|
||||
}
|
||||
} elseif ($status === 'finalized' && ! empty($draft->teacher_file ?: $draft->author_file)) {
|
||||
} elseif ($status === 'finalized' && !empty($draft->teacher_file ?: $draft->author_file)) {
|
||||
$copied = $this->fileService->copyDraftToFinal(
|
||||
(string) ($draft->teacher_file ?? $draft->author_file),
|
||||
ExamDraftConfigService::TEACHER_UPLOAD_DIR,
|
||||
@@ -297,7 +297,6 @@ class ExamDraftAdminService
|
||||
if (isset($aliases[$input])) {
|
||||
$input = $aliases[$input];
|
||||
}
|
||||
|
||||
return in_array($input, ExamDraftConfigService::STATUS_OPTIONS, true) ? $input : $default;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user