/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $assignmentService = new ProctoringAssignmentService(); $assignmentService->setServiceManager($serviceManager); $serviceManager->register(ProctoringAssignmentService::CONFIG_ID, $assignmentService); }
/** * PciAssetHandler constructor. * Set PortableElementItemParser */ public function __construct(Item $item, $sourceDir) { $this->portableItemParser = new PortableElementItemParser(); $this->portableItemParser->setServiceLocator(ServiceManager::getServiceManager()); $this->portableItemParser->setSource(rtrim($sourceDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR); $this->portableItemParser->setQtiModel($item); }
public static function getServiceStorage($serviceCallId) { $serviceService = ServiceManager::getServiceManager()->get('tao/stateStorage'); $state = $serviceService->get(common_session_SessionManager::getSession()->getUserUri(), $serviceCallId); $submitUrl = _url('submitState', 'ServiceModule', 'tao', array('serviceCallId' => $serviceCallId)); return 'new StateStorage(' . tao_helpers_Javascript::buildObject($state) . ', ' . tao_helpers_Javascript::buildObject($submitUrl) . ')'; }
/** * Get the TextConverterService * * @return ProctoringTextConverter */ protected function getTextConverterService() { if (!$this->textConverterService) { $this->textConverterService = ServiceManager::getServiceManager()->get(ProctoringTextConverter::SERVICE_ID); } return $this->textConverterService; }
/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $deliveryContainerService = new DeliveryContainerService(); $deliveryContainerService->setServiceManager($serviceManager); $serviceManager->register(DeliveryContainerService::CONFIG_ID, $deliveryContainerService); }
private function getIrregularities($delivery, $from = '', $to = '') { $export = array(array(__('date'), __('author'), __('test taker'), __('category'), __('subcategory'), __('comment'))); $deliveryLog = ServiceManager::getServiceManager()->get(DeliveryLog::SERVICE_ID); $service = ResultsService::singleton(); $implementation = $service->getReadableImplementation($delivery); $service->setImplementation($implementation); $results = $service->getImplementation()->getResultByDelivery(array($delivery->getUri())); foreach ($results as $res) { $deliveryExecution = \taoDelivery_models_classes_execution_ServiceProxy::singleton()->getDeliveryExecution($res['deliveryResultIdentifier']); $logs = $deliveryLog->get($deliveryExecution->getIdentifier(), 'TEST_IRREGULARITY'); foreach ($logs as $data) { $exportable = array(); if ((empty($from) || $data['created_at'] > $from) && (empty($to) || $data['created_at'] < $to)) { $testTaker = new \core_kernel_classes_Resource($res['testTakerIdentifier']); $author = new \core_kernel_classes_Resource($data['created_by']); $exportable[] = \tao_helpers_Date::displayeDate($data['created_at']); $exportable[] = $author->getLabel(); $exportable[] = $testTaker->getLabel(); $exportable[] = $data['data']['reason']['reasons']['category']; $exportable[] = isset($data['data']['reason']['reasons']['subCategory']) ? $data['data']['reason']['reasons']['subCategory'] : ''; $exportable[] = $data['data']['reason']['comment']; $export[] = $exportable; } } } return $export; }
public function __invoke($params) { $service = new PortableElementService(); $service->setServiceLocator(ServiceManager::getServiceManager()); $sourceDirectory = $this->getSourceDirectory(); if (empty($sourceDirectory)) { return $this->createFailure('the source directory is empty'); } if (!is_readable($sourceDirectory)) { return $this->createFailure('the source directory does not exists or is not readable ' . $sourceDirectory); } try { $model = $service->getValidPortableElementFromDirectorySource($sourceDirectory); if (!empty($params)) { $minRequiredVersion = $params[0]; // if the minimal required version number string "x.y.z" is given in the parameter, the new target version should be equal or higher than it if (version_compare($model->getVersion(), $minRequiredVersion) < 0) { return $this->createFailure('the version in manifest "' . $model->getVersion() . '" cannot be lower than the given minimum required version "' . $minRequiredVersion . '"', $model); } } $service->registerFromDirectorySource($sourceDirectory); } catch (PortableElementVersionIncompatibilityException $e) { return $this->createFailure('incompatible version: ' . $e->getMessage(), $model); } return Report::createSuccess('registered portable element "' . $model->getTypeIdentifier() . '" in version "' . $model->getVersion() . '""'); }
public function __invoke($params) { $this->dryrun = in_array('dryrun', $params) || in_array('--dryrun', $params); /** @var StorageInterface $storageService */ $storageService = ServiceManager::getServiceManager()->get(StorageInterface::SERVICE_ID); $page = 1; $rows = 500; $this->report = new \common_report_Report(\common_report_Report::TYPE_INFO, 'Converting of dates for the event log'); while (true) { $slice = $storageService->searchInstances(['page' => $page, 'rows' => $rows]); if (!count($slice['data'])) { break; } foreach ($slice['data'] as $row) { if (empty($row['occurred']) || $row['occurred'] == '0000-00-00 00:00:00') { $this->report->add(new \common_report_Report(\common_report_Report::TYPE_WARNING, 'Would not be converted date in id="' . $row['id'] . '" date is "' . $row['occurred'] . '"')); continue; } if ($this->dryrun) { $this->report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'Would be changed date "' . $row['occurred'] . '" to "' . $this->convertToUtcDate($row['occurred']) . '"')); } else { $this->setOccurred($storageService, $row['id'], $this->convertToUtcDate($row['occurred'])); } } if ($this->dryrun) { $this->report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'In the same way would be changed "' . $slice['records'] . '" records')); break; } $page++; } $this->report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'Done')); return $this->report; }
/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $service = new CategoryService(); $service->setServiceManager($serviceManager); $serviceManager->register(CategoryService::SERVICE_ID, $service); }
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'); }
/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $testRunnerFeatureService = new TestRunnerFeatureService(); $testRunnerFeatureService->setServiceManager($serviceManager); $serviceManager->register(TestRunnerFeatureService::SERVICE_ID, $testRunnerFeatureService); }
/** * install an extension * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @return void */ public function install() { common_Logger::i('Installing extension ' . $this->extension->getId(), 'INSTALL'); if ($this->extension->getId() == 'generis') { throw new common_ext_ForbiddenActionException('Tried to install generis using the ExtensionInstaller', $this->extension->getId()); } if (common_ext_ExtensionsManager::singleton()->isInstalled($this->extension->getId())) { throw new common_ext_AlreadyInstalledException('Problem installing extension ' . $this->extension->getId() . ' : Already installed', $this->extension->getId()); } // we purge the whole cache. $cache = common_cache_FileCache::singleton(); $cache->purge(); // check reuired extensions, throws exception if failed helpers_ExtensionHelper::checkRequiredExtensions($this->getExtension()); $this->installLoadDefaultConfig(); $this->installOntology(); $this->installRegisterExt(); common_Logger::d('Installing custom script for extension ' . $this->extension->getId()); $this->installCustomScript(); common_Logger::d('Done installing custom script for extension ' . $this->extension->getId()); if ($this->getLocalData() == true) { common_Logger::d('Installing local data for extension ' . $this->extension->getId()); $this->installLocalData(); common_Logger::d('Done installing local data for extension ' . $this->extension->getId()); } common_Logger::d('Extended install for extension ' . $this->extension->getId()); // Method to be overriden by subclasses // to extend the installation mechanism. $this->extendedInstall(); common_Logger::d('Done extended install for extension ' . $this->extension->getId()); $eventManager = ServiceManager::getServiceManager()->get(EventManager::CONFIG_ID); $eventManager->trigger(new common_ext_event_ExtensionInstalled($this->extension)); }
public function inject($target, array $values) { if (!$target instanceof core_kernel_classes_Resource) { $msg = "The given target is not an instance of core_kernel_classes_Resource."; throw new MetadataInjectionException($msg); } $injectionRules = $this->getInjectionRules(); foreach ($values as $metadataValues) { foreach ($metadataValues as $metadataValue) { $pathKey = implode('->', $metadataValue->getPath()); $lang = $metadataValue->getLanguage() ?: DEFAULT_LANG; if (($rule = $this->getRuleByValue($metadataValue->getPath(), $metadataValue->getValue())) !== false) { // Direct Mapping. $target->setPropertyValueByLg(new core_kernel_classes_Property($rule[0]), $rule[2], $lang); } elseif (($rule = $this->getRuleByPath($metadataValue->getPath())) !== false) { // Direct Injection. $target->setPropertyValueByLg(new core_kernel_classes_Property($rule[0]), $metadataValue->getValue(), $lang); } $eventManager = ServiceManager::getServiceManager()->get(EventManager::CONFIG_ID); $metadata = $metadataValue->getPath(); $metadataUri = array_pop($metadata); $eventManager->trigger(new MetadataModified($target, $metadataUri, $metadataValue->getValue())); } } }
/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $eventManager = $serviceManager->get(EventManager::CONFIG_ID); $eventManager->attach('oat\\taoTests\\models\\event\\TestExecutionPausedEvent', ['oat\\taoProctoring\\model\\implementation\\DeliveryExecutionStateService', 'catchSessionPause']); $serviceManager->register(EventManager::CONFIG_ID, $eventManager); }
public function getPersistence() { if (is_null($this->persistence)) { $this->persistence = ServiceManager::getServiceManager()->get(\common_persistence_Manager::SERVICE_KEY)->getPersistenceById($this->getOption('persistence')); } return $this->persistence; }
/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $testPluginService = new TestPluginService(); $testPluginService->setServiceManager($serviceManager); $serviceManager->register(TestPluginService::CONFIG_ID, $testPluginService); }
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')); }
/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $service = new TestExporter(); $service->setServiceManager($serviceManager); $serviceManager->register(TestMetadataExporter::SERVICE_ID, $service); }
/** * DatatablePayload constructor. * @param DatatableRequestInterface|null $request */ public function __construct(DatatableRequestInterface $request = null) { $this->setServiceLocator(ServiceManager::getServiceManager()); if ($request === null) { $request = DatatableRequest::fromGlobals(); } $this->request = $request; }
public function getRegistry() { /** @var PortableElementRegistry $registry */ $registry = PicRegistry::getRegistry(); $registry->setServiceLocator(ServiceManager::getServiceManager()); $registry->setModel($this); return $registry; }
public function testGetInjectorNotFound() { $importer = new MockeryTest_MetadataOntologyImport(array('injectorNotFound' => ['class' => Injector::class])); $importer->setServiceManager(ServiceManager::getServiceManager()); $method = new \ReflectionMethod(get_class($importer), 'getInjectors'); $method->setAccessible(true); $this->setExpectedException(InconsistencyConfigException::class); $method->invoke($importer); }
/** * @return common_persistence_Manager */ protected static function getDefaultManager() { try { $manager = ServiceManager::getServiceManager()->get(self::SERVICE_KEY); } catch (ServiceNotFoundException $ex) { $manager = new self(array(self::OPTION_PERSISTENCES => array())); $manager->setServiceManager(ServiceManager::getServiceManager()); } return $manager; }
/** * @inheritDoc */ protected function init() { $containerService = ServiceManager::getServiceManager()->get(DeliveryContainerService::CONFIG_ID); // set the test parameters $this->setData('testDefinition', $containerService->getTestDefinition($this->deliveryExecution)); $this->setData('testCompilation', $containerService->getTestCompilation($this->deliveryExecution)); $this->setData('plugins', $containerService->getPlugins($this->deliveryExecution)); $this->setData('bootstrap', $containerService->getBootstrap($this->deliveryExecution)); $this->setData('serviceCallId', $this->deliveryExecution->getIdentifier()); }
/** * @param $params */ public function __invoke($params) { $serviceManager = ServiceManager::getServiceManager(); $deliveryExt = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); $deliveryServerConfig = $deliveryExt->getConfig('deliveryServer'); $deliveryServerOptions = $deliveryServerConfig->getOptions(); $deliveryServerService = new DeliveryServerService($deliveryServerOptions); $deliveryServerService->setServiceManager($serviceManager); $serviceManager->register(DeliveryServerService::CONFIG_ID, $deliveryServerService); }
/** * DeliveryMonitoringData constructor. * @param DeliveryExecution $deliveryExecution */ public function __construct(DeliveryExecution $deliveryExecution) { $this->deliveryExecution = $deliveryExecution; $deliveryExecutionId = $this->deliveryExecution->getIdentifier(); $data = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID)->find([[DeliveryMonitoringService::DELIVERY_EXECUTION_ID => $deliveryExecutionId]], ['asArray' => true], true); if (empty($data)) { $this->addValue('delivery_execution_id', $deliveryExecutionId); } else { $this->data = $data[0]; } }
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.'); } }
public static function stateChange(DeliveryExecutionState $event) { /** @var DeliveryMonitoringService $service */ $service = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); $deliveryExecution = $event->getDeliveryExecution(); $data = $service->getData($deliveryExecution, true); $success = $service->save($data); if (!$success) { \common_Logger::w('monitor cache for delivery ' . $deliveryExecution->getIdentifier() . ' could not be created'); } }
/** * Create filesystem for ItemExporter service * * @param $params * @return \common_report_Report */ public function __invoke($params) { try { $serviceManager = ServiceManager::getServiceManager(); $fsService = $serviceManager->get(FileSystemService::SERVICE_ID); $fsService->createLocalFileSystem(ItemExporter::EXPORT_FILESYSTEM); $serviceManager->register(FileSystemService::SERVICE_ID, $fsService); } catch (\Exception $e) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Fail to create export directory.'); } return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'Export directory created.'); }
protected static function deleteDependencies(\core_kernel_classes_Triple $triple) { if (CloneHelper::isFileReference($triple)) { $referencer = ServiceManager::getServiceManager()->get(FileReferenceSerializer::SERVICE_ID); $source = $referencer->unserialize($triple->object); if ($source instanceof Directory) { $source->deleteSelf(); } elseif ($source instanceof File) { $source->delete(); } $referencer->cleanUp($triple->object); } }