diff options
| author | Khaled Lela <eng.khaled.lela@gmail.com> | 2025-08-14 13:10:00 +0300 |
|---|---|---|
| committer | Khaled Lela <eng.khaled.lela@gmail.com> | 2025-08-14 13:10:00 +0300 |
| commit | 924c72de0af5fd00ae171189788b8a713472afba (patch) | |
| tree | 1df34a0f14de0cedd9013d5ee51b7bdd7f35a8b4 /src/Manager/ScormManager.php | |
| parent | 70f8710355ec0a91d279b12a2c0e74083dc6e7b6 (diff) | |
Enhance SCORM file handling with improved error logging and validation. Added checks for disk accessibility and file existence in readScormArchive method. Updated uuid assignment logic in uploadScormFromUri and uploadScormArchive methods.
Diffstat (limited to 'src/Manager/ScormManager.php')
| -rw-r--r-- | src/Manager/ScormManager.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Manager/ScormManager.php b/src/Manager/ScormManager.php index 2dcaa5e..abf1e26 100644 --- a/src/Manager/ScormManager.php +++ b/src/Manager/ScormManager.php @@ -42,12 +42,16 @@ class ScormManager public function uploadScormFromUri($file, $uuid = null) { // $uuid is meant for user to update scorm content. Hence, if user want to update content should parse in existing uuid - if (!empty($uuid)) { - $this->uuid = $uuid; - } else { - $this->uuid = Str::uuid(); + $this->uuid = $uuid ?? Str::uuid()->toString(); + + // Validate that the file parameter is not empty + if (empty($file)) { + throw new InvalidScormArchiveException('file_parameter_empty'); } + // Log the file being processed for debugging + \Log::info('Uploading SCORM from URI: ' . $file); + $scorm = null; $this->scormDisk->readScormArchive($file, function ($path) use (&$scorm, $file, $uuid) { $filename = basename($file); @@ -65,11 +69,7 @@ class ScormManager public function uploadScormArchive(UploadedFile $file, $uuid = null) { // $uuid is meant for user to update scorm content. Hence, if user want to update content should parse in existing uuid - if (!empty($uuid)) { - $this->uuid = $uuid; - } else { - $this->uuid = Str::uuid(); - } + $this->uuid = $uuid ?? Str::uuid()->toString(); return $this->saveScorm($file, $file->getClientOriginalName(), $uuid); } @@ -401,7 +401,7 @@ class ScormManager 'user_id' => $userId, 'sco_id' => $sco->id ], [ - 'uuid' => Str::uuid(), + 'uuid' => Str::uuid()->toString(), 'progression' => $scoTracking->getProgression(), 'score_raw' => $scoTracking->getScoreRaw(), 'score_min' => $scoTracking->getScoreMin(), |
