diff options
| author | Khaled Lela <eng.khaled.lela@gmail.com> | 2023-05-08 14:50:05 +0300 |
|---|---|---|
| committer | Khaled Lela <eng.khaled.lela@gmail.com> | 2023-05-08 14:50:05 +0300 |
| commit | b9f46baefcfaf2890dc3cfa5d1d7fe3f547f0e19 (patch) | |
| tree | b3feb58bdf6b05ddb86c2eab2b29a27c940d4cd5 /src | |
| parent | d87753ffbbbc5eb75e20f8aa0cb39faed8f34863 (diff) | |
handle scorm with identifer
Diffstat (limited to 'src')
| -rw-r--r-- | src/Manager/ScormManager.php | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/Manager/ScormManager.php b/src/Manager/ScormManager.php index d403d1e..bb502f4 100644 --- a/src/Manager/ScormManager.php +++ b/src/Manager/ScormManager.php @@ -42,16 +42,12 @@ 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)) - { + if (!empty($uuid)) { $this->uuid = $uuid; - } - else - { + } else { $this->uuid = Str::uuid(); } - $scorm = null; $this->scormDisk->readScormArchive($file, function ($path) use (&$scorm, $file, $uuid) { $filename = basename($file); @@ -69,12 +65,9 @@ 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)) - { + if (!empty($uuid)) { $this->uuid = $uuid; - } - else - { + } else { $this->uuid = Str::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,11 @@ 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::whereUuid($this->uuid); // Check if scom package already exists to drop old one. if (!$scorm->exists()) { @@ -608,7 +603,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 +652,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) { |
