public function testCompressFolder()
 {
     $files = array('releases-noNewPatch.xml', 'releases-patchsOnly.xml', 'releases.xml', 'folder/', 'folder/emptyFile', 'emptyFolder/');
     $dest = dirname(__FILE__) . '/backup/test.zip';
     $src = dirname(__FILE__) . '/sample';
     taoUpdate_helpers_Zip::compressFolder($src, $dest);
     $this->assertTrue(is_file($dest));
     $zip = new ZipArchive();
     $zip->open($dest);
     foreach ($files as $file) {
         $this->assertFalse($zip->locateName($file) === false, $file . ' not found');
     }
     $this->assertFalse($zip->locateName('.svn'));
     helpers_File::remove($dest);
     $dest = dirname(__FILE__) . '/backup/test2.zip';
     taoUpdate_helpers_Zip::compressFolder($src, $dest, true);
     $files = array('sample/releases-noNewPatch.xml', 'sample/releases-patchsOnly.xml', 'sample/releases.xml', 'sample/folder/', 'sample/folder/emptyFile', 'sample/emptyFolder/');
     $this->assertTrue(is_file($dest));
     $zip = new ZipArchive();
     $zip->open($dest);
     for ($i = 0; $i < $zip->numFiles; $i++) {
         $stat = $zip->statIndex($i);
         //cehck no .svn added in zip
         $this->assertFalse(strpos($stat['name'], '.svn') > 0);
     }
     foreach ($files as $file) {
         $this->assertFalse($zip->locateName($file) === false);
     }
     helpers_File::remove($dest);
 }
Exemple #2
0
 protected function setupServiceManager($configPath)
 {
     if (!\helpers_File::emptyDirectory($configPath, true)) {
         throw new common_exception_Error('Unable to empty ' . $configPath . ' folder.');
     }
     $driver = new SimpleConfigDriver();
     $configService = $driver->connect('config', array('dir' => $configPath, 'humanReadable' => true));
     return new ServiceManager($configService);
 }
 public function run()
 {
     $extension = common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery');
     $runPath = $extension->getConstant('BASE_PATH') . 'data' . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR;
     helpers_File::emptyDirectory($runPath);
     $runSource = tao_models_classes_FileSourceService::singleton()->addLocalSource('runtimeDirectory', $runPath);
     $provider = new tao_models_classes_fsAccess_TokenAccessProvider($runSource);
     taoDelivery_models_classes_RuntimeAccess::setAccessProvider($provider);
 }
Exemple #4
0
 public function tearDown()
 {
     if (!is_null($this->fileSource)) {
         $this->fileSource->delete();
     } else {
         throw new common_Exception('should not be null, something wrong happen during test');
     }
     helpers_File::remove($this->fsPath);
 }
 public function tearDown()
 {
     parent::tearDown();
     helpers_File::remove($this->getBasePath());
     //unregister all
     $ids = array_keys(array_diff_key($this->getClientLibRegistryMap(), $this->initialMapping));
     foreach ($ids as $id) {
         ClientLibRegistry::getRegistry()->remove($id);
     }
 }
 protected function tearDown()
 {
     helpers_File::remove($this->directory);
     if ($this->repository != null) {
         $directory = $this->repository->getPath();
         $this->repository->delete();
         parent::tearDown();
     } else {
         throw new common_Exception('Repository should never be null');
     }
 }
 /**
  *
  * @access
  * @author "Lionel Lecaque, <*****@*****.**>"
  * @param unknown $ext
  * @return boolean
  */
 public function shield($ext, $destination)
 {
     $extFolder = ROOT_PATH . DIRECTORY_SEPARATOR . $ext;
     if (is_file($extFolder . '/htaccess.1')) {
         throw new taoUpdate_models_classes_UpdateException('Previous lock, htaccess.1 still exits, delete it in ' . $extFolder);
     }
     helpers_File::copy($extFolder . '/.htaccess', $extFolder . '/htaccess.1', true, false);
     if (is_file($extFolder . '/htaccess.1') && is_writable($extFolder . '/.htaccess')) {
         file_put_contents($extFolder . '/.htaccess', "Options +FollowSymLinks\n" . "<IfModule mod_rewrite.c>\n" . "RewriteEngine On\n" . "RewriteCond %{REQUEST_URI} !/views/  [NC]\n" . "RewriteRule ^.*\$ " . ROOT_URL . $destination . " [L]\n" . "</IfModule>");
         return true;
     } else {
         throw new taoUpdate_models_classes_UpdateException('.htaccess is not writtable in ' . $extFolder);
     }
 }
 /**
  * 
  * @access
  * @author "Lionel Lecaque, <*****@*****.**>"
  * @param unknown $folder
  * @throws taoUpdate_models_classes_UpdateException
  */
 public function storeDatabase($folder)
 {
     $dbBackupHelper = new taoUpdate_helpers_DbBackup();
     $fileContent = $dbBackupHelper->backup();
     $filepath = $folder . DIRECTORY_SEPARATOR . self::DB_BACKUP_FILE_PREFFIX . TAO_VERSION . self::DB_BACKUP_FILE_SUFFIX;
     if (!file_put_contents($filepath, $fileContent)) {
         throw new taoUpdate_models_classes_UpdateException('fail to create SQL file');
     }
     if (is_file($filepath)) {
         taoUpdate_helpers_Zip::compressFile($filepath, $filepath . '.zip');
         if (is_file($filepath . '.zip')) {
             helpers_File::remove($filepath);
         }
     }
 }
 public function run()
 {
     $publicDataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR;
     $privateDataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'private' . DIRECTORY_SEPARATOR;
     if (file_exists($publicDataPath)) {
         helpers_File::emptyDirectory($publicDataPath);
     }
     if (file_exists($privateDataPath)) {
         helpers_File::emptyDirectory($privateDataPath);
     }
     $publicFs = tao_models_classes_FileSourceService::singleton()->addLocalSource('public service storage', $publicDataPath);
     $privateFs = tao_models_classes_FileSourceService::singleton()->addLocalSource('private service storage', $privateDataPath);
     $provider = tao_models_classes_fsAccess_TokenAccessProvider::spawnProvider($publicFs);
     tao_models_classes_service_FileStorage::configure($privateFs, $publicFs, $provider);
 }
 public function __invoke($params)
 {
     $publicDataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR;
     $privateDataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'private' . DIRECTORY_SEPARATOR;
     if (file_exists($publicDataPath)) {
         helpers_File::emptyDirectory($publicDataPath);
     }
     if (file_exists($privateDataPath)) {
         helpers_File::emptyDirectory($privateDataPath);
     }
     $fsService = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID);
     $fsService->createFileSystem('public', 'tao/public');
     $fsService->createFileSystem('private', 'tao/private');
     $this->registerService(FileSystemService::SERVICE_ID, $fsService);
     $websource = TokenWebSource::spawnWebsource('public', $publicDataPath);
     $service = new tao_models_classes_service_FileStorage(array(tao_models_classes_service_FileStorage::OPTION_PUBLIC_FS => 'public', tao_models_classes_service_FileStorage::OPTION_PRIVATE_FS => 'private', tao_models_classes_service_FileStorage::OPTION_ACCESS_PROVIDER => $websource->getId()));
     $this->registerService(tao_models_classes_service_FileStorage::SERVICE_ID, $service);
 }
 public function testDelployRelease()
 {
     $release = '10.10.88';
     $path = $this->service->downloadRelease($release);
     $result = $this->service->deploy($release);
     $this->assertTrue(is_dir($result . 'TAO_10.10.88_build'));
     helpers_File::remove($path);
 }
Exemple #12
0
 /**
  * @author "Sam Sipasseuth, <*****@*****.**>"
  */
 protected function clear()
 {
     if (file_exists($this->file)) {
         helpers_File::remove($this->file);
     }
     if (file_exists($this->counterFile)) {
         helpers_File::remove($this->counterFile);
     }
     if (file_exists($this->sentFolder)) {
         helpers_File::remove($this->sentFolder);
     }
 }
Exemple #13
0
 public function testUrlToPath()
 {
     $path = DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'tao-user-styles.css';
     $urls = array('/style/custom/tao-user-styles.css', 'http://ex.com/style/custom/tao-user-styles.css', 'https://ex.com/style/custom/tao-user-styles.css', 'file://c/style/custom/tao-user-styles.css', 'file://D:/style/custom/tao-user-styles.css');
     foreach ($urls as $url) {
         $this->assertEquals(helpers_File::urlToPath($url), $path);
     }
 }
Exemple #14
0
 /**
  * Short description of method delete
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  File resource
  * @param  string path
  * @return boolean
  * @see core_kernel_versioning_File::delete()
  */
 public function delete(core_kernel_file_File $resource, $path)
 {
     $returnValue = (bool) false;
     common_Logger::i(__FUNCTION__ . ' called on local directory', 'LOCALVCS');
     $returnValue = helpers_File::remove($path);
     return (bool) $returnValue;
 }
/*  
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; under version 2
 * of the License (non-upgradable).
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
/*
 * This post-installation script creates a fodler for the QTI Tests
 */
$dataPath = FILES_PATH . 'taoQtiTest' . DIRECTORY_SEPARATOR;
if (file_exists($dataPath)) {
    helpers_File::emptyDirectory($dataPath);
}
$source = tao_models_classes_FileSourceService::singleton()->addLocalSource('QTI test datasource', $dataPath);
mkdir($dataPath . 'testData');
$directory = new core_kernel_file_File($source->createFile('', 'testData'));
taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestDirectory($directory);
Exemple #16
0
 /**
  * Remove a file. If the recursive parameter is set to true, the target file
  * can be a directory that contains data.
  *
  * @author Lionel Lecaque, <*****@*****.**>
  * @param  string path The path to the file you want to remove.
  * @param  boolean recursive (optional, default is false) Remove file content recursively (only if the path points to a directory).
  * @return boolean Return true if the file is correctly removed, false otherwise.
  */
 public static function remove($path, $recursive = false)
 {
     $returnValue = (bool) false;
     if ($recursive) {
         $returnValue = helpers_File::remove($path);
     } elseif (is_file($path)) {
         $returnValue = @unlink($path);
     }
     // else fail silently
     return (bool) $returnValue;
 }
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
/*
 * This post-installation script creates a new local file source for file uploaded
 * by end-users through the TAO GUI.
 */
$publicDataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR;
$privateDataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'private' . DIRECTORY_SEPARATOR;
if (file_exists($publicDataPath)) {
    helpers_File::emptyDirectory($publicDataPath);
}
if (file_exists($privateDataPath)) {
    helpers_File::emptyDirectory($privateDataPath);
}
$publicFs = tao_models_classes_FileSourceService::singleton()->addLocalSource('public service storage', $publicDataPath);
$privateFs = tao_models_classes_FileSourceService::singleton()->addLocalSource('private service storage', $privateDataPath);
$websource = TokenWebSource::spawnWebsource($publicFs);
tao_models_classes_service_FileStorage::configure($privateFs, $publicFs, $websource);
 /**
  * 
  * @return \oat\tao\model\search\zend\ZendSearch
  */
 public static function createSearch()
 {
     $privateDataPath = FILES_PATH . 'tao' . DIRECTORY_SEPARATOR . 'ZendSearch' . DIRECTORY_SEPARATOR;
     if (file_exists($privateDataPath)) {
         \helpers_File::emptyDirectory($privateDataPath);
     }
     $privateFs = \tao_models_classes_FileSourceService::singleton()->addLocalSource('Zend Search index folder', $privateDataPath);
     $search = new ZendSearch(array('fileSystem' => $privateFs->getUri()));
     $search->flushIndex();
     return $search;
 }
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * Copyright (c) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
 *
 */
use oat\taoQtiItem\model\SharedLibrariesRegistry;
$libBasePath = ROOT_PATH . 'taoQtiItem/views/js/portableSharedLibraries';
$libRootUrl = ROOT_URL . 'taoQtiItem/views/js/portableSharedLibraries';
$installBasePath = __DIR__ . '/portableSharedLibraries';
// clean directory...
helpers_File::emptyDirectory($libBasePath, true);
$registry = new SharedLibrariesRegistry($libBasePath, $libRootUrl);
$registry->registerFromFile('IMSGlobal/jquery_2_1_1', $installBasePath . '/IMSGlobal/jquery_2_1_1.js');
$registry->registerFromFile('OAT/lodash', $installBasePath . '/OAT/lodash.js');
$registry->registerFromFile('OAT/async', $installBasePath . '/OAT/async.js');
$registry->registerFromFile('OAT/raphael', $installBasePath . '/OAT/raphael.js');
$registry->registerFromFile('OAT/scale.raphael', $installBasePath . '/OAT/scale.raphael.js');
$registry->registerFromFile('OAT/jquery.qtip', $installBasePath . '/OAT/jquery.qtip.js');
$registry->registerFromFile('OAT/util/xml', $installBasePath . '/OAT/util/xml.js');
$registry->registerFromFile('OAT/util/math', $installBasePath . '/OAT/util/math.js');
$registry->registerFromFile('OAT/util/html', $installBasePath . '/OAT/util/html.js');
$registry->registerFromFile('OAT/util/EventMgr', $installBasePath . '/OAT/util/EventMgr.js');
$registry->registerFromFile('OAT/util/event', $installBasePath . '/OAT/util/event.js');
$registry->registerFromFile('OAT/util/asset', $installBasePath . '/OAT/util/asset.js');
$registry->registerFromFile('OAT/util/tpl', $installBasePath . '/OAT/util/tpl.js');
$registry->registerFromFile('OAT/sts/common', $installBasePath . '/OAT/sts/common.js');
Exemple #20
0
 /**
  * Ask the repository to deal with a file located in $filePath. It will return
  * you a reference on Versioned File.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  string filePath The path to the file you want the repository to deal with.
  * @param  string label A label for the created file Resource.
  * @param  callable $createFileName A function that generates unique file name during spawn file
  * @return core_kernel_versioning_File
  * @since 2.4
  */
 public function spawnFile($filePath, $label = '', callable $createFileName = null)
 {
     $returnValue = null;
     if (!$createFileName) {
         $createFileName = [__CLASS__, 'createFileName'];
     }
     $fileInfo = new SplFileInfo($filePath);
     $relativePath = str_replace([$this->getPath(), $fileInfo->getFilename(), dirname($filePath)], '', $fileInfo->getPathname());
     $fileName = $createFileName($fileInfo->getFilename());
     $destination = $this->getPath() . $relativePath . $fileName;
     $source = $filePath;
     if (helpers_File::copy($source, $destination, true, false)) {
         if ($fileInfo->isDir()) {
             $returnValue = $this->createFile('', $relativePath . $fileName);
         } else {
             $returnValue = $this->createFile($fileName);
         }
         if (!empty($label)) {
             $returnValue->setLabel($label);
         }
     }
     return $returnValue;
 }
<?php

/**  
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; under version 2
 * of the License (non-upgradable).
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2014 (original work) Open Assessment Technologies SA;
 *               
 * 
 */
use oat\taoBooklet\model\StorageService;
$bookletDataPath = FILES_PATH . 'taoBooklet' . DIRECTORY_SEPARATOR;
if (file_exists($bookletDataPath)) {
    helpers_File::emptyDirectory($bookletDataPath);
}
$bookletFs = tao_models_classes_FileSourceService::singleton()->addLocalSource('booklet storage', $bookletDataPath);
StorageService::setFileSystem($bookletFs);
 /**
  * Import a QTI Test and its dependent Items into the TAO Platform.
  *
  * @param core_kernel_classes_Class $targetClass The RDFS Class where Ontology resources must be created.
  * @param oat\taoQtiItem\model\qti\Resource $qtiTestResource The QTI Test Resource representing the IMS QTI Test to be imported.
  * @param taoQtiTest_models_classes_ManifestParser $manifestParser The parser used to retrieve the IMS Manifest.
  * @param string $folder The absolute path to the folder where the IMS archive containing the test content
  * @return common_report_Report A report about how the importation behaved.
  */
 protected function importTest(core_kernel_classes_Class $targetClass, Resource $qtiTestResource, taoQtiTest_models_classes_ManifestParser $manifestParser, $folder)
 {
     $itemImportService = ImportService::singleton();
     $itemService = taoItems_models_classes_ItemsService::singleton();
     $testClass = $targetClass;
     // Create an RDFS resource in the knowledge base that will hold
     // the information about the imported QTI Test.
     $testResource = $this->createInstance($testClass);
     $qtiTestModelResource = new core_kernel_classes_Resource(INSTANCE_TEST_MODEL_QTI);
     $modelProperty = new core_kernel_classes_Property(PROPERTY_TEST_TESTMODEL);
     $testResource->editPropertyValues($modelProperty, $qtiTestModelResource);
     // Create the report that will hold information about the import
     // of $qtiTestResource in TAO.
     $report = new common_report_Report(common_report_Report::TYPE_INFO);
     // The class where the items that belong to the test will be imported.
     $itemClass = new core_kernel_classes_Class(TAO_ITEM_CLASS);
     $targetClass = $itemClass->createSubClass($testResource->getLabel());
     // Load and validate the manifest
     $qtiManifestParser = new taoQtiTest_models_classes_ManifestParser($folder . 'imsmanifest.xml');
     $qtiManifestParser->validate();
     // Set up $report with useful information for client code (especially for rollback).
     $reportCtx = new stdClass();
     $reportCtx->manifestResource = $qtiTestResource;
     $reportCtx->rdfsResource = $testResource;
     $reportCtx->itemClass = $targetClass;
     $reportCtx->items = array();
     $report->setData($reportCtx);
     // Expected test.xml file location.
     $expectedTestFile = $folder . str_replace('/', DIRECTORY_SEPARATOR, $qtiTestResource->getFile());
     // Already imported test items (qti xml file paths).
     $alreadyImportedTestItemFiles = array();
     // -- Check if the file referenced by the test QTI resource exists.
     if (is_readable($expectedTestFile) === false) {
         $report->add(common_report_Report::createFailure(__('No file found at location "%s".', $qtiTestResource->getFile())));
     } else {
         // -- Load the test in a QTISM flavour.
         $testDefinition = new XmlDocument();
         try {
             $testDefinition->load($expectedTestFile, true);
             // -- Load all items related to test.
             $itemError = false;
             // discover test's base path.
             $dependencies = taoQtiTest_helpers_Utils::buildAssessmentItemRefsTestMap($testDefinition, $manifestParser, $folder);
             if (count($dependencies) > 0) {
                 foreach ($dependencies as $assessmentItemRefId => $qtiDependency) {
                     if ($qtiDependency !== false) {
                         if (Resource::isAssessmentItem($qtiDependency->getType())) {
                             $qtiFile = $folder . str_replace('/', DIRECTORY_SEPARATOR, $qtiDependency->getFile());
                             // Skip if $qtiFile already imported (multiple assessmentItemRef "hrefing" the same file).
                             if (array_key_exists($qtiFile, $alreadyImportedTestItemFiles) === false) {
                                 $itemReport = $itemImportService->importQTIFile($qtiFile, $targetClass);
                                 $rdfItem = $itemReport->getData();
                                 if ($rdfItem) {
                                     $itemPath = taoItems_models_classes_ItemsService::singleton()->getItemFolder($rdfItem);
                                     foreach ($qtiDependency->getAuxiliaryFiles() as $auxResource) {
                                         // $auxResource is a relativ URL, so we need to replace the slashes with directory separators
                                         $auxPath = $folder . str_replace('/', DIRECTORY_SEPARATOR, $auxResource);
                                         // does the file referenced by $auxPath exist?
                                         if (is_readable($auxPath) === true) {
                                             $relPath = helpers_File::getRelPath($qtiFile, $auxPath);
                                             $destPath = $itemPath . $relPath;
                                             tao_helpers_File::copy($auxPath, $destPath, true);
                                         } else {
                                             $msg = __('Auxiliary file not found at location "%s".', $auxResource);
                                             $itemReport->add(new common_report_Report(common_report_Report::TYPE_WARNING, $msg));
                                         }
                                     }
                                     $reportCtx->items[$assessmentItemRefId] = $rdfItem;
                                     $alreadyImportedTestItemFiles[$qtiFile] = $rdfItem;
                                     $itemReport->setMessage(__('IMS QTI Item referenced as "%s" in the IMS Manifest file successfully imported.', $qtiDependency->getIdentifier()));
                                 } else {
                                     $itemReport->setType(common_report_Report::TYPE_ERROR);
                                     $itemReport->setMessage(__('IMS QTI Item referenced as "%s" in the IMS Manifest file could not be imported.', $qtiDependency->getIdentifier()));
                                     $itemError = $itemError === false ? true : $itemError;
                                 }
                                 $report->add($itemReport);
                             } else {
                                 $reportCtx->items[$assessmentItemRefId] = $alreadyImportedTestItemFiles[$qtiFile];
                             }
                         }
                     } else {
                         $msg = __('The dependency to the IMS QTI AssessmentItemRef "%s" in the IMS Manifest file could not be resolved.', $assessmentItemRefId);
                         $report->add(common_report_Report::createFailure($msg));
                         $itemError = $itemError === false ? true : $itemError;
                     }
                 }
                 // If items did not produce errors, we import the test definition.
                 if ($itemError === false) {
                     common_Logger::i('Importing test...');
                     // Second step is to take care of the test definition and the related media (auxiliary files).
                     // 1. Import test definition (i.e. the QTI-XML Test file).
                     $testContent = $this->importTestDefinition($testResource, $testDefinition, $qtiTestResource, $reportCtx->items, $folder, $report);
                     if ($testContent !== false) {
                         // 2. Import test auxilliary files (e.g. stylesheets, images, ...).
                         $this->importTestAuxiliaryFiles($testContent, $qtiTestResource, $folder, $report);
                         // 3. Give meaningful names to resources.
                         $testTitle = $testDefinition->getDocumentComponent()->getTitle();
                         $testResource->setLabel($testDefinition->getDocumentComponent()->getTitle());
                         $targetClass->setLabel($testDefinition->getDocumentComponent()->getTitle());
                     }
                 } else {
                     $msg = __("One or more dependent IMS QTI Items could not be imported.");
                     $report->add(common_report_Report::createFailure($msg));
                 }
             } else {
                 // No depencies found (i.e. no item resources bound to the test).
                 $msg = __("No reference to any IMS QTI Item found.");
                 $report->add(common_report_Report::createFailure($msg));
             }
         } catch (StorageException $e) {
             // Source of the exception = $testDefinition->load()
             // What is the reason ?
             $finalErrorString = '';
             $eStrs = array();
             if (($libXmlErrors = $e->getErrors()) !== null) {
                 foreach ($libXmlErrors as $libXmlError) {
                     $eStrs[] = __('XML error at line %1$d column %2$d "%3$s".', $libXmlError->line, $libXmlError->column, trim($libXmlError->message));
                 }
             }
             $finalErrorString = implode("\n", $eStrs);
             if (empty($finalErrorString) === true) {
                 // Not XML malformation related. No info from LibXmlErrors extracted.
                 if (($previous = $e->getPrevious()) != null) {
                     // Useful information could be found here.
                     $finalErrorString = $previous->getMessage();
                     if ($previous instanceof UnmarshallingException) {
                         $domElement = $previous->getDOMElement();
                         $finalErrorString = __('Inconsistency at line %1d:', $domElement->getLineNo()) . ' ' . $previous->getMessage();
                     }
                 } else {
                     $finalErrorString = __("Unknown error.");
                 }
             }
             $msg = __("Error found in the IMS QTI Test:\n%s", $finalErrorString);
             $report->add(common_report_Report::createFailure($msg));
         }
     }
     if ($report->containsError() === false) {
         $report->setType(common_report_Report::TYPE_SUCCESS);
         $msg = __("IMS QTI Test referenced as \"%s\" in the IMS Manifest file successfully imported.", $qtiTestResource->getIdentifier());
         $report->setMessage($msg);
     } else {
         $report->setType(common_report_Report::TYPE_ERROR);
         $msg = __("The IMS QTI Test referenced as \"%s\" in the IMS Manifest file could not be imported.", $qtiTestResource->getIdentifier());
         $report->setMessage($msg);
     }
     return $report;
 }
 /**
  * Return the location of file as relative path in package
  *
  * @param $qtiFile
  * @param $absolutePath
  * @return mixed
  */
 protected function getRelativePath($qtiFile, $absolutePath)
 {
     return str_replace(DIRECTORY_SEPARATOR, '/', \helpers_File::getRelPath($qtiFile, $absolutePath));
 }
 /**
  * purge the persistence directory
  * 
  * @return boolean
  */
 public function purge()
 {
     // @todo opcache invalidation
     return file_exists($this->directory) ? helpers_File::emptyDirectory($this->directory) : false;
 }
Exemple #25
0
 public function import($id, $directoryPath)
 {
     $directory = $this->getDirectoryById($id);
     if (file_exists($directory->getPath())) {
         if (tao_helpers_File::isDirEmpty($directory->getPath())) {
             common_Logger::d('Directory already found but content is empty');
             helpers_File::copy($directoryPath, $directory->getPath(), true);
         } else {
             if (tao_helpers_File::isIdentical($directory->getPath(), $directoryPath)) {
                 common_Logger::d('Directory already found but content is identical');
             } else {
                 throw new common_Exception('Duplicate dir ' . $id . ' with different content');
             }
         }
     } else {
         mkdir($directory->getPath(), 0700, true);
         helpers_File::copy($directoryPath, $directory->getPath(), true);
     }
 }
 /**
  * Retrieve a file from a given $url and copy it to its final $destination.
  * 
  * @param string $url The URL to be dereferenced.
  * @param string $destination The destination of the retrieved file, on the file system.
  * @return boolean|string false If an error occurs during the retrieval/copy process, or the final destination name if it succeeds.
  */
 public static function retrieveFile($url, $destination)
 {
     $fileName = basename($url);
     //check file name compatibility:
     //e.g. if a file with a common name (e.g. car.jpg, house.png, sound.mp3) already exists in the destination folder
     while (file_exists($destination . $fileName)) {
         $lastDot = strrpos($fileName, '.');
         $fileName = substr($fileName, 0, $lastDot) . '_' . substr($fileName, $lastDot);
     }
     // Since the file has not been downloaded yet, start downloading it using cUrl
     // Only if the resource is external, else we copy it
     if (!preg_match('@^' . ROOT_URL . '@', $url)) {
         common_Logger::d('Downloading ' . $url);
         helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::NO_TIMEOUT);
         $fp = fopen($destination . $fileName, 'w+');
         $curlHandler = curl_init();
         curl_setopt($curlHandler, CURLOPT_URL, $url);
         curl_setopt($curlHandler, CURLOPT_FILE, $fp);
         curl_setopt($curlHandler, CURLOPT_TIMEOUT, 50);
         curl_setopt($curlHandler, CURLOPT_FOLLOWLOCATION, true);
         //if there is an http auth on the local domain, it's mandatory to auth with curl
         if (USE_HTTP_AUTH) {
             $addAuth = false;
             $domains = array('localhost', '127.0.0.1', ROOT_URL);
             foreach ($domains as $domain) {
                 if (preg_match("/" . preg_quote($domain, '/') . "/", $url)) {
                     $addAuth = true;
                 }
             }
             if ($addAuth) {
                 curl_setopt($curlHandler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                 curl_setopt($curlHandler, CURLOPT_USERPWD, USE_HTTP_USER . ":" . USE_HTTP_PASS);
             }
         }
         curl_exec($curlHandler);
         $httpCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
         $success = $httpCode == 200;
         curl_close($curlHandler);
         fclose($fp);
         helpers_TimeOutHelper::reset();
     } else {
         $path = tao_helpers_File::getPathFromUrl($url);
         common_Logger::d('Copying ' . $path);
         $success = helpers_File::copy($path, $destination . $fileName);
     }
     if ($success == false) {
         common_Logger::w('Unable to retrieve ' . $url);
         return false;
     } else {
         return $destination . $fileName;
     }
 }
Exemple #27
0
 /**
  * Create a new local file system
  * 
  * @param string $id
  * @return FileSystem
  */
 public function createLocalFileSystem($id)
 {
     $path = $this->getOption(self::OPTION_FILE_PATH) . \helpers_File::sanitizeInjectively($id);
     $this->registerLocalFileSystem($id, $path);
     return $this->getFileSystem($id);
 }
 public function tearDown()
 {
     helpers_File::remove($this->folder);
 }
 /**
  * Run the TAO install from the given data
  * @throws tao_install_utils_Exception
  * @param $installData data coming from the install form
  * @see tao_install_form_Settings
  */
 public function install(array $installData)
 {
     try {
         /*
          * 0 - Check input parameters. 
          */
         $this->log('i', "Checking install data");
         self::checkInstallData($installData);
         $this->log('i', "Starting TAO install", 'INSTALL');
         // Sanitize $installData if needed.
         if (!preg_match("/\\/\$/", $installData['module_url'])) {
             $installData['module_url'] .= '/';
         }
         if (isset($installData['extensions'])) {
             $extensionIDs = is_array($installData['extensions']) ? $installData['extensions'] : explode(',', $installData['extensions']);
         } else {
             $extensionIDs = array('taoCe');
         }
         $installData['file_path'] = rtrim($installData['file_path'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
         /*
          *  1 - Check configuration with checks described in the manifest.
          */
         $configChecker = tao_install_utils_ChecksHelper::getConfigChecker($extensionIDs);
         // Silence checks to have to be escaped.
         foreach ($configChecker->getComponents() as $c) {
             if (method_exists($c, 'getName') && in_array($c->getName(), $this->getEscapedChecks())) {
                 $configChecker->silent($c);
             }
         }
         $reports = $configChecker->check();
         foreach ($reports as $r) {
             $msg = $r->getMessage();
             $component = $r->getComponent();
             $this->log('i', $msg);
             if ($r->getStatus() !== common_configuration_Report::VALID && !$component->isOptional()) {
                 throw new tao_install_utils_Exception($msg);
             }
         }
         /*
          *  2 - Test DB connection (done by the constructor)
          */
         $this->log('i', "Spawning DbCreator", 'INSTALL');
         $dbName = $installData['db_name'];
         if ($installData['db_driver'] == 'pdo_oci') {
             $installData['db_name'] = $installData['db_host'];
             $installData['db_host'] = '';
         }
         $dbConfiguration = array('driver' => $installData['db_driver'], 'host' => $installData['db_host'], 'dbname' => $installData['db_name'], 'user' => $installData['db_user'], 'password' => $installData['db_pass']);
         $hostParts = explode(':', $installData['db_host']);
         if (count($hostParts) == 2) {
             $dbConfiguration['host'] = $hostParts[0];
             $dbConfiguration['port'] = $hostParts[1];
         }
         if ($installData['db_driver'] == 'pdo_mysql') {
             $dbConfiguration['dbname'] = '';
         }
         if ($installData['db_driver'] == 'pdo_oci') {
             $dbConfiguration['wrapperClass'] = 'Doctrine\\DBAL\\Portability\\Connection';
             $dbConfiguration['portability'] = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL;
             $dbConfiguration['fetch_case'] = PDO::CASE_LOWER;
         }
         $dbCreator = new tao_install_utils_DbalDbCreator($dbConfiguration);
         $this->log('d', "DbCreator spawned", 'INSTALL');
         /*
          *   3 - Load the database schema
          */
         // If the database already exists, drop all tables
         if ($dbCreator->dbExists($dbName)) {
             try {
                 //If the target Sgbd is mysql select the database after creating it
                 if ($installData['db_driver'] == 'pdo_mysql') {
                     $dbCreator->setDatabase($installData['db_name']);
                 }
                 $dbCreator->cleanDb($dbName);
             } catch (Exception $e) {
                 $this->log('i', 'Problem cleaning db will try to erase the whole db: ' . $e->getMessage());
                 try {
                     $dbCreator->destroyTaoDatabase($dbName);
                 } catch (Exception $e) {
                     $this->log('i', 'isssue during db cleaning : ' . $e->getMessage());
                 }
             }
             $this->log('i', "Dropped all tables", 'INSTALL');
         } else {
             try {
                 $dbCreator->createDatabase($installData['db_name']);
                 $this->log('i', "Created database " . $installData['db_name'], 'INSTALL');
             } catch (Exception $e) {
                 throw new tao_install_utils_Exception('Unable to create the database, make sure that ' . $installData['db_user'] . ' is granted to create databases. Otherwise create the database with your super user and give to  ' . $installData['db_user'] . ' the right to use it.');
             }
             //If the target Sgbd is mysql select the database after creating it
             if ($installData['db_driver'] == 'pdo_mysql') {
                 $dbCreator->setDatabase($installData['db_name']);
             }
         }
         // reset db name for mysql
         if ($installData['db_driver'] == 'pdo_mysql') {
             $dbConfiguration['dbname'] = $installData['db_name'];
         }
         // Create tao tables
         $dbCreator->initTaoDataBase();
         $this->log('i', 'Created tables', 'INSTALL');
         $storedProcedureFile = $this->options['install_path'] . 'db/tao_stored_procedures_' . str_replace('pdo_', '', $installData['db_driver']) . '.sql';
         if (file_exists($storedProcedureFile) && is_readable($storedProcedureFile)) {
             $this->log('i', 'Installing stored procedures for ' . $installData['db_driver'], 'INSTALL');
             $dbCreator->loadProc($storedProcedureFile);
         } else {
             $this->log('e', 'Could not find storefile : ' . $storedProcedureFile);
         }
         /*
          *  4 - Create the local namespace
          */
         // 			$this->log('i', 'Creating local namespace', 'INSTALL');
         // 			$dbCreator->addLocalModel('8',$installData['module_namespace']);
         // 			$dbCreator->addModels();
         /*
          *  5 - Create the generis config files
          */
         $this->log('d', 'Removing old config', 'INSTALL');
         if (!helpers_File::emptyDirectory($this->options['root_path'] . 'config/', true)) {
             throw new common_exception_Error('Unable to empty ' . $this->options['root_path'] . 'config/ folder.');
         }
         $this->log('d', 'Writing generis config', 'INSTALL');
         $generisConfigWriter = new tao_install_utils_ConfigWriter($this->options['root_path'] . 'generis/config/sample/generis.conf.php', $this->options['root_path'] . 'config/generis.conf.php');
         $generisConfigWriter->createConfig();
         $generisConfigWriter->writeConstants(array('LOCAL_NAMESPACE' => $installData['module_namespace'], 'GENERIS_INSTANCE_NAME' => $installData['instance_name'], 'GENERIS_SESSION_NAME' => self::generateSessionName(), 'ROOT_PATH' => $this->options['root_path'], 'FILES_PATH' => $installData['file_path'], 'ROOT_URL' => $installData['module_url'], 'DEFAULT_LANG' => $installData['module_lang'], 'DEBUG_MODE' => $installData['module_mode'] == 'debug' ? true : false, 'TIME_ZONE' => $installData['timezone']));
         /*
          * 5b - Prepare the file/cache folder (FILES_PATH) not yet defined)
          * @todo solve this more elegantly
          */
         $file_path = $installData['file_path'];
         if (is_dir($file_path)) {
             $this->log('i', 'Data from previous install found and will be removed');
             if (!helpers_File::emptyDirectory($installData['file_path'], true)) {
                 throw new common_exception_Error('Unable to empty ' . $installData['file_path'] . ' folder.');
             }
         } else {
             mkdir($installData['file_path'], 0700, true);
         }
         $cachePath = $installData['file_path'] . 'generis' . DIRECTORY_SEPARATOR . 'cache';
         mkdir($cachePath, 0700, true);
         /*
          * 6 - Run the extensions bootstrap
          */
         $this->log('d', 'Running the extensions bootstrap', 'INSTALL');
         require_once $this->options['root_path'] . 'generis/common/inc.extension.php';
         /*
          * 6b - Create cache persistence
          */
         common_persistence_Manager::addPersistence('cache', array('driver' => 'phpfile'));
         common_persistence_KeyValuePersistence::getPersistence('cache')->purge();
         /*
          * 6c - Create generis persistence 
          */
         common_persistence_Manager::addPersistence('default', $dbConfiguration);
         /*
          * 6d - Create generis user
          */
         // Init model creator and create the Generis User.
         $modelCreator = new tao_install_utils_ModelCreator(LOCAL_NAMESPACE);
         $modelCreator->insertGenerisUser(helpers_Random::generateString(8));
         /*
          * 7 - Add languages
          */
         $models = $modelCreator->getLanguageModels();
         foreach ($models as $ns => $modelFiles) {
             foreach ($modelFiles as $file) {
                 $this->log('d', "Inserting language description model '" . $file . "'", 'INSTALL');
                 $modelCreator->insertLocalModel($file);
             }
         }
         /*
          * 8 - Finish Generis Install
          */
         $generis = common_ext_ExtensionsManager::singleton()->getExtensionById('generis');
         $generisInstaller = new common_ext_GenerisInstaller($generis);
         $generisInstaller->install();
         /*
          * 9 - Install the extensions
          */
         $toInstall = array();
         foreach ($extensionIDs as $id) {
             try {
                 $ext = common_ext_ExtensionsManager::singleton()->getExtensionById($id);
                 if (!common_ext_ExtensionsManager::singleton()->isInstalled($ext->getId())) {
                     $this->log('d', 'Extension ' . $id . ' needs to be installed');
                     $toInstall[$id] = $ext;
                 }
             } catch (common_ext_ExtensionException $e) {
                 $this->log('w', 'Extension ' . $id . ' not found');
             }
         }
         while (!empty($toInstall)) {
             $modified = false;
             foreach ($toInstall as $key => $extension) {
                 // if all dependencies are installed
                 $this->log('d', 'Considering extension ' . $key);
                 $installed = array_keys(common_ext_extensionsmanager::singleton()->getinstalledextensions());
                 $missing = array_diff(array_keys($extension->getDependencies()), $installed);
                 if (count($missing) == 0) {
                     try {
                         $importLocalData = $installData['import_local'] == true;
                         $extinstaller = new tao_install_ExtensionInstaller($extension, $importLocalData);
                         set_time_limit(300);
                         $extinstaller->install();
                         $this->log('ext', $key);
                         $this->log('i', 'Extension ' . $key . ' installed');
                     } catch (common_ext_ExtensionException $e) {
                         $this->log('w', 'Exception(' . $e->getMessage() . ') during install for extension "' . $extension->getId() . '"');
                         throw new tao_install_utils_Exception("An error occured during the installation of extension '" . $extension->getId() . "'.");
                     }
                     unset($toInstall[$key]);
                     $modified = true;
                 } else {
                     $missing = array_diff($missing, array_keys($toInstall));
                     foreach ($missing as $extID) {
                         $this->log('d', 'Extension ' . $extID . ' is required but missing, added to install list');
                         $toInstall[$extID] = common_ext_ExtensionsManager::singleton()->getExtensionById($extID);
                         $modified = true;
                     }
                 }
             }
             // no extension could be installed, and no new requirements was added
             if (!$modified) {
                 throw new common_exception_Error('Unfulfilable/Cyclic reference found in extensions');
             }
         }
         /*
          *  9bis - Generates client side translation bundles (depends on extension install)
          */
         $this->log('i', 'Generates client side translation bundles', 'INSTALL');
         //
         $files = tao_models_classes_LanguageService::singleton()->generateClientBundles();
         /*
          *  10 - Insert Super User
          */
         $this->log('i', 'Spawning SuperUser ' . $installData['user_login'], 'INSTALL');
         $modelCreator->insertSuperUser(array('login' => $installData['user_login'], 'password' => core_kernel_users_Service::getPasswordHash()->encrypt($installData['user_pass1']), 'userLastName' => $installData['user_lastname'], 'userFirstName' => $installData['user_firstname'], 'userMail' => $installData['user_email'], 'userDefLg' => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang' . $installData['module_lang'], 'userUILg' => 'http://www.tao.lu/Ontologies/TAO.rdf#Lang' . $installData['module_lang'], 'userTimezone' => TIME_ZONE));
         /*
          *  11 - Secure the install for production mode
          */
         if ($installData['module_mode'] == 'production') {
             $extensions = common_ext_ExtensionsManager::singleton()->getInstalledExtensions();
             $this->log('i', 'Securing tao for production', 'INSTALL');
             // 11.1 Remove Generis User
             $dbCreator->removeGenerisUser();
             // 11.2 Protect TAO dist
             $shield = new tao_install_utils_Shield(array_keys($extensions));
             $shield->disableRewritePattern(array("!/test/", "!/doc/"));
             $shield->denyAccessTo(array('views/sass', 'views/js/test', 'views/build'));
             $shield->protectInstall();
         }
         /*
          *  12 - Create the version file
          */
         $this->log('d', 'Creating TAO version file', 'INSTALL');
         file_put_contents($installData['file_path'] . 'version', TAO_VERSION);
     } catch (Exception $e) {
         if ($this->retryInstallation($e)) {
             return;
         }
         // In any case, we transmit a single exception type (at the moment)
         // for a clearer API for client code.
         $this->log('e', 'Error Occurs : ' . $e->getMessage() . $e->getTraceAsString(), 'INSTALL');
         throw new tao_install_utils_Exception($e->getMessage(), 0, $e);
     }
 }
 /**
  * It is sometimes necessary to identify the link between assessmentItemRefs described in a QTI Test definition and the resources
  * describing items in IMS Manifest file. This utility method helps you to achieve this.
  * 
  * The method will return an array describing the IMS Manifest resources that were found in an IMS Manifest file on basis of
  * the assessmentItemRefs found in an AssessmentTest definition. The keys of the arrays are assessmentItemRef identifiers and
  * values are IMS Manifest Resources. 
  * 
  * If an IMS Manifest Resource cannot be found for a given assessmentItemRef, the value in the returned array will be false.
  * 
  * @param XmlDocument $test A QTI Test Definition.
  * @param taoQtiTest_models_classes_ManifestParser $manifestParser A Manifest Parser.
  * @param string $basePath The base path of the folder the IMS archive is exposed as a file system component.
  * @return array An array containing two arrays (items and dependencies) where keys are identifiers and values are oat\taoQtiItem\model\qti\Resource objects or false.
  */
 public static function buildAssessmentItemRefsTestMap(XmlDocument $test, taoQtiTest_models_classes_ManifestParser $manifestParser, $basePath)
 {
     $assessmentItemRefs = $test->getDocumentComponent()->getComponentsByClassName('assessmentItemRef');
     $map = array('items' => array(), 'dependencies' => array());
     $itemResources = $manifestParser->getResources(array('imsqti_item_xmlv2p1', 'imsqti_apipitem_xmlv2p1'), taoQtiTest_models_classes_ManifestParser::FILTER_RESOURCE_TYPE);
     $allResources = $manifestParser->getResources();
     // cleanup $basePath.
     $basePath = rtrim($basePath, "/\\");
     $basePath = helpers_File::truePath($basePath);
     $basePath .= DIRECTORY_SEPARATOR;
     $documentURI = preg_replace('/^file:\\//', '', $test->getDomDocument()->documentURI);
     $testPathInfo = pathinfo($documentURI);
     $testBasePath = tao_helpers_File::truePath($testPathInfo['dirname']) . DIRECTORY_SEPARATOR;
     foreach ($assessmentItemRefs as $itemRef) {
         // Find the QTI Resource (in IMS Manifest) related to the item ref.
         // To achieve this, we compare their path.
         $itemRefRelativeHref = str_replace('/', DIRECTORY_SEPARATOR, $itemRef->getHref());
         $itemRefRelativeHref = ltrim($itemRefRelativeHref, "/\\");
         $itemRefCanonicalHref = helpers_File::truePath($testBasePath . $itemRefRelativeHref);
         $map['items'][$itemRef->getIdentifier()] = false;
         // Compare with items referenced in the manifest.
         foreach ($itemResources as $itemResource) {
             $itemResourceRelativeHref = str_replace('/', DIRECTORY_SEPARATOR, $itemResource->getFile());
             $itemResourceRelativeHref = ltrim($itemResourceRelativeHref, "/\\");
             $itemResourceCanonicalHref = helpers_File::truePath($basePath . $itemResourceRelativeHref);
             // With some Windows flavours (Win7, Win8), the $itemRefCanonicalHref comes out with
             // a leading 'file:\' component. Let's clean this. (str_replace is binary-safe \0/)
             $os = tao_helpers_Environment::getOperatingSystem();
             if ($os === 'WINNT' || $os === 'WIN32' || $os === 'Windows') {
                 $itemRefCanonicalHref = str_replace('file:\\', '', $itemRefCanonicalHref);
                 // And moreover, it sometimes refer the temp directory as Windows\TEMP instead of Windows\Temp.
                 $itemRefCanonicalHref = str_replace('\\TEMP\\', '\\Temp\\', $itemRefCanonicalHref);
             }
             // With some MacOS flavours, the $itemRefCanonicalHref comes out with
             // a leading '/private' component. Clean it!
             if ($os === 'Darwin') {
                 $itemRefCanonicalHref = str_replace('/private', '', $itemRefCanonicalHref);
             }
             if ($itemResourceCanonicalHref == $itemRefCanonicalHref && is_file($itemResourceCanonicalHref)) {
                 // assessmentItemRef <-> IMS Manifest resource successful binding!
                 $map['items'][$itemRef->getIdentifier()] = $itemResource;
                 //get dependencies for each item
                 foreach ($itemResource->getDependencies() as $dependencyIdentifier) {
                     /** @var taoQtiTest_models_classes_QtiResource $resource */
                     foreach ($allResources as $resource) {
                         if ($dependencyIdentifier == $resource->getIdentifier()) {
                             $map['dependencies'][$dependencyIdentifier] = $resource;
                             break;
                         }
                     }
                 }
                 break;
             }
         }
     }
     return $map;
 }