diff options
Diffstat (limited to 'src/Manager/ScormManager.php')
| -rw-r--r-- | src/Manager/ScormManager.php | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/Manager/ScormManager.php b/src/Manager/ScormManager.php index d403d1e..abf1e26 100644 --- a/src/Manager/ScormManager.php +++ b/src/Manager/ScormManager.php @@ -42,15 +42,15 @@ 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) { @@ -69,14 +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); } @@ -117,8 +110,7 @@ class ScormManager } // This uuid is use when the admin wants to edit existing scorm file. - if (!empty($uuid)) - { + if (!empty($uuid)) { $this->uuid = $uuid; // Overwrite system generated uuid } @@ -136,8 +128,9 @@ class ScormManager * Handle dynamic method calls into the method. * return $this->dynamicWhere($method, $parameters); **/ + // $scorm = ScormModel::whereOriginFile($filename); // Uuid indicator is better than filename for update content or add new content. - $scorm = ScormModel::whereUuid($this->uuid); + $scorm = ScormModel::where('uuid', $this->uuid); // Check if scom package already exists to drop old one. if (!$scorm->exists()) { @@ -408,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(), @@ -608,7 +601,8 @@ class ScormManager $tracking->setLessonStatus($lessonStatus); $bestStatus = $lessonStatus; - if (empty($tracking->getCompletionStatus()) + if ( + empty($tracking->getCompletionStatus()) || ($completionStatus !== $tracking->getCompletionStatus() && $statusPriority[$completionStatus] > $statusPriority[$tracking->getCompletionStatus()]) ) { // This is no longer needed as completionStatus and successStatus are merged together @@ -656,7 +650,8 @@ class ScormManager return $updateResult; } - public function resetUserData($scormId, $userId) { + public function resetUserData($scormId, $userId) + { $scos = ScormScoModel::where('scorm_id', $scormId)->get(); foreach ($scos as $sco) { |
