/**
  * Updater
  *
  * @param string $initialVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     $this->skip('0.1', '0.2.4');
     if ($this->isVersion('0.2.4')) {
         $setupPortableElementFileStorage = new SetupPortableElementFileStorage();
         $setupPortableElementFileStorage->setServiceLocator($this->getServiceManager());
         $setupPortableElementFileStorage([]);
         $registerPicModel = new RegisterPicModel();
         $registerPicModel->setServiceLocator($this->getServiceManager());
         $registerPicModel([]);
         $setQtiCreatorConfig = new SetQtiCreatorConfig();
         $setQtiCreatorConfig([]);
         $registerClientProvider = new RegisterClientProvider();
         $registerClientProvider([]);
         $testManagerRole = $this->getResource('http://www.tao.lu/Ontologies/TAOItem.rdf#ItemsManagerRole');
         $QTIManagerRole = $this->getResource('http://www.tao.lu/Ontologies/TAOItem.rdf#QTIManagerRole');
         $testTakerRole = $this->getResource(INSTANCE_ROLE_DELIVERY);
         $accessService = \funcAcl_models_classes_AccessService::singleton();
         $accessService->grantModuleAccess($testManagerRole, 'qtiItemPic', 'PciLoader');
         $accessService->grantModuleAccess($QTIManagerRole, 'qtiItemPic', 'PciLoader');
         $accessService->grantModuleAccess($testTakerRole, 'qtiItemPic', 'PciLoader');
         HookRegistry::getRegistry()->remove('picCreator');
         $this->setVersion('1.0.0');
     }
     $this->skip('1.0.0', '1.1.0');
     if ($this->isVersion('1.1.0')) {
         call_user_func(new RegisterPicStudentToolbar(), ['0.2.0']);
         call_user_func(new RegisterPicStudentToolSample(), ['0.2.0']);
         $this->setVersion('1.2.0');
     }
 }
 /**
  * @depends testSet
  * 
  * @author Lionel Lecaque, lionel@taotesting.com
  */
 public function testRemove()
 {
     $interactions = HookRegistry::getRegistry()->getMap();
     $this->assertTrue(isset($interactions['fakeInteraction']));
     HookRegistry::getRegistry()->remove('fakeInteraction');
     $interactions = HookRegistry::getRegistry()->getMap();
     $this->assertFalse(isset($interactions['fakeInteraction']));
 }
Example #3
0
 /**
  *
  * @param string $currentVersion
  * @return string $versionUpdatedTo
  */
 public function update($initialVersion)
 {
     if ($this->isBetween('0', '0.2.1')) {
         $this->setVersion('0.2.1');
     }
     if ($this->isVersion('0.2.1')) {
         HookRegistry::getRegistry()->remove('pciSamplesCreator');
         $this->setVersion('1.0.0');
     }
     $this->skip('1.0.0', '1.2.0');
     if ($this->isVersion('1.2.0')) {
         call_user_func(new RegisterPciTextReader(), ['0.4.0']);
         $this->setVersion('1.3.0');
     }
 }
<?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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
 *               
 * 
 */
use oat\taoQtiItem\model\HookRegistry;
HookRegistry::add('pciCreator', 'oat\\qtiItemPci\\model\\CreatorHook');
 public function index()
 {
     $config = new CreatorConfig();
     $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
     $creatorConfig = $ext->getConfig('qtiCreator');
     if (is_array($creatorConfig)) {
         foreach ($creatorConfig as $prop => $value) {
             $config->setProperty($prop, $value);
         }
     }
     if ($this->hasRequestParameter('instance')) {
         //uri:
         $itemUri = tao_helpers_Uri::decode($this->getRequestParameter('instance'));
         $config->setProperty('uri', $itemUri);
         //get label:
         $rdfItem = new core_kernel_classes_Resource($itemUri);
         $config->setProperty('label', $rdfItem->getLabel());
         //set the current data lang in the item content to keep the integrity
         //@todo : allow preview in a language other than the one in the session
         $lang = \common_session_SessionManager::getSession()->getDataLanguage();
         $config->setProperty('lang', $lang);
         //base url:
         $url = tao_helpers_Uri::url('getFile', 'QtiCreator', 'taoQtiItem', array('uri' => $itemUri, 'lang' => $lang));
         $config->setProperty('baseUrl', $url . '&relPath=');
     }
     $mediaSourcesUrl = tao_helpers_Uri::url('getMediaSources', 'QtiCreator', 'taoQtiItem');
     $config->setProperty('mediaSourcesUrl', $mediaSourcesUrl);
     //initialize all registered hooks:
     $hookClasses = HookRegistry::getRegistry()->getMap();
     foreach ($hookClasses as $hookClass) {
         $hook = new $hookClass();
         $hook->init($config);
     }
     $config->init();
     $this->setData('config', $config->toArray());
     $this->setView('QtiCreator/index.tpl');
 }
 /**
  * 
  * @author Lionel Lecaque, lionel@taotesting.com
  * @param string $key
  * @param string $class
  * @deprecated use set directly
  */
 public static function add($key, $phpClass)
 {
     HookRegistry::getRegistry()->set($key, $phpClass);
 }
 /**
  * Get the configuration of the Item Creator
  * @param core_kernel_classes_Resource $item the selected item
  * @return CreatorConfig the configration
  */
 protected function getCreatorConfig(core_kernel_classes_Resource $item)
 {
     $config = new CreatorConfig();
     $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
     $creatorConfig = $ext->getConfig('qtiCreator');
     if (is_array($creatorConfig)) {
         foreach ($creatorConfig as $prop => $value) {
             $config->setProperty($prop, $value);
         }
     }
     $config->setProperty('uri', $item->getUri());
     $config->setProperty('label', $item->getLabel());
     //set the current data lang in the item content to keep the integrity
     //@todo : allow preview in a language other than the one in the session
     $lang = \common_session_SessionManager::getSession()->getDataLanguage();
     $config->setProperty('lang', $lang);
     //base url:
     $url = tao_helpers_Uri::url('getFile', 'QtiCreator', 'taoQtiItem', array('uri' => $item->getUri(), 'lang' => $lang, 'relPath' => ''));
     $config->setProperty('baseUrl', $url);
     //map the multi column config to the plugin
     //TODO migrate the config
     if ($config->getProperty('multi-column') == true) {
         $config->addPlugin('blockAdder', 'taoQtiItem/qtiCreator/plugins/content/blockAdder', 'content');
     }
     $mediaSourcesUrl = tao_helpers_Uri::url('getMediaSources', 'QtiCreator', 'taoQtiItem');
     $config->setProperty('mediaSourcesUrl', $mediaSourcesUrl);
     //initialize all registered hooks:
     $hookClasses = HookRegistry::getRegistry()->getMap();
     foreach ($hookClasses as $hookClass) {
         $hook = new $hookClass();
         $hook->init($config);
     }
     $config->init();
     return $config;
 }
<?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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
 *               
 * 
 */
use oat\taoQtiItem\model\HookRegistry;
HookRegistry::add('picCreator', 'oat\\qtiItemPic\\model\\CreatorHook');