public function __invoke($params) { if (!isset($params[0])) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: InitRdsQueue PERSISTENCE_ID')); } $persistenceId = $params[0]; $serviceManager = ServiceManager::getServiceManager(); $persistence = \common_persistence_Manager::getPersistence($persistenceId); $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $queueTable = $schema->createtable(RdsQueue::QUEUE_TABLE_NAME); $queueTable->addOption('engine', 'MyISAM'); $queueTable->addColumn(RdsQueue::QUEUE_ID, "integer", array("notnull" => true, "autoincrement" => true)); $queueTable->addColumn(RdsQueue::QUEUE_STATUS, "string", array("notnull" => true, "length" => 50)); $queueTable->addColumn(RdsQueue::QUEUE_ADDED, "string", array("notnull" => true)); $queueTable->addColumn(RdsQueue::QUEUE_UPDATED, "string", array("notnull" => true)); $queueTable->addColumn(RdsQueue::QUEUE_OWNER, "string", array("notnull" => false, "length" => 255)); $queueTable->addColumn(RdsQueue::QUEUE_TASK, "string", array("notnull" => true, "length" => 4000)); $queueTable->setPrimaryKey(array(RdsQueue::QUEUE_ID)); $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } } catch (SchemaException $e) { \common_Logger::i('Database Schema already up to date.'); } $queue = new RdsQueue(array(RdsQueue::OPTION_PERSISTENCE => $persistenceId)); $serviceManager->register(Queue::CONFIG_ID, $queue); return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Setup rds queue successfully')); }
public function setUp() { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); TaoPhpUnitTestRunner::initTest(); $this->service = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); $this->persistence = \common_persistence_Manager::getPersistence('default'); }
public function __invoke($params) { $persistenceId = count($params) > 0 ? reset($params) : 'default'; $persistence = \common_persistence_Manager::getPersistence($persistenceId); $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $tableLog = $schema->createTable(RdsDeliveryLogService::TABLE_NAME); $tableLog->addOption('engine', 'InnoDB'); $tableLog->addColumn(RdsDeliveryLogService::ID, "integer", array("autoincrement" => true)); $tableLog->addColumn(RdsDeliveryLogService::DELIVERY_EXECUTION_ID, "string", array("notnull" => true, "length" => 255)); $tableLog->addColumn(RdsDeliveryLogService::EVENT_ID, "string", array("notnull" => true, "length" => 255)); $tableLog->addColumn(RdsDeliveryLogService::DATA, "text", array("notnull" => true)); $tableLog->addColumn(RdsDeliveryLogService::CREATED_AT, "string", array("notnull" => true, "length" => 255)); $tableLog->addColumn(RdsDeliveryLogService::CREATED_BY, "string", array("notnull" => true, "length" => 255)); $tableLog->setPrimaryKey(array(RdsDeliveryLogService::ID)); $tableLog->addIndex(array(RdsDeliveryLogService::DELIVERY_EXECUTION_ID), 'IDX_' . RdsDeliveryLogService::TABLE_NAME . '_' . RdsDeliveryLogService::DELIVERY_EXECUTION_ID); } 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->registerService(RdsDeliveryLogService::SERVICE_ID, new RdsDeliveryLogService(array(RdsDeliveryLogService::OPTION_PERSISTENCE => $persistenceId))); return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Registered proctoring log')); }
public static function getPersistence($driverId) { $returnValue = common_persistence_Manager::getPersistence($driverId); $class = get_called_class(); if (!$returnValue instanceof $class) { common_Logger::w('Got a ', get_class($returnValue) . ' instead of ' . $class); } return $returnValue; }
public function __invoke($params) { $service = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); $this->persistence = \common_persistence_Manager::getPersistence($service->getOption(DeliveryMonitoringService::OPTION_PERSISTENCE)); // Drop foreign key /** @var common_persistence_sql_pdo_SchemaManager $schemaManager */ $schemaManager = $this->persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $tableData = $schema->getTable(DeliveryMonitoringService::KV_TABLE_NAME); $tableData->removeForeignKey(DeliveryMonitoringService::KV_FK_PARENT); } catch (SchemaException $e) { \common_Logger::i('Database Schema already up to date.'); } $queries = $this->persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $this->persistence->exec($query); } //change parent_id column type $schemaManager = $this->persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $tableData = $schema->getTable(DeliveryMonitoringService::KV_TABLE_NAME); $tableData->changeColumn(DeliveryMonitoringService::KV_COLUMN_PARENT_ID, array('type' => Type::getType('string'), 'notnull' => true, 'length' => 255)); } catch (SchemaException $e) { \common_Logger::i('Database Schema already up to date.'); } $queries = $this->persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $this->persistence->exec($query); } //update parent_id column values $this->updateLinks(); //add foreign key. $schemaManager = $this->persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $tableLog = $schema->getTable(DeliveryMonitoringService::TABLE_NAME); $tableData = $schema->getTable(DeliveryMonitoringService::KV_TABLE_NAME); $tableData->addForeignKeyConstraint($tableLog, array(DeliveryMonitoringService::KV_COLUMN_PARENT_ID), array(DeliveryMonitoringService::COLUMN_DELIVERY_EXECUTION_ID), array('onDelete' => 'CASCADE', 'onUpdate' => 'CASCADE'), DeliveryMonitoringService::KV_FK_PARENT); $tableLog->dropColumn('id'); $tableData->dropColumn('id'); } catch (SchemaException $e) { \common_Logger::i('Database Schema already up to date.'); } $queries = $this->persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $this->persistence->exec($query); } return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Tables successfully altered')); }
public function setUp() { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); TaoPhpUnitTestRunner::initTest(); $service = ServiceManager::getServiceManager()->get(MonitorCacheService::CONFIG_ID); $this->service = new MonitorCacheService($service->getOptions()); $this->persistence = \common_persistence_Manager::getPersistence('default'); if (!extension_loaded('pthreads')) { $this->markTestSkipped('Pthreads extension is not available.'); } }
/** * Retrieve params from exist tao instance * @return array * @throws Exception */ public function getParams() { $path = $this->taoPath . DIRECTORY_SEPARATOR . 'tao' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'raw_start.php'; if (!is_file($path)) { throw new Exception('DB config auto integration require a tao package install should be found ' . $path); } require_once $path; if (!$this->params) { $persistence = \common_persistence_Manager::getPersistence('default'); $schemaManager = $persistence->getDriver()->getSchemaManager(); $reflectionMethod = new ReflectionMethod(get_class($schemaManager), 'getDriver'); $reflectionMethod->setAccessible(true); $this->params = $reflectionMethod->invoke($schemaManager)->getParams(); } return $this->params; }
public function __invoke($params) { try { $persistenceId = isset($params[0]) ? $params[0] : 'default'; $persistence = \common_persistence_Manager::getPersistence($persistenceId); } catch (\common_Exception $e) { $report = new Report(Report::TYPE_INFO, __('Usage: InitRdsQueue PERSISTENCE_ID')); $report->add(new Report(Report::TYPE_ERROR, __('Persistence "%s" could not be loaded', $persistenceId))); return $report; } $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $queueTable = $schema->createtable(RdsQueue::QUEUE_TABLE_NAME); $queueTable->addOption('engine', 'MyISAM'); $queueTable->addColumn(RdsQueue::QUEUE_ID, "string", array("notnull" => true, "length" => 255)); $queueTable->addColumn(RdsQueue::QUEUE_STATUS, "string", array("notnull" => true, "length" => 50)); $queueTable->addColumn(RdsQueue::QUEUE_ADDED, "string", array("notnull" => true)); $queueTable->addColumn(RdsQueue::QUEUE_UPDATED, "string", array("notnull" => true)); $queueTable->addColumn(RdsQueue::QUEUE_OWNER, "string", array("notnull" => false, "length" => 255)); $queueTable->addColumn(RdsQueue::QUEUE_TASK, "string", array("notnull" => true, "length" => 4000)); $queueTable->addColumn(RdsQueue::QUEUE_REPORT, "text", array("default" => null, "notnull" => false)); $queueTable->setPrimaryKey(array(RdsQueue::QUEUE_ID)); $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } } catch (SchemaException $e) { \common_Logger::i('Database Schema already up to date.'); } $queue = new RdsQueue(array(RdsQueue::OPTION_PERSISTENCE => $persistenceId)); $queue->setServiceLocator($this->getServiceLocator()); $this->getServiceLocator()->register(Queue::CONFIG_ID, $queue); return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Setup rds queue successfully using persistence "%s"', $persistenceId)); }
* 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 (under the project TAO-PRODUCT); * * */ use oat\taoOutcomeRds\model\RdsResultStorage; use Doctrine\DBAL\Schema\SchemaException; $persistence = common_persistence_Manager::getPersistence('default'); $schemaManager = $persistence->getDriver()->getSchemaManager(); $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $tableResults = $schema->createtable(RdsResultStorage::RESULTS_TABLENAME); $tableResults->addOption('engine', 'MyISAM'); $tableVariables = $schema->createtable(RdsResultStorage::VARIABLES_TABLENAME); $tableVariables->addOption('engine', 'MyISAM'); $tableResults->addColumn(RdsResultStorage::RESULTS_TABLE_ID, "string", array("length" => 255)); $tableResults->addColumn(RdsResultStorage::TEST_TAKER_COLUMN, "string", array("notnull" => false, "length" => 255)); $tableResults->addColumn(RdsResultStorage::DELIVERY_COLUMN, "string", array("notnull" => false, "length" => 255)); $tableResults->setPrimaryKey(array(RdsResultStorage::RESULTS_TABLE_ID)); $tableVariables->addColumn(RdsResultStorage::VARIABLES_TABLE_ID, "integer", array("autoincrement" => true)); $tableVariables->addColumn(RdsResultStorage::CALL_ID_TEST_COLUMN, "string", array("notnull" => false, "length" => 255)); $tableVariables->addColumn(RdsResultStorage::CALL_ID_ITEM_COLUMN, "string", array("notnull" => false, "length" => 255));
public function setUp() { TaoPhpUnitTestRunner::initTest(); $this->persistence = \common_persistence_Manager::getPersistence('default'); }
/** * 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); } }
/** * * @param string $currentVersion * @return string $versionUpdatedTo */ public function update($initialVersion) { $currentVersion = $initialVersion; if ($currentVersion == '1.0' || $currentVersion == '1.0.1' || $currentVersion == '1.0.2') { $currentVersion = '1.0.3'; } if ($currentVersion == '1.0.3') { //get variables $persistence = \common_persistence_Manager::getPersistence('default'); $sql = 'SELECT * FROM ' . RdsResultStorage::VARIABLES_TABLENAME . ' WHERE ' . RdsResultStorage::VARIABLE_VALUE . ' IS NULL'; $countSql = 'SELECT count(*) FROM ' . RdsResultStorage::VARIABLES_TABLENAME . ' WHERE ' . RdsResultStorage::VARIABLE_VALUE . ' IS NULL'; //update variable storage table schema $schema = $persistence->getDriver()->getSchemaManager()->createSchema(); $fromSchema = clone $schema; $tableVariables = $schema->getTable(RdsResultStorage::VARIABLES_TABLENAME); if (!$tableVariables->hasColumn(RdsResultStorage::VARIABLE_VALUE)) { $tableVariables->addColumn(RdsResultStorage::VARIABLE_VALUE, "text", array("notnull" => false)); $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } $sql = 'SELECT * FROM ' . RdsResultStorage::VARIABLES_TABLENAME; $countSql = 'SELECT count(*) FROM ' . RdsResultStorage::VARIABLES_TABLENAME; } $params = array(); $entries = $persistence->query($countSql, $params)->fetchColumn(); $limit = 1000; for ($i = 0; $i <= $entries; $i += $limit) { $newSql = $sql . ' ORDER BY ' . RdsResultStorage::VARIABLES_TABLE_ID; $query = $persistence->getPlatform()->limitStatement($newSql, $limit, $i); $variables = $persistence->query($query); //store information the new way foreach ($variables as $variable) { //get Variable informations $variableSql = 'SELECT * FROM ' . RdsResultStorage::RESULT_KEY_VALUE_TABLE_NAME . ' WHERE ' . RdsResultStorage::RESULTSKV_FK_COLUMN . ' = ?'; $params = array($variable[RdsResultStorage::VARIABLES_TABLE_ID]); $variableValues = $persistence->query($variableSql, $params); if (class_exists($variable[RdsResultStorage::VARIABLE_CLASS])) { $resultVariable = new $variable[RdsResultStorage::VARIABLE_CLASS](); } else { $resultVariable = new \taoResultServer_models_classes_OutcomeVariable(); } foreach ($variableValues as $variableValue) { $setter = 'set' . ucfirst($variableValue[RdsResultStorage::KEY_COLUMN]); $value = $variableValue[RdsResultStorage::VALUE_COLUMN]; if (method_exists($resultVariable, $setter) && !is_null($value)) { if ($variableValue[RdsResultStorage::KEY_COLUMN] == 'value' || $variableValue[RdsResultStorage::KEY_COLUMN] == 'candidateResponse') { $value = base64_decode($value); } $resultVariable->{$setter}($value); } } $sqlUpdate = 'UPDATE ' . RdsResultStorage::VARIABLES_TABLENAME . ' SET ' . RdsResultStorage::VARIABLE_VALUE . ' = ? WHERE ' . RdsResultStorage::VARIABLES_TABLE_ID . ' = ?'; $paramsUpdate = array(serialize($resultVariable), $variable[RdsResultStorage::VARIABLES_TABLE_ID]); $persistence->exec($sqlUpdate, $paramsUpdate); } } //remove kv table $schema = $persistence->getDriver()->getSchemaManager()->createSchema(); $fromSchema = clone $schema; $tableVariables = $schema->getTable(RdsResultStorage::VARIABLES_TABLENAME); $resultKv = $schema->dropTable(RdsResultStorage::RESULT_KEY_VALUE_TABLE_NAME); $tableVariables->dropColumn(RdsResultStorage::VARIABLE_CLASS); $queries = $persistence->getPlatform()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } $currentVersion = '1.1.0'; } $this->setVersion($currentVersion); $this->skip('1.1.0', '1.1.4'); }
/** * Set up test */ public function setUp() { TaoPhpUnitTestRunner::initTest(); $this->service = new RdsDeliveryLogService(array(RdsDeliveryLogService::OPTION_PERSISTENCE => 'default')); $this->persistence = \common_persistence_Manager::getPersistence('default'); }
<?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 (under the project TAO-PRODUCT); * * */ common_persistence_Manager::addPersistence('serviceState', array('driver' => 'phpfile'));
* 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\oatbox\user\auth\AuthFactory; $parms = $argv; array_shift($parms); if (count($parms) != 1) { echo 'Usage: ' . __FILE__ . ' TAOROOT' . PHP_EOL; die(1); } $root = rtrim(array_shift($parms), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $rawStart = $root . 'tao' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'raw_start.php'; require_once $rawStart; $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('generis'); $auths = $ext->getConfig(AuthFactory::CONFIG_KEY); foreach ($auths as $authConfig) { if (!isset($authConfig['driver'])) { throw new common_Exception('Incomplete auth configuration'); } if ($authConfig['driver'] == 'oat\\authKeyValue\\AuthKeyValueAdapter') { throw new common_Exception('AuthKeyValueAdapter already present'); } } common_persistence_Manager::addPersistence('authKeyValue', array('driver' => 'phpredis', 'host' => '127.0.0.1', 'port' => 6379)); array_unshift($auth, array('driver' => 'oat\\authKeyValue\\AuthKeyValueAdapter')); $ext->setConfig(AuthFactory::CONFIG_KEY, $auths); echo 'activate' . PHP_EOL;
private function getPersistence() { return \common_persistence_Manager::getPersistence('default'); }
/** * @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'); }
public function __construct() { $this->setPersistence(\common_persistence_Manager::getPersistence('default')); }
/** * Get persistence with configurable driver option of Sql Storage * Get default driver if option is not set * @return \common_persistence_Persistence */ public function getPersistence() { $persistenceOption = $this->getOption(self::DIAGNOSTIC_PERSISTENCE); $persistence = !empty($persistenceOption) ? $persistenceOption : 'default'; return \common_persistence_Manager::getPersistence($persistence); }
/** * @return \common_persistence_SqlPersistence */ protected function getPersistence() { return \common_persistence_Manager::getPersistence($this->getOption(self::OPTION_PERSISTENCE)); }