/** * Will make the Global Manager include the Management Role of the extension * to install (if it exists). * * @access public * @author Jerome Bogaerts <*****@*****.**> * @return void * @since 2.4 */ public function installManagementRole() { // Try to get a Management Role described by the extension itself. // (this information comes actually from the Manifest of the extension) $roleUri = $this->extension->getManifest()->getManagementRoleUri(); if (!empty($roleUri)) { $role = new core_kernel_classes_Resource($roleUri); $roleService = tao_models_classes_RoleService::singleton(); if (!$role->exists()) { // Management role does not exist yet, so we create it $roleClass = new core_kernel_classes_Class(CLASS_MANAGEMENTROLE); $roleLabel = $this->extension->getId() . ' Manager'; $role = $roleClass->createInstance($roleLabel, $roleLabel . ' Role', $role->getUri()); $roleService->includeRole($role, new core_kernel_classes_Resource(INSTANCE_ROLE_BACKOFFICE)); } // Take the Global Manager role and make it include // the Management role of the currently installed extension. if ($role->getUri() !== INSTANCE_ROLE_GLOBALMANAGER) { $globalManagerRole = new core_kernel_classes_Resource(INSTANCE_ROLE_GLOBALMANAGER); $roleService->includeRole($globalManagerRole, $role); } common_Logger::d("Management Role " . $role->getUri() . " created for extension '" . $this->extension->getId() . "'."); } else { // There is no Management role described by the Extension Manifest. common_Logger::i("No management role for extension '" . $this->extension->getId() . "'."); } }
public function tearDown() { parent::tearDown(); $userService = tao_models_classes_UserService::singleton(); $roleService = tao_models_classes_RoleService::singleton(); if ($this->user != null) { $userService->removeUser($this->user); } if ($this->testRole) { $roleService->removeRole($this->testRole); } }
/** * (non-PHPdoc) * @see common_ext_ExtensionUpdater::update() */ public function update($initialVersion) { $current = $initialVersion; if ($current == '0.0.1' || $current == '0.1.0' || $current == '0.1.1') { OntologyUpdater::syncModels(); $current = '0.1.2'; } if ($current == '0.1.2') { OntologyUpdater::syncModels(); $accessService = \funcAcl_models_classes_AccessService::singleton(); $roleService = \tao_models_classes_RoleService::singleton(); $testCenterManager = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/generis.rdf#TestCenterManager'); //revoke access right to test center manager $accessService->revokeExtensionAccess($testCenterManager, 'taoTestCenter'); $roleService->removeRole($testCenterManager); $current = '0.2'; } $this->setVersion($current); $this->skip('0.2', '0.3.0'); }
/** * Manage permissions * @requiresRight id GRANT */ public function adminPermissions() { $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id')); $accessRights = AdminService::getUsersPermissions($resource->getUri()); $this->setData('privileges', PermissionProvider::getRightLabels()); $users = array(); $roles = array(); foreach ($accessRights as $uri => $privileges) { $identity = new \core_kernel_classes_Resource($uri); if ($identity->isInstanceOf(\tao_models_classes_RoleService::singleton()->getRoleClass())) { $roles[$uri] = array('label' => $identity->getLabel(), 'privileges' => $privileges); } else { $users[$uri] = array('label' => $identity->getLabel(), 'privileges' => $privileges); } } $this->setData('users', $users); $this->setData('roles', $roles); $this->setData('isClass', $resource->isClass()); $this->setData('uri', $resource->getUri()); $this->setData('label', _dh($resource->getLabel())); $this->setView('AdminAccessController/index.tpl'); }
/** * Edit a group instance * @return void */ public function editRole() { $clazz = $this->getCurrentClass(); $role = $this->getCurrentInstance(); $formContainer = new tao_actions_form_Role($clazz, $role); $myForm = $formContainer->getForm(); if ($myForm->isSubmited()) { if ($myForm->isValid()) { $formValues = $myForm->getValues(); $roleService = tao_models_classes_RoleService::singleton(); $includedRolesProperty = new core_kernel_classes_Property(PROPERTY_ROLE_INCLUDESROLE); // We have to make the difference between the old list // of included roles and the new ones. $oldIncludedRolesUris = $role->getPropertyValues($includedRolesProperty); $newIncludedRolesUris = $formValues[PROPERTY_ROLE_INCLUDESROLE]; $removeIncludedRolesUris = array_diff($oldIncludedRolesUris, $newIncludedRolesUris); $addIncludedRolesUris = array_diff($newIncludedRolesUris, $oldIncludedRolesUris); // Make the changes according to the detected differences. foreach ($removeIncludedRolesUris as $rU) { $r = new core_kernel_classes_Resource($rU); $roleService->unincludeRole($role, $r); } foreach ($addIncludedRolesUris as $aU) { $r = new core_kernel_classes_Resource($aU); $roleService->includeRole($role, $r); } // Let's deal with other properties the usual way. unset($formValues[$includedRolesProperty->getUri()]); $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($role); $role = $binder->bind($myForm->getValues()); core_kernel_users_Cache::removeIncludedRoles($role); // flush cache for this role. $this->setData('selectNode', tao_helpers_Uri::encode($role->getUri())); $this->setData('message', __('Role saved')); $this->setData('reload', true); } } $this->setData('uri', tao_helpers_Uri::encode($role->getUri())); $this->setData('classUri', tao_helpers_Uri::encode($clazz->getUri())); $this->setData('formTitle', 'Edit Role'); $this->setData('myForm', $myForm->render()); $this->setView('roles/form.tpl'); }
/** * * @param string $initialVersion * @return string $versionUpdatedTo */ public function update($initialVersion) { $currentVersion = $initialVersion; //migrate from 0.1 to 0.1.1 if ($currentVersion == '0.1') { // mediaSources set in 0.2 $currentVersion = '0.1.1'; } if ($currentVersion == '0.1.1') { FileManager::setFileManagementModel(new SimpleFileManagement()); // mediaSources unset in 0.2 $currentVersion = '0.1.2'; } if ($currentVersion == '0.1.2') { //add alt text to media manager $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'alt_text.rdf'; $adapter = new \tao_helpers_data_GenerisAdapterRdf(); if ($adapter->import($file)) { $currentVersion = '0.1.3'; } else { \common_Logger::w('Import failed for ' . $file); } } if ($currentVersion == '0.1.3') { OntologyUpdater::correctModelId(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'alt_text.rdf'); $currentVersion = '0.1.4'; } if ($currentVersion == '0.1.4') { //modify config files due to the new interfaces relation $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $tao->unsetConfig('mediaManagementSources'); $tao->unsetConfig('mediaBrowserSources'); TaoMediaService::singleton()->addMediaSource(new MediaSource()); //modify links in item content $service = \taoItems_models_classes_ItemsService::singleton(); $items = $service->getAllByModel('http://www.tao.lu/Ontologies/TAOItem.rdf#QTI'); foreach ($items as $item) { $itemContent = $service->getItemContent($item); $itemContent = preg_replace_callback('/src="mediamanager\\/([^"]+)"/', function ($matches) { $mediaClass = MediaService::singleton()->getRootClass(); $medias = $mediaClass->searchInstances(array(MEDIA_LINK => $matches[1]), array('recursive' => true)); $media = array_pop($medias); $uri = ''; if (!is_null($media) && $media->exists()) { $uri = \tao_helpers_Uri::encode($media->getUri()); } return 'src="taomedia://mediamanager/' . $uri . '"'; }, $itemContent); $itemContent = preg_replace_callback('/src="local\\/([^"]+)"/', function ($matches) { return 'src="' . $matches[1] . '"'; }, $itemContent); $service->setItemContent($item, $itemContent); } $currentVersion = '0.2.0'; } if ($currentVersion === '0.2.0') { $accessService = \funcAcl_models_classes_AccessService::singleton(); //revoke access right to back office $backOffice = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole'); $accessService->revokeExtensionAccess($backOffice, 'taoMediaManager'); //grant access right to media manager $mediaManager = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOMedia.rdf#MediaManagerRole'); $accessService->grantExtensionAccess($mediaManager, 'taoMediaManager'); $currentVersion = '0.2.1'; } if ($currentVersion === '0.2.1') { //include mediamanager into globalmanager $mediaManager = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOMedia.rdf#MediaManagerRole'); $globalManager = new \core_kernel_Classes_Resource('http://www.tao.lu/Ontologies/TAO.rdf#GlobalManagerRole'); \tao_models_classes_RoleService::singleton()->includeRole($globalManager, $mediaManager); $currentVersion = '0.2.2'; } if ($currentVersion === '0.2.2') { //copy file from /media to data/taoMediaManager/media and delete /media $dataPath = FILES_PATH . 'taoMediaManager' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR; $dir = dirname(dirname(__DIR__)) . '/media'; if (file_exists($dir)) { if (\tao_helpers_File::copy($dir, $dataPath)) { $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS); $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); foreach ($files as $file) { if ($file->isDir()) { rmdir($file->getRealPath()); } else { unlink($file->getRealPath()); } } rmdir($dir); $currentVersion = '0.2.3'; } } else { $currentVersion = '0.2.3'; } } if ($currentVersion === '0.2.3') { $accessService = \funcAcl_models_classes_AccessService::singleton(); //grant access to item author $itemAuthor = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOItem.rdf#ItemAuthor'); $accessService->grantExtensionAccess($itemAuthor, 'taoMediaManager'); $currentVersion = '0.2.4'; } if ($currentVersion === '0.2.4') { $mediaClass = MediaService::singleton()->getRootClass(); $fileManager = FileManager::getFileManagementModel(); foreach ($mediaClass->getInstances(true) as $media) { $fileLink = $media->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LINK)); $fileLink = $fileLink instanceof \core_kernel_classes_Resource ? $fileLink->getUri() : (string) $fileLink; $filePath = $fileManager->retrieveFile($fileLink); $mimeType = \tao_helpers_File::getMimeType($filePath); $mimeType = $mimeType === 'application/xhtml+xml' ? 'application/qti+xml' : $mimeType; $media->setPropertyValue(new \core_kernel_classes_Property(MEDIA_MIME_TYPE), $mimeType); } $currentVersion = '0.2.5'; } if ($currentVersion === '0.2.5') { $fileManager = FileManager::getFileManagementModel(); $iterator = new \core_kernel_classes_ResourceIterator(array(MediaService::singleton()->getRootClass())); foreach ($iterator as $media) { $fileLink = $media->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LINK)); $fileLink = $fileLink instanceof \core_kernel_classes_Resource ? $fileLink->getUri() : (string) $fileLink; $filePath = $fileManager->retrieveFile($fileLink); try { SharedStimulusImporter::isValidSharedStimulus($filePath); $media->editPropertyValues(new \core_kernel_classes_Property(MEDIA_MIME_TYPE), 'application/qti+xml'); } catch (\Exception $e) { $mimeType = \tao_helpers_File::getMimeType($filePath); $media->editPropertyValues(new \core_kernel_classes_Property(MEDIA_MIME_TYPE), $mimeType); } } $currentVersion = '0.3.0'; } $this->skip('0.3.0', '0.5.1'); }
/** * get the list of roles * @param array $resourceIds * @return array key => value with key = user Uri and value = user Label */ protected function getRoleList() { $roleService = \tao_models_classes_RoleService::singleton(); $roles = array(); foreach ($roleService->getAllRoles() as $role) { $roles[$role->getUri()] = _dh($role->getLabel()); } return $roles; }
/** * Shows the access to the actions of a controller for a specific role * * @throws Exception */ public function getActions() { if (!tao_helpers_Request::isAjax()) { throw new Exception("wrong request mode"); } else { $role = new core_kernel_classes_Resource($this->getRequestParameter('role')); $included = array(); foreach (tao_models_classes_RoleService::singleton()->getIncludedRoles($role) as $includedRole) { $included[] = $includedRole->getUri(); } $module = new core_kernel_classes_Resource($this->getRequestParameter('module')); $controllerClassName = funcAcl_helpers_Map::getControllerFromUri($module->getUri()); $controllerAccess = funcAcl_helpers_Cache::getControllerAccess($controllerClassName); $actions = array(); foreach (ControllerHelper::getActions($controllerClassName) as $actionName) { $uri = funcAcl_helpers_Map::getUriForAction($controllerClassName, $actionName); $part = explode('#', $uri); list($type, $extId, $modId, $actId) = explode('_', $part[1]); $allowedRoles = isset($controllerAccess['actions'][$actionName]) ? array_merge($controllerAccess['module'], $controllerAccess['actions'][$actionName]) : $controllerAccess['module']; $access = count(array_intersect($included, $allowedRoles)) > 0 ? self::ACCESS_INHERITED : (in_array($role->getUri(), $allowedRoles) ? self::ACCESS_FULL : self::ACCESS_NONE); $actions[$actId] = array('uri' => $uri, 'access' => $access); } ksort($actions); $this->returnJson($actions); } }
/** * Test generation of users: */ public function testCreateUsers() { error_reporting(E_ALL); if ($this->createUsers) { $roleService = wfEngine_models_classes_RoleService::singleton(); $usec = time(); $this->userLogins = array(); $this->users = array(); //create roles and users: $roleService = tao_models_classes_RoleService::singleton(); $wfRole = new core_kernel_classes_Resource(INSTANCE_ROLE_WORKFLOW); $this->roles = array(); $this->roles['consortium'] = $roleService->addRole('consortium - ' . $usec, $wfRole); $this->roles['NPM'] = $roleService->addRole('NPMs - ' . $usec, $wfRole); $this->roles['translator'] = $roleService->addRole('translators - ' . $usec, $wfRole); $this->roles['reconciler'] = $roleService->addRole('reconcilers - ' . $usec, $wfRole); $this->roles['verifier'] = $roleService->addRole('verifiers - ' . $usec, $wfRole); $this->roles['developer'] = $roleService->addRole('developers - ' . $usec, $wfRole); $this->roles['testDeveloper'] = $roleService->addRole('test developers - ' . $usec, $wfRole); $classRole = new core_kernel_classes_Class(CLASS_ROLE); $translatorClass = $classRole->createSubClass('translatorsTestClass'); foreach ($this->roles as $role) { $role->setType($translatorClass); $role->removeType($classRole); } //create the country code and language code properties to the wf user class: $propUserCountryCode = $this->createTranslationProperty('CountryCode', '', '', $translatorClass); $propUserLangCode = $this->createTranslationProperty('LanguageCode', '', '', $translatorClass); //generate users' logins: $this->userLogins = array(); $this->roleLogins = array(); $this->userLogins['consortium'] = array(); $memberConsortium = 1; for ($i = 1; $i <= $memberConsortium; $i++) { $this->userLogins['consortium'][$i] = 'consortium_' . $i . '_' . $usec; //the process admin $this->roleLogins[$this->roles['consortium']->getUri()][] = $this->userLogins['consortium'][$i]; } $this->userLogins['developer'] = array(); $nbDevelopers = 6; for ($i = 1; $i <= $nbDevelopers; $i++) { $this->userLogins['developer'][$i] = 'developer_' . $i . '_' . $usec; //ETS_01, ETS_02, etc. $this->roleLogins[$this->roles['developer']->getUri()][] = $this->userLogins['developer'][$i]; } $this->userLogins['testDeveloper'] = array(); $nbTestDevelopers = 3; for ($i = 1; $i <= $nbTestDevelopers; $i++) { $this->userLogins['testDeveloper'][$i] = 'testDeveloper_' . $i . '_' . $usec; //test creators $this->roleLogins[$this->roles['testDeveloper']->getUri()][] = $this->userLogins['testDeveloper'][$i]; } $nbTranslatorsByCountryLang = 3; foreach ($this->langCountries as $countryCode => $languageCodes) { $this->userLogins[$countryCode] = array(); //one NPM by country $this->userLogins[$countryCode]['NPM'] = 'NPM_' . $countryCode . '_' . $usec; $this->roleLogins[$this->roles['NPM']->getUri()][] = $this->userLogins[$countryCode]['NPM']; foreach ($languageCodes as $languageCode) { //one reconciler and verifier by country-language $this->userLogins[$countryCode][$languageCode] = array('translator' => array(), 'reconciler' => 'reconciler_' . $countryCode . '_' . $languageCode . '_' . $usec, 'verifier' => 'verifier_' . $countryCode . '_' . $languageCode . '_' . $usec); $this->roleLogins[$this->roles['reconciler']->getUri()][] = $this->userLogins[$countryCode][$languageCode]['reconciler']; $this->roleLogins[$this->roles['verifier']->getUri()][] = $this->userLogins[$countryCode][$languageCode]['verifier']; //as many translators as wanted: for ($i = 1; $i <= $nbTranslatorsByCountryLang; $i++) { $this->userLogins[$countryCode][$languageCode]['translator'][$i] = 'translator_' . $countryCode . '_' . $languageCode . '_' . $i . '_' . $usec; $this->roleLogins[$this->roles['translator']->getUri()][] = $this->userLogins[$countryCode][$languageCode]['translator'][$i]; } } } $this->createUsers($this->userLogins); foreach ($this->roleLogins as $roleUri => $usrs) { $role = new core_kernel_classes_Resource($roleUri); $userUris = array(); foreach ($usrs as $login) { if (isset($this->users[$login])) { $matchesarray = array(); if (preg_match_all('/translator_(.[^_]*)_(.[^_]*)_/', $login, $matchesarray) > 0) { $countryCode = $matchesarray[1][0]; $langCode = $matchesarray[2][0]; $this->assertTrue($this->users[$login]->setPropertyValue($propUserCountryCode, $countryCode)); $this->assertTrue($this->users[$login]->setPropertyValue($propUserLangCode, $langCode)); } $userUris[] = $this->users[$login]->getUri(); } } $this->assertTrue($roleService->setRoleToUsers($role, $userUris)); } } }
/** * @param string $initialVersion * @return string string */ public function update($initialVersion) { $currentVersion = $initialVersion; $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoProctoring'); if ($currentVersion == '0.1') { $service = new DeliveryService(); $ext->setConfig('delivery', $service); $currentVersion = '0.2'; } if ($currentVersion == '0.2') { // $service = new TestCenterService(); // $ext->setConfig('testCenter', $service); $currentVersion = '0.3'; } if ($currentVersion == '0.3') { //grant access to test taker $testTakerRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_DELIVERY); $accessService = \funcAcl_models_classes_AccessService::singleton(); $accessService->grantModuleAccess($testTakerRole, 'taoProctoring', 'DeliveryServer'); $mpManagerRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole'); $accessService->revokeModuleAccess($mpManagerRole, 'taoProctoring', 'DeliveryServer'); //replace delivery server $entryPointService = EntryPointService::getRegistry(); $entryPointService->overrideEntryPoint('deliveryServer', new ProctoringDeliveryServer()); $this->getServiceManager()->register(EntryPointService::SERVICE_ID, $entryPointService); $currentVersion = '0.4'; } if ($currentVersion == '0.4') { OntologyUpdater::syncModels(); $ext->unsetConfig('testCenter'); $accessService = \funcAcl_models_classes_AccessService::singleton(); $roleService = \tao_models_classes_RoleService::singleton(); //grant access right to proctoring manager $testCenterManager = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#TestCenterManager'); $globalManager = new \core_kernel_Classes_Resource('http://www.tao.lu/Ontologies/TAO.rdf#BackOfficeRole'); $roleService->includeRole($globalManager, $testCenterManager); $accessService->grantModuleAccess($testCenterManager, 'taoProctoring', 'TestCenterManager'); //revoke access to legacy delivery server $testTakerRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_DELIVERY); $accessService->revokeModuleAccess($testTakerRole, 'taoDelivery', 'DeliveryServer'); //grant access to proctor role $proctorRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole'); $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'Delivery'); $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'Diagnostic'); $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'Reporting'); $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'TestCenter'); $currentVersion = '0.5'; } if ($currentVersion == '0.5') { try { $this->getServiceManager()->get(AssessmentResultsService::CONFIG_ID); } catch (ServiceNotFoundException $e) { $service = new AssessmentResultsService([AssessmentResultsService::OPTION_PRINTABLE_RUBRIC_TAG => 'x-tao-scorereport', AssessmentResultsService::OPTION_PRINT_REPORT_BUTTON => false]); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(AssessmentResultsService::CONFIG_ID, $service); } $currentVersion = '0.6'; } $this->setVersion($currentVersion); if ($this->isVersion('0.6')) { OntologyUpdater::syncModels(); //grant access to test site admin role $proctorRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#TestCenterAdministratorRole'); $accessService = \funcAcl_models_classes_AccessService::singleton(); $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'ProctorManager'); $this->setVersion('0.7'); } if ($this->isVersion('0.7')) { try { $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); } catch (ServiceNotFoundException $e) { $service = new DeliveryMonitoringService(array(DeliveryMonitoringService::OPTION_PERSISTENCE => 'default')); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(DeliveryMonitoringService::CONFIG_ID, $service); } include __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'createDeliveryMonitoringTables.php'; $this->setVersion('0.8.0'); } if ($this->isVersion('0.8.0')) { $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID); $eventManager->attach(TestChangedEvent::EVENT_NAME, array('oat\\taoProctoring\\model\\monitorCache\\update\\TestUpdate', 'testStateChange')); $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager); $this->setVersion('0.9.0'); } // nothign to do if ($this->isVersion('0.9.0')) { $this->setVersion('1.0.0'); } if ($this->isVersion('1.0.0')) { try { $this->getServiceManager()->get(DeliveryAuthorizationService::SERVICE_ID); } catch (ServiceNotFoundException $e) { $service = new DeliveryAuthorizationService(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(DeliveryAuthorizationService::SERVICE_ID, $service); } $this->setVersion('1.1.0'); } if ($this->isVersion('1.1.0')) { OntologyUpdater::syncModels(); $this->setVersion('1.2.0'); } if ($this->isVersion('1.2.0')) { try { $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID); } catch (ServiceNotFoundException $e) { $service = new DeliveryExecutionStateService(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(DeliveryExecutionStateService::SERVICE_ID, $service); } $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID); $eventManager->attach('oat\\taoTests\\models\\event\\TestChangedEvent', array('\\oat\\taoProctoring\\helpers\\DeliveryHelper', 'testStateChanged')); $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager); $this->setVersion('1.3.0'); } if ($this->isVersion('1.3.0')) { $proctoringExtension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoProctoring'); $proctoringExtension->setConfig('monitoringUserExtraFields', array()); $this->setVersion('1.4.0'); } $this->skip('1.4.0', '1.4.1'); $this->skip('1.4.1', '1.5.0'); if ($this->isVersion('1.5.0')) { try { $this->getServiceManager()->get(RdsDeliveryLogService::SERVICE_ID); } catch (ServiceNotFoundException $e) { $action = new RegisterProctoringLog(); $action->setServiceLocator($this->getServiceManager()); $action->__invoke(array('default')); } $this->setVersion('1.6.0'); } if ($this->isVersion('1.6.0')) { $settingsScript = new addDiagnosticSettings(); $settingsScript([]); $sqlScript = new createDiagnosticTable(); $sqlScript([]); //Grant access to the overridden controller $accessService = \funcAcl_models_classes_AccessService::singleton(); $taoClientDiagnosticManager = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/generis.rdf#taoClientDiagnosticManager'); $accessService->grantModuleAccess($taoClientDiagnosticManager, 'taoProctoring', 'DiagnosticChecker'); $anonymousRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole'); $accessService->grantModuleAccess($anonymousRole, 'taoProctoring', 'DiagnosticChecker'); $this->setVersion('1.7.0'); } $this->skip('1.7.0', '1.7.1'); if ($this->isVersion('1.7.1')) { $deliveryExecutionStateService = $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID); $deliveryExecutionStateService->setOption(DeliveryExecutionStateService::OPTION_TERMINATION_DELAY_AFTER_PAUSE, 'PT1H'); $this->getServiceManager()->register(DeliveryExecutionStateService::SERVICE_ID, $deliveryExecutionStateService); $this->setVersion('1.8.0'); } $this->skip('1.8.0', '1.9.0'); if ($this->isVersion('1.9.0')) { $persistence = $this->getServiceManager()->get(PaginatedStorage::SERVICE_ID)->getPersistence(); $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; /** @var \Doctrine\DBAL\Schema\Table $tableResults */ $tableResults = $schema->getTable(DiagnosticStorage::DIAGNOSTIC_TABLE); $tableResults->changeColumn(DiagnosticStorage::DIAGNOSTIC_TEST_CENTER, ['notnull' => false]); $tableResults->changeColumn(DiagnosticStorage::DIAGNOSTIC_WORKSTATION, ['notnull' => false]); $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } $this->setVersion('1.9.1'); } if ($this->isVersion('1.9.1')) { $assignmentService = new ProctoringAssignmentService(); $assignmentService->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(ProctoringAssignmentService::CONFIG_ID, $assignmentService); $deliveryExt = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); $deliveryServerConfig = $deliveryExt->getConfig('deliveryServer'); $deliveryServerOptions = $deliveryServerConfig->getOptions(); $deliveryServerService = new DeliveryServerService($deliveryServerOptions); $deliveryServerService->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(DeliveryServerService::CONFIG_ID, $deliveryServerService); $this->setVersion('1.9.2'); } $this->skip('1.9.2', '1.12.2'); if ($this->isVersion('1.12.2')) { $persistenceId = $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID)->getOption(DeliveryMonitoringService::OPTION_PERSISTENCE); $persistence = \common_persistence_Manager::getPersistence($persistenceId); $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $tableData = $schema->getTable(DeliveryMonitoringService::TABLE_NAME); $tableData->changeColumn(DeliveryMonitoringService::COLUMN_START_TIME, array('type' => \Doctrine\DBAL\Types\Type::getType('string'), 'notnull' => false, 'length' => 255)); $tableData->changeColumn(DeliveryMonitoringService::COLUMN_END_TIME, array('type' => \Doctrine\DBAL\Types\Type::getType('string'), 'notnull' => false, 'length' => 255)); } catch (SchemaException $e) { \common_Logger::i('Database Schema already up to date.'); } $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } $this->setVersion('1.12.3'); } if ($this->isVersion('1.12.3')) { try { $this->getServiceManager()->get(TestSessionConnectivityStatusService::SERVICE_ID); } catch (ServiceNotFoundException $e) { $service = new TestSessionConnectivityStatusService(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(TestSessionConnectivityStatusService::SERVICE_ID, $service); } $this->setVersion('1.13.0'); } if ($this->isVersion('1.13.0')) { $this->refreshMonitoringData(); $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID); $eventManager->attach('oat\\taoDelivery\\models\\classes\\execution\\event\\DeliveryExecutionState', ['oat\\taoProctoring\\model\\monitorCache\\update\\DeliveryExecutionStateUpdate', 'stateChange']); $eventManager->attach(EligiblityChanged::EVENT_NAME, ['oat\\taoProctoring\\model\\monitorCache\\update\\EligiblityUpdate', 'eligiblityChange']); $eventManager->attach(MetadataModified::class, ['oat\\taoProctoring\\model\\monitorCache\\update\\DeliveryUpdate', 'labelChange']); $eventManager->attach(MetadataModified::class, ['oat\\taoProctoring\\model\\monitorCache\\update\\TestTakerUpdate', 'propertyChange']); $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager); $this->setVersion('1.14.0'); } $this->skip('1.14.0', '1.14.1'); if ($this->isVersion('1.14.1')) { $this->refreshMonitoringData(); $this->setVersion('1.14.2'); } if ($this->isVersion('1.14.2') || $this->isVersion('1.14.3')) { $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); $config = $ext->getConfig('execution_service'); $config = new \oat\taoProctoring\model\execution\DeliveryExecutionService(['implementation' => $config]); $ext->setConfig('execution_service', $config); $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID); $eventManager->attach('oat\\taoDelivery\\models\\classes\\execution\\event\\DeliveryExecutionState', ['oat\\taoProctoring\\model\\monitorCache\\update\\DeliveryExecutionStateUpdate', 'stateChange']); $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager); OntologyUpdater::syncModels(); $this->refreshMonitoringData(); $this->setVersion('1.15.0'); } if ($this->isVersion('1.15.0')) { $this->refreshMonitoringData(); $this->setVersion('1.15.1'); } $this->skip('1.15.1', '1.16.2'); if ($this->isVersion('1.16.2')) { OntologyUpdater::syncModels(); $this->setVersion('1.17.0'); } $this->skip('1.17.0', '2.1.0'); if ($this->isVersion('2.1.0')) { $authService = $this->getServiceManager()->get(AuthorizationService::SERVICE_ID); if ($authService instanceof AuthorizationAggregator) { $authService->unregister(StateValidation::class); $authService->addProvider(new ProctorAuthorizationProvider()); $this->getServiceManager()->register(AuthorizationService::SERVICE_ID, $authService); } else { throw new \common_exception_Error('Incompatible AuthorizationService "' . get_class($authService) . '" found.'); } $this->setVersion('3.0.0'); } $this->skip('3.0.0', '3.0.6'); if ($this->isVersion('3.0.6')) { //grant access to test taker $globalManagerRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_GLOBALMANAGER); $accessService = \funcAcl_models_classes_AccessService::singleton(); $accessService->grantModuleAccess($globalManagerRole, 'taoProctoring', 'Irregularity'); $this->setVersion('3.1.0'); } if ($this->isVersion('3.1.0')) { $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID); $eventManager->attach('oat\\taoTests\\models\\event\\TestExecutionPausedEvent', ['oat\\taoProctoring\\model\\implementation\\DeliveryExecutionStateService', 'catchSessionPause']); $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager); $this->setVersion('3.1.1'); } $this->skip('3.1.1', '3.3.1'); if ($this->isVersion('3.3.1')) { $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); $config = $ext->getConfig('execution_service'); $implementation = $config->getImplementation(); $ext->setConfig('execution_service', $implementation); $this->setVersion('3.4.0'); } if ($this->isVersion('3.4.0')) { try { $this->getServiceManager()->get(TestSessionService::SERVICE_ID); } catch (ServiceNotFoundException $e) { $service = new TestSessionService(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(TestSessionService::SERVICE_ID, $service); } $this->setVersion('3.4.1'); } $this->skip('3.4.1', '3.6.3'); if ($this->isVersion('3.6.3')) { $deliveryMonitoringService = $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); $deliveryMonitoringService->setOption(DeliveryMonitoringService::OPTION_PRIMARY_COLUMNS, [DeliveryMonitoringService::COLUMN_DELIVERY_EXECUTION_ID, DeliveryMonitoringService::COLUMN_STATUS, DeliveryMonitoringService::COLUMN_CURRENT_ASSESSMENT_ITEM, DeliveryMonitoringService::COLUMN_TEST_TAKER, DeliveryMonitoringService::COLUMN_AUTHORIZED_BY, DeliveryMonitoringService::COLUMN_START_TIME, DeliveryMonitoringService::COLUMN_END_TIME]); $this->getServiceManager()->register(DeliveryMonitoringService::CONFIG_ID, $deliveryMonitoringService); $this->setVersion('3.6.5'); } $this->skip('3.6.4', '3.6.5'); if ($this->isVersion('3.6.5')) { $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID); $eventManager->detach('oat\\taoTests\\models\\event\\TestChangedEvent', array('\\oat\\taoProctoring\\helpers\\DeliveryHelper', 'testStateChanged')); $eventManager->attach('oat\\taoQtiTest\\models\\event\\QtiTestStateChangeEvent', array('\\oat\\taoProctoring\\helpers\\DeliveryHelper', 'testStateChanged')); $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager); $this->setVersion('3.6.6'); } $this->skip('3.6.6', '3.6.18'); if ($this->isVersion('3.6.18')) { $this->getServiceManager()->register(ProctoringTextConverter::SERVICE_ID, new ProctoringTextConverter()); $proctorRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole'); $accessService = \funcAcl_models_classes_AccessService::singleton(); $accessService->grantModuleAccess($proctorRole, 'taoProctoring', 'TextConverter'); $this->setVersion('3.7.0'); } $this->skip('3.7.0', '3.10.1'); if ($this->isVersion('3.10.1')) { try { $this->getServiceManager()->get(TestSessionHistoryService::SERVICE_ID); } catch (ServiceNotFoundException $e) { $service = new TestSessionHistoryService(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(TestSessionHistoryService::SERVICE_ID, $service); } $this->setVersion('3.11.0'); } if ($this->isVersion('3.11.0')) { // register timeHandling option try { $service = $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID); } catch (ServiceNotFoundException $e) { $service = new DeliveryExecutionStateService([DeliveryExecutionStateService::OPTION_TERMINATION_DELAY_AFTER_PAUSE => 'PT1H', DeliveryExecutionStateService::OPTION_TIME_HANDLING => false]); } $service->setOption(DeliveryExecutionStateService::OPTION_TIME_HANDLING, false); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(DeliveryExecutionStateService::SERVICE_ID, $service); // extend the data table $persistenceId = $this->getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID)->getOption(DeliveryMonitoringService::OPTION_PERSISTENCE); $persistence = \common_persistence_Manager::getPersistence($persistenceId); $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $tableData = $schema->getTable(DeliveryMonitoringService::TABLE_NAME); $tableData->addColumn(DeliveryMonitoringService::COLUMN_REMAINING_TIME, "string", array("notnull" => false, "length" => 255)); $tableData->addColumn(DeliveryMonitoringService::COLUMN_EXTRA_TIME, "string", array("notnull" => false, "length" => 255)); $tableData->addColumn(DeliveryMonitoringService::COLUMN_CONSUMED_EXTRA_TIME, "string", array("notnull" => false, "length" => 255)); } catch (SchemaException $e) { \common_Logger::i('Database Schema already up to date.'); } $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } $this->setVersion('3.12.0'); } $this->skip('3.12.0', '3.12.1'); if ($this->isVersion('3.12.1')) { OntologyUpdater::syncModels(); $this->setVersion('3.13.0'); } $this->skip('3.13.0', '3.13.5'); }