/** * 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'])); }
/** * * @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'); } }
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; }