plugin/scorm/Manager/ExportManager.php
public function createPackage(ResourceNode $node, $locale, AbstractScormManifest $manifest, array $scos = [])
    {
        $scormId = 'scorm-'.$node->getId().'-'.date('YmdHis');

        // Create and open scorm archive
        if (!is_dir($this->tmpPath)) {
            mkdir($this->tmpPath);
        }

        $archive = new \ZipArchive();
        $archive->open($this->tmpPath.DIRECTORY_SEPARATOR.$scormId.'.zip', \ZipArchive::CREATE);

        // Add manifest
        $this->saveToPackage($archive, 'imsmanifest.xml', $manifest->dump());

        // Add common files
        $this->addCommons($archive, $locale);

        // Add resources files
        foreach ($scos as $sco) {
            // Dump template into file
            $this->saveToPackage($archive, 'scos/resource_'.$sco['node']->getId().'.html', $sco['template']);

            // Dump additional resource assets
            if (!empty($sco['assets'])) {
                foreach ($sco['assets'] as $filename => $originalFile) {
                    $this->copyToPackage($archive, 'assets/'.$filename, $this->getFilePath($this->webPath, $originalFile));
                }
            }

            // Add uploaded files
            if (!empty($sco['files'])) {
                // $this->container->getParameter('claroline.param.files_directory')
                foreach ($sco['files'] as $filename => $originalFile) {
                    $filePath = $originalFile['absolute'] ? $originalFile['path'] : $this->getFilePath($this->uploadPath, $originalFile['path']);
                    $this->copyToPackage($archive, 'files/'.$filename, $filePath);
                }
            }

            // Add translations
            if (!empty($sco['translation_domains'])) {
                foreach ($sco['translation_domains'] as $domain) {
                    $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js';
                    $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile));
                }
            }
        }

        $archive->close();

        return $archive;
    }
public function createPackage(ResourceNode $node, $locale, AbstractScormManifest $manifest, array $scos = [])
    {
        $scormId = 'scorm-'.$node->getId().'-'.date('YmdHis');

        // Create and open scorm archive
        if (!is_dir($this->tmpPath)) {
            mkdir($this->tmpPath);
        }

        $archive = new \ZipArchive();
        $archive->open($this->tmpPath.DIRECTORY_SEPARATOR.$scormId.'.zip', \ZipArchive::CREATE);

        // Add manifest
        $this->saveToPackage($archive, 'imsmanifest.xml', $manifest->dump());

        // Add common files
        $this->addCommons($archive, $locale);

        // Add resources files
        foreach ($scos as $sco) {
            // Dump template into file
            $this->saveToPackage($archive, 'scos/resource_'.$sco['node']->getId().'.html', $sco['template']);

            // Dump additional resource assets
            if (!empty($sco['assets'])) {
                foreach ($sco['assets'] as $filename => $originalFile) {
                    $this->copyToPackage($archive, 'assets/'.$filename, $this->getFilePath($this->webPath, $originalFile));
                }
            }

            // Add uploaded files
            if (!empty($sco['files'])) {
                // $this->container->getParameter('claroline.param.files_directory')
                foreach ($sco['files'] as $filename => $originalFile) {
                    $filePath = $originalFile['absolute'] ? $originalFile['path'] : $this->getFilePath($this->uploadPath, $originalFile['path']);
                    $this->copyToPackage($archive, 'files/'.$filename, $filePath);
                }
            }

            // Add translations
            if (!empty($sco['translation_domains'])) {
                foreach ($sco['translation_domains'] as $domain) {
                    $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js';
                    $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile));
                }
            }
        }

        $archive->close();

        return $archive;
    }
public function createPackage ( ResourceNode $ node , $ locale , AbstractScormManifest $ manifest , array $ scos = [ ] ) { $ scormId = 'scorm-' . $ node -> getId ( ) . '-' . date ( 'YmdHis' ) ; // Create and open scorm archive if ( ! is_dir ( $ this -> tmpPath ) ) { mkdir ( $ this -> tmpPath ) ; } $ archive = new \ ZipArchive ( ) ; $ archive -> open ( $ this -> tmpPath . DIRECTORY_SEPARATOR . $ scormId . '.zip' , \ ZipArchive :: CREATE ) ; // Add manifest $ this -> saveToPackage ( $ archive , 'imsmanifest.xml' , $ manifest -> dump ( ) ) ; // Add common files $ this -> addCommons ( $ archive , $ locale ) ; // Add resources files foreach ( $ scos as $ sco ) { // Dump template into file $ this -> saveToPackage ( $ archive , 'scos/resource_' . $ sco [ 'node' ] -> getId ( ) . '.html' , $ sco [ 'template' ] ) ; // Dump additional resource assets if ( ! empty ( $ sco [ 'assets' ] ) ) { foreach ( $ sco [ 'assets' ] as $ filename => $ originalFile ) { $ this -> copyToPackage ( $ archive , 'assets/' . $ filename , $ this -> getFilePath ( $ this -> webPath , $ originalFile ) ) ; } } // Add uploaded files if ( ! empty ( $ sco [ 'files' ] ) ) { // $this->container->getParameter('claroline.param.files_directory') foreach ( $ sco [ 'files' ] as $ filename => $ originalFile ) { $ filePath = $ originalFile [ 'absolute' ] ? $ originalFile [ 'path' ] : $ this -> getFilePath ( $ this -> uploadPath , $ originalFile [ 'path' ] ) ; $ this -> copyToPackage ( $ archive , 'files/' . $ filename , $ filePath ) ; } } // Add translations if ( ! empty ( $ sco [ 'translation_domains' ] ) ) { foreach ( $ sco [ 'translation_domains' ] as $ domain ) { $ translationFile = 'js/translations/' . $ domain . '/' . $ locale . '.js' ; $ this -> copyToPackage ( $ archive , 'translations/' . $ domain . '.js' , $ this -> getFilePath ( $ this -> webPath , $ translationFile ) ) ; } } } $ archive -> close ( ) ; return $ archive ; }
Create SCORM package.

@param ResourceNode          $node     - The exported ResourceNode
@param string                $locale   - THe locale to use for export
@param AbstractScormManifest $manifest - The manifest of the SCORM package
@param array                 $scos     - The list of resources to include into the package

@return \ZipArchive
Create SCORM package .