From 745cf2431a71d0e6c5f08f8605839279b2f7496e Mon Sep 17 00:00:00 2001 From: Devian Date: Thu, 22 Apr 2021 17:03:46 +0800 Subject: Initiate commit --- src/Entity/Sco.php | 270 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 src/Entity/Sco.php (limited to 'src/Entity/Sco.php') diff --git a/src/Entity/Sco.php b/src/Entity/Sco.php new file mode 100644 index 0000000..75eec2b --- /dev/null +++ b/src/Entity/Sco.php @@ -0,0 +1,270 @@ + $this->getId(), + 'scorm' => $this->getScorm(), + 'scoParent' => $this->getScoParent(), + 'entryUrl' => $this->getEntryUrl(), + 'identifier' => $this->getIdentifier(), + + ]; + } + + public function getUuid() + { + return $this->uuid; + } + + public function setUuid($uuid) + { + $this->uuid = $uuid; + } + + public function getId() + { + return $this->id; + } + + public function setId($id) + { + $this->id = $id; + } + + public function getScorm() + { + return $this->scorm; + } + + public function setScorm(Scorm $scorm = null) + { + $this->scorm = $scorm; + } + + public function getScoParent() + { + return $this->scoParent; + } + + public function setScoParent(Sco $scoParent = null) + { + $this->scoParent = $scoParent; + } + + public function getScoChildren() + { + return $this->scoChildren; + } + + public function setScoChildren($scoChildren) + { + $this->scoChildren = $scoChildren; + } + + public function getEntryUrl() + { + return $this->entryUrl; + } + + public function setEntryUrl($entryUrl) + { + $this->entryUrl = $entryUrl; + } + + public function getIdentifier() + { + return $this->identifier; + } + + public function setIdentifier($identifier) + { + $this->identifier = $identifier; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + } + + public function isVisible() + { + return $this->visible; + } + + public function setVisible($visible) + { + $this->visible = $visible; + } + + public function getParameters() + { + return $this->parameters; + } + + public function setParameters($parameters) + { + $this->parameters = $parameters; + } + + public function getLaunchData() + { + return $this->launchData; + } + + public function setLaunchData($launchData) + { + $this->launchData = $launchData; + } + + public function getMaxTimeAllowed() + { + return $this->maxTimeAllowed; + } + + public function setMaxTimeAllowed($maxTimeAllowed) + { + $this->maxTimeAllowed = $maxTimeAllowed; + } + + public function getTimeLimitAction() + { + return $this->timeLimitAction; + } + + public function setTimeLimitAction($timeLimitAction) + { + $this->timeLimitAction = $timeLimitAction; + } + + public function isBlock() + { + return $this->block; + } + + public function setBlock($block) + { + $this->block = $block; + } + + public function getScoreToPass() + { + if (Scorm::SCORM_2004 === $this->scorm->getVersion()) { + return $this->scoreToPassDecimal; + } else { + return $this->scoreToPassInt; + } + } + + public function setScoreToPass($scoreToPass) + { + if (Scorm::SCORM_2004 === $this->scorm->getVersion()) { + $this->setScoreToPassDecimal($scoreToPass); + } else { + $this->setScoreToPassInt($scoreToPass); + } + } + + public function getScoreToPassInt() + { + return $this->scoreToPassInt; + } + + public function setScoreToPassInt($scoreToPassInt) + { + $this->scoreToPassInt = $scoreToPassInt; + } + + public function getScoreToPassDecimal() + { + return $this->scoreToPassDecimal; + } + + public function setScoreToPassDecimal($scoreToPassDecimal) + { + $this->scoreToPassDecimal = $scoreToPassDecimal; + } + + public function getCompletionThreshold() + { + return $this->completionThreshold; + } + + public function setCompletionThreshold($completionThreshold) + { + $this->completionThreshold = $completionThreshold; + } + + public function getPrerequisites() + { + return $this->prerequisites; + } + + public function setPrerequisites($prerequisites) + { + $this->prerequisites = $prerequisites; + } + + /** + * @return array + */ + public function serialize(Sco $sco) + { + $scorm = $sco->getScorm(); + $parent = $sco->getScoParent(); + + return [ + 'id' => $sco->getUuid(), + 'scorm' => !empty($scorm) ? ['id' => $scorm->getUuid()] : null, + 'data' => [ + 'entryUrl' => $sco->getEntryUrl(), + 'identifier' => $sco->getIdentifier(), + 'title' => $sco->getTitle(), + 'visible' => $sco->isVisible(), + 'parameters' => $sco->getParameters(), + 'launchData' => $sco->getLaunchData(), + 'maxTimeAllowed' => $sco->getMaxTimeAllowed(), + 'timeLimitAction' => $sco->getTimeLimitAction(), + 'block' => $sco->isBlock(), + 'scoreToPassInt' => $sco->getScoreToPassInt(), + 'scoreToPassDecimal' => $sco->getScoreToPassDecimal(), + 'scoreToPass' => !empty($scorm) ? $sco->getScoreToPass() : null, + 'completionThreshold' => $sco->getCompletionThreshold(), + 'prerequisites' => $sco->getPrerequisites(), + ], + 'parent' => !empty($parent) ? ['id' => $parent->getUuid()] : null, + 'children' => array_map(function (Sco $scoChild) { + return $this->serialize($scoChild); + }, is_array($sco->getScoChildren()) ? $sco->getScoChildren() : $sco->getScoChildren()->toArray()), + ]; + } +} -- cgit v1.2.3