summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Lela <eng.khaled.lela@gmail.com>2022-02-10 01:17:43 +0200
committerKhaled Lela <eng.khaled.lela@gmail.com>2022-02-10 01:17:43 +0200
commitf658708e0ba11ced12a395b848cc13771db2628b (patch)
tree5f5e1a68c071ad9c02bf79e077001d8e4355a710
parent9e6f0a90b6b99d7a08fbe07ecd9c304b825f3a16 (diff)
update scorm model
-rw-r--r--database/migrations/create_scorm_tables.php.stub14
-rw-r--r--src/Entity/Scorm.php35
-rw-r--r--src/Manager/ScormManager.php20
3 files changed, 39 insertions, 30 deletions
diff --git a/database/migrations/create_scorm_tables.php.stub b/database/migrations/create_scorm_tables.php.stub
index 506e9cb..6a136b3 100644
--- a/database/migrations/create_scorm_tables.php.stub
+++ b/database/migrations/create_scorm_tables.php.stub
@@ -97,19 +97,7 @@ class CreateScormTables extends Migration
*/
public function down()
{
- $tableNames = config('scorm_sco_tracking_table');
-
- if (empty($tableNames)) {
- throw new \Exception('Error: Table not found.');
- }
-
- $tableNames = config('scorm_sco_table');
-
- if (empty($tableNames)) {
- throw new \Exception('Error: Table not found.');
- }
-
- $tableNames = config('scorm_table');
+ $tableNames = config('scorm.table_names');
if (empty($tableNames)) {
throw new \Exception('Error: Table not found.');
diff --git a/src/Entity/Scorm.php b/src/Entity/Scorm.php
index 4095986..48fd711 100644
--- a/src/Entity/Scorm.php
+++ b/src/Entity/Scorm.php
@@ -3,9 +3,6 @@
namespace Peopleaps\Scorm\Entity;
-
-use Doctrine\Common\Collections\ArrayCollection;
-
class Scorm
{
const SCORM_12 = 'scorm_12';
@@ -13,8 +10,9 @@ class Scorm
public $uuid;
public $id;
+ public $title;
public $version;
- public $hashName;
+ public $entryUrl;
public $ratio = 56.25;
public $scos;
public $scoSerializer;
@@ -70,17 +68,33 @@ class Scorm
/**
* @return string
*/
- public function getHashName()
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * @param string $title
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ }
+
+ /**
+ * @return string
+ */
+ public function getEntryUrl()
{
- return $this->hashName;
+ return $this->entryUrl;
}
/**
- * @param string $hashName
+ * @param string $title
*/
- public function setHashName($hashName)
+ public function setEntryUrl($entryUrl)
{
- $this->hashName = $hashName;
+ $this->entryUrl = $entryUrl;
}
/**
@@ -131,7 +145,8 @@ class Scorm
return [
'id' => $scorm->getUuid(),
'version' => $scorm->getVersion(),
- 'hashName' => $scorm->getHashName(),
+ 'title' => $scorm->getTitle(),
+ 'entryUrl' => $scorm->getEntryUrl(),
'ratio' => $scorm->getRatio(),
'scos' => $this->serializeScos($scorm),
];
diff --git a/src/Manager/ScormManager.php b/src/Manager/ScormManager.php
index 4e9e9c5..2b901ab 100644
--- a/src/Manager/ScormManager.php
+++ b/src/Manager/ScormManager.php
@@ -68,11 +68,11 @@ class ScormManager
$this->deleteScormData($scorm);
}
+ $scorm->uuid = $scormData['uuid'];
+ $scorm->title = $scormData['title'];
$scorm->version = $scormData['version'];
- $scorm->hash_name = $scormData['hashName'];
+ $scorm->entryUrl = $scormData['entryUrl'];
$scorm->origin_file = $scormData['identifier'];
- $scorm->origin_file_mime = $scormData['type'];
- $scorm->uuid = $scormData['hashName'];
$scorm->save();
if (!empty($scormData['scos']) && is_array($scormData['scos'])) {
@@ -134,6 +134,10 @@ class ScormManager
} else {
throw new InvalidScormArchiveException('invalid_scorm_manifest_identifier');
}
+ $titles = $dom->getElementsByTagName('title');
+ if ($titles->length > 0) {
+ $data['title'] = $titles->item(0)->textContent;
+ }
$scormVersionElements = $dom->getElementsByTagName('schemaversion');
if ($scormVersionElements->length > 0) {
@@ -157,6 +161,8 @@ class ScormManager
if (0 >= count($scos)) {
throw new InvalidScormArchiveException('no_sco_in_scorm_archive_message');
}
+
+ $data['entryUrl'] = $scos[0]->entryUrl;
$data['scos'] = $scos;
return $data;
@@ -182,7 +188,7 @@ class ScormManager
}
$model->scos()->delete(); // delete scos
// Delete folder from server
- $this->deleteScormFolder($model->hash_name);
+ $this->deleteScormFolder($model->title);
}
/**
@@ -212,10 +218,10 @@ class ScormManager
return [
'identifier' => $scormData['identifier'],
- // 'name' => $hashFileName, // to follow standard file data format
- 'hashName' => $uuid,
- 'type' => $file->getMimeType(),
+ 'uuid' => $uuid,
+ 'title' => $scormData['title'], // to follow standard file data format
'version' => $scormData['version'],
+ 'entryUrl' => $scormData['entryUrl'],
'scos' => $scormData['scos'],
];
}