/** * Copy given sco and its children. * * @param Scorm12Sco $sco * @param Scorm12Resource $resource * @param Scorm12Sco $scoParent */ private function copySco(Scorm12Sco $sco, Scorm12Resource $resource, Scorm12Sco $scoParent = null) { $scoCopy = new Scorm12Sco(); $scoCopy->setScormResource($resource); $scoCopy->setScoParent($scoParent); $scoCopy->setEntryUrl($sco->getEntryUrl()); $scoCopy->setIdentifier($sco->getIdentifier()); $scoCopy->setIsBlock($sco->getIsBlock()); $scoCopy->setLaunchData($sco->getLaunchData()); $scoCopy->setMasteryScore($sco->getMasteryScore()); $scoCopy->setMaxTimeAllowed($sco->getMaxTimeAllowed()); $scoCopy->setParameters($sco->getParameters()); $scoCopy->setPrerequisites($sco->getPrerequisites()); $scoCopy->setTimeLimitAction($sco->getTimeLimitAction()); $scoCopy->setTitle($sco->getTitle()); $scoCopy->setVisible($sco->isVisible()); $this->om->persist($scoCopy); foreach ($sco->getScoChildren() as $scoChild) { $this->copySco($scoChild, $resource, $scoCopy); } }
/** * Initializes parameters of the SCO defined in attributes of the node. * It also look for the associated resource if it is a SCO and not a block. * * @param Scorm12Sco $sco * @param \DOMNode $item * @param \DOMNodeList $resources * * @throws InvalidScormArchiveException */ private function findAttrParams(Scorm12Sco $sco, \DOMNode $item, \DOMNodeList $resources) { $identifier = $item->attributes->getNamedItem('identifier'); $isVisible = $item->attributes->getNamedItem('isvisible'); $identifierRef = $item->attributes->getNamedItem('identifierref'); $parameters = $item->attributes->getNamedItem('parameters'); // throws an Exception if identifier is undefined if (is_null($identifier)) { throw new InvalidScormArchiveException('sco_with_no_identifier_message'); } $sco->setIdentifier($identifier->nodeValue); // visible is true by default if (!is_null($isVisible) && $isVisible === 'false') { $sco->setVisible(false); } else { $sco->setVisible(true); } // set parameters for SCO entry resource if (!is_null($parameters)) { $sco->setParameters($parameters->nodeValue); } // check if item is a block or a SCO. A block doesn't define identifierref if (is_null($identifierRef)) { $sco->setIsBlock(true); } else { $sco->setIsBlock(false); // retrieve entry URL $sco->setEntryUrl($this->findEntryUrl($identifierRef->nodeValue, $resources)); } }