/** * @param $params * @return Report */ public function __invoke($params) { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoProctoring'); \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $report = new Report(Report::TYPE_INFO, 'Updating of delivery monitoring cache...'); $testCenters = TestCenterService::singleton()->getRootClass()->getInstances(true); $deliveryMonitoringService = $this->getServiceLocator()->get(DeliveryMonitoringService::CONFIG_ID); $deliveryService = $this->getServiceLocator()->get(DeliveryService::CONFIG_ID); $eligibilityService = EligibilityService::singleton(); foreach ($testCenters as $testCenter) { $deliveries = $eligibilityService->getEligibleDeliveries($testCenter, false); foreach ($deliveries as $delivery) { if ($delivery->exists()) { $deliveryExecutions = $deliveryService->getCurrentDeliveryExecutions($delivery->getUri(), $testCenter->getUri()); foreach ($deliveryExecutions as $deliveryExecution) { $data = $deliveryMonitoringService->getData($deliveryExecution, true); if ($deliveryMonitoringService->save($data)) { $report->add(new Report(Report::TYPE_SUCCESS, "Delivery execution {$deliveryExecution->getUri()} successfully updated.")); } else { $errors = $data->getErrors(); $errorsStr = " " . PHP_EOL; array_walk($errors, function ($val, $key) use(&$errorsStr) { $errorsStr .= " {$key} - {$val}" . PHP_EOL; }); $report->add(new Report(Report::TYPE_ERROR, "Delivery execution {$deliveryExecution->getUri()} was not updated. {$errorsStr}")); } } } } } return $report; }
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; }
/** * @return Report * @throws \common_exception_Error */ public function runQueue() { $count = 0; $statistics = array(); $queue = $this->getServiceManager()->get(Queue::CONFIG_ID); $report = new Report(Report::TYPE_SUCCESS); $limit = $this->getLimit(); foreach ($queue as $task) { $subReport = $this->runTask($task); $statistics[$subReport->getType()] = isset($statistics[$subReport->getType()]) ? $statistics[$subReport->getType()] + 1 : 1; $report->add($subReport); $count++; if ($limit !== 0 && $count === $limit) { break; } } if (empty($statistics)) { $report = new Report(Report::TYPE_INFO, __('No tasks to run')); } else { if (isset($statistics[Report::TYPE_ERROR]) || isset($statistics[Report::TYPE_WARNING])) { $report->setType(Report::TYPE_WARNING); } $report->setMessage(__('Ran %s task(s):', array_sum($statistics))); } return $report; }
public function testNestedReport() { $report = new common_report_Report(common_report_Report::TYPE_WARNING, 'test message3'); $sub1 = new common_report_Report(common_report_Report::TYPE_INFO, 'info31'); $sub2 = new common_report_Report(common_report_Report::TYPE_ERROR, 'error31'); $report->add(array($sub1, $sub2)); $this->assertTrue($report->hasChildren()); $this->assertEquals('test message3', (string) $report); $this->assertEquals(common_report_Report::TYPE_WARNING, $report->getType()); $array = array(); foreach ($report as $child) { $array[] = $child; } $this->assertEquals(2, count($array)); list($first, $second) = $array; $this->assertFalse($first->hasChildren()); $this->assertEquals('info31', (string) $first); $this->assertEquals(common_report_Report::TYPE_INFO, $first->getType()); foreach ($first as $child) { $this->fail('Should not contain children'); } $this->assertFalse($second->hasChildren()); $this->assertEquals('error31', (string) $second); $this->assertEquals(common_report_Report::TYPE_ERROR, $second->getType()); foreach ($second as $child) { $this->fail('Should not contain children'); } $this->assertFalse($report->contains(common_report_Report::TYPE_SUCCESS)); $this->assertTrue($report->contains(common_report_Report::TYPE_INFO)); $this->assertTrue($report->contains(common_report_Report::TYPE_ERROR)); }
/** * Compile an item. * * @param core_kernel_file_File $destinationDirectory * @throws taoItems_models_classes_CompilationFailedException * @return tao_models_classes_service_ServiceCall */ public function compile() { $destinationDirectory = $this->spawnPublicDirectory(); $item = $this->getResource(); $itemUri = $item->getUri(); $report = new common_report_Report(common_report_Report::TYPE_SUCCESS, __('Published %s', $item->getLabel())); if (!taoItems_models_classes_ItemsService::singleton()->isItemModelDefined($item)) { return $this->fail(__('Item \'%s\' has no model', $item->getLabel())); } $langs = $this->getContentUsedLanguages(); foreach ($langs as $compilationLanguage) { $compiledFolder = $this->getLanguageCompilationPath($destinationDirectory, $compilationLanguage); if (!is_dir($compiledFolder)) { if (!@mkdir($compiledFolder)) { common_Logger::e('Could not create directory ' . $compiledFolder, 'COMPILER'); return $this->fail(__('Could not create language specific directory for item \'%s\'', $item->getLabel())); } } $langReport = $this->deployItem($item, $compilationLanguage, $compiledFolder); $report->add($langReport); if ($langReport->getType() == common_report_Report::TYPE_ERROR) { $report->setType(common_report_Report::TYPE_ERROR); break; } } if ($report->getType() == common_report_Report::TYPE_SUCCESS) { $report->setData($this->createService($item, $destinationDirectory)); } else { $report->setMessage(__('Failed to publish %s', $item->getLabel())); } return $report; }
/** * Apply css to all instances of this class and its subclasses * * @param \core_kernel_classes_Class $class * @param $destPath, optional * @return \common_report_Report * @throws \common_exception_Error */ public function applyToClass(\core_kernel_classes_Class $class, $destPath = null) { $destPath = is_null($destPath) ? basename($this->cssFile) : $destPath; if (strtolower(substr(strrchr($destPath, '.'), 1)) !== 'css') { throw new \common_exception_Error($destPath . ' does not appear to be a stylesheet'); } $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS); $itemIterator = new \core_kernel_classes_ResourceIterator(array($class)); $count = 0; foreach ($itemIterator as $item) { // is QTI? $model = \taoItems_models_classes_ItemsService::singleton()->getItemModel($item); if (!is_null($model) && $model->getUri() == TAO_ITEM_MODEL_QTI) { $subReport = $this->applyToItem($item, $destPath); $report->add($subReport); if ($subReport->getType() == \common_report_Report::TYPE_SUCCESS) { $count++; } else { $report->setType($subReport->getType()); } } } $report->setMessage($count > 0 ? __('%1s has been applied to %2s items', basename($destPath), $count) : __('CSS was not applied to any items')); return $report; }
/** * Walk through the cloned process and replace the item runner placeholders * * @param core_kernel_classes_Resource $processDefinition */ protected function process(core_kernel_classes_Resource $processDefinition) { $report = new common_report_Report(common_report_Report::TYPE_SUCCESS); $activities = wfEngine_models_classes_ProcessDefinitionService::singleton()->getAllActivities($processDefinition); foreach ($activities as $activity) { $services = wfEngine_models_classes_ActivityService::singleton()->getInteractiveServices($activity); foreach ($services as $service) { $serviceDefinition = $service->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION)); if ($serviceDefinition->getUri() == INSTANCE_ITEMCONTAINER_SERVICE) { $item = taoWfTest_models_classes_WfTestService::singleton()->getItemByService($service); if (is_null($item)) { $report->add($this->fail(__('No valid item found for service "%s"', $service->getLabel()))); } else { $itemReport = $this->subCompile($item); if ($itemReport->getType() == common_report_Report::TYPE_SUCCESS) { $serviceCall = $itemReport->getData(); $storedServiceCall = $serviceCall->toOntology(); // remove old service wfEngine_models_classes_InteractiveServiceService::singleton()->deleteInteractiveService($service); $activity->removePropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_INTERACTIVESERVICES), $service); // add new service $activity->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_INTERACTIVESERVICES), $storedServiceCall); } $report->add($itemReport); if ($itemReport->getType() != common_report_Report::TYPE_SUCCESS) { $report->setType($itemReport->getType()); } } } } } return $report; }
public function run(Task $task) { \common_Logger::d('Running task ' . $task->getId()); $report = new \common_report_Report(\common_report_Report::TYPE_INFO, __('Running task %s', $task->getId())); $queue = $this->getServiceLocator()->get(Queue::CONFIG_ID); $queue->updateTaskStatus($task->getId(), Task::STATUS_RUNNING); try { $actionService = $this->getServiceLocator()->get(ActionService::SERVICE_ID); $invocable = $task->getInvocable(); if (is_string($invocable)) { $invocable = $actionService->resolve($task->getInvocable()); } else { if ($invocable instanceof ServiceLocatorAwareInterface) { $invocable->setServiceLocator($this->getServiceLocator()); } } $subReport = call_user_func($invocable, $task->getParameters()); $report->add($subReport); } catch (\Exception $e) { $message = 'Task ' . $task->getId() . ' failed. Error message: ' . $e->getMessage(); \common_Logger::e($message); $report = new \common_report_Report(\common_report_Report::TYPE_ERROR, $message); } $queue->updateTaskStatus($task->getId(), Task::STATUS_FINISHED, $report); return $report; }
protected function removeDeliveryExecutions() { $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS); // deliveryExecutions $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); $deliveryService = $extension->getConfig('execution_service'); if ($deliveryService instanceof \taoDelivery_models_classes_execution_KeyValueService) { $persistenceOption = $deliveryService->getOption(\taoDelivery_models_classes_execution_KeyValueService::OPTION_PERSISTENCE); $persistence = \common_persistence_KeyValuePersistence::getPersistence($persistenceOption); $count = 0; foreach ($persistence->keys('kve_*') as $key) { if (substr($key, 0, 4) == 'kve_') { $persistence->del($key); $count++; } } $report->setMessage('Removed ' . $count . ' key-value delivery executions'); } elseif ($deliveryService instanceof \taoDelivery_models_classes_execution_OntologyService) { $count = 0; $deliveryExecutionClass = new \core_kernel_classes_Class(\taoDelivery_models_classes_execution_OntologyDeliveryExecution::CLASS_URI); $deliveryExecutions = $deliveryExecutionClass->getInstances(); /** @var \core_kernel_classes_Class $deliveryExecution */ foreach ($deliveryExecutions as $deliveryExecution) { $deliveryExecution->delete(true); $count++; } $report->setMessage('Removed ' . $count . ' ontology delivery executions'); } else { $report->setType(\common_report_Report::TYPE_ERROR); $report->setMessage('Cannot cleanup delivery executions from ' . get_class($deliveryService)); } $this->finalReport->add($report); }
public function __invoke($params) { $actionResolver = $this->getServiceLocator()->get(ActionService::SERVICE_ID); $report = new \common_report_Report(\common_report_Report::TYPE_INFO, __('Available Actions:')); foreach ($actionResolver->getAvailableActions() as $actionClass) { $report->add(new \common_report_Report(\common_report_Report::TYPE_INFO, ' ' . $actionClass)); } return $report; }
public function __invoke($params) { $tasksRun = 0; $queue = $this->getServiceManager()->get(Queue::CONFIG_ID); $runner = new TaskRunner(); $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS); foreach ($queue as $task) { $subReport = $runner->run($task); $tasksRun++; $report->add($subReport); } $report->setMessage(__('Successfully ran %s tasks:', $tasksRun)); return $report; }
/** * * @param unknown $params */ public function __invoke($params) { if (count($params) < 1) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s ASSEMBLY_FILE [ASSEMBLY_FILE_2] [ASSEMBLY_FILE_3] ...', __CLASS__)); } \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); $deliveryClass = DeliveryAssemblyService::singleton()->getRootClass()->createSubClass('Import ' . \tao_helpers_Date::displayeDate(time())); $importer = new Assembler(); $report = new \common_report_Report(\common_report_Report::TYPE_INFO, __('Importing %1$s files into \'%2$s\'', count($params), $deliveryClass->getLabel())); while (!empty($params)) { $file = array_shift($params); $report->add($importer->importDelivery($deliveryClass, $file)); } return $report; }
public function __invoke($params) { $statistics = array(); $queue = $this->getServiceManager()->get(Queue::CONFIG_ID); $runner = new TaskRunner(); $report = new Report(Report::TYPE_SUCCESS); foreach ($queue as $task) { $subReport = $runner->run($task); $statistics[$subReport->getType()] = isset($statistics[$subReport->getType()]) ? $statistics[$subReport->getType()] + 1 : 1; $report->add($subReport); } if (empty($statistics)) { $report = new Report(Report::TYPE_INFO, __('No tasks to run')); } else { if (isset($statistics[Report::TYPE_ERROR]) || isset($statistics[Report::TYPE_WARNING])) { $report->setType(Report::TYPE_WARNING); } $report->setMessage(__('Ran %s task(s):', array_sum($statistics))); } return $report; }
/** * (non-PHPdoc) * @see \oat\oatbox\action\Action::__invoke() */ public function __invoke($params) { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); if (count($params) != 2) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s DELIVERY_CLASS_URI OUTPUT_DIRECTORY', __CLASS__)); } $deliveryClassUri = array_shift($params); $deliveryClass = new \core_kernel_classes_Class($deliveryClassUri); $dir = array_shift($params); if (!file_exists($dir) && !mkdir($dir)) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Directory %s doesn\'t exist', $dir)); } $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exporting %s', $deliveryClass->getLabel())); foreach ($deliveryClass->getInstances(true) as $delivery) { $destFile = $dir . \tao_helpers_File::getSafeFileName($delivery->getLabel()) . '.zip'; $tmpFile = Assembler::exportCompiledDelivery($delivery); \tao_helpers_File::move($tmpFile, $destFile); $report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exported %1$s to %2$s', $delivery->getLabel(), $destFile))); } return $report; }
/** * @param string $actionIdentifier fully qualified action class name * @param array $params Params to be passed to action's __invoke method * @return Report */ public function runAction($actionIdentifier, array $params = []) { try { $action = $this->actionService->resolve($actionIdentifier); } catch (\common_ext_ManifestNotFoundException $e) { $action = new Help(null); } catch (ResolutionException $e) { $parts = explode('/', $actionIdentifier); $extId = $parts[0]; $action = new Help($extId); } if ($action instanceof ServiceLocatorAwareInterface) { $action->setServiceLocator($this->getServiceLocator()); } try { $report = call_user_func($action, $params); } catch (\Exception $e) { $report = new Report(Report::TYPE_ERROR, __('An exception occured while running "%s"', $actionIdentifier)); $report->add(new Report(Report::TYPE_ERROR, $e->getMessage())); } return $report; }
public function testJsonUnserialize() { $root = new common_report_Report(common_report_Report::TYPE_WARNING, 'test message3'); $sub1 = new common_report_Report(common_report_Report::TYPE_INFO, 'info31'); $sub2 = new common_report_Report(common_report_Report::TYPE_ERROR, 'error31'); $subsub = new common_report_Report(common_report_Report::TYPE_SUCCESS, 'success31'); // make report tree $sub1->add([$subsub]); $root->add([$sub1, $sub2]); $json = json_encode($root, JSON_PRETTY_PRINT); $report = common_report_Report::jsonUnserialize($json); $this->assertTrue($report->hasChildren()); $this->assertEquals('test message3', (string) $report); $this->assertEquals(common_report_Report::TYPE_WARNING, $report->getType()); $array = array(); foreach ($report as $child) { $array[] = $child; } $this->assertEquals(2, count($array)); list($first, $second) = $array; $this->assertTrue($first->hasChildren()); $this->assertEquals('info31', (string) $first); $this->assertEquals(common_report_Report::TYPE_INFO, $first->getType()); foreach ($first as $child) { $this->assertEquals('success31', (string) $child); $this->assertEquals(common_report_Report::TYPE_SUCCESS, $child->getType()); } $this->assertFalse($second->hasChildren()); $this->assertEquals('error31', (string) $second); $this->assertEquals(common_report_Report::TYPE_ERROR, $second->getType()); foreach ($second as $child) { $this->fail('Should not contain children'); } $this->assertTrue($report->contains(common_report_Report::TYPE_SUCCESS)); $this->assertTrue($report->contains(common_report_Report::TYPE_INFO)); $this->assertTrue($report->contains(common_report_Report::TYPE_ERROR)); }
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)); }
/** * * @param unknown $xhtml * @param unknown $destination * @return common_report_Report */ public static function retrieveExternalResources($xhtml, $destination) { if (!file_exists($destination)) { if (!mkdir($destination)) { common_Logger::e('Folder ' . $destination . ' could not be created'); return new common_report_Report(common_report_Report::TYPE_ERROR, __('Unable to create deployement directory'), $xhtml); } } $authorizedMedia = self::$defaultMedia; $mediaList = array(); $expr = "/http[s]?:(\\\\)?\\/(\\\\)?\\/[^<'\"&?]+\\.(" . implode('|', $authorizedMedia) . ")/mi"; //take into account json encoded url preg_match_all($expr, $xhtml, $mediaList, PREG_PATTERN_ORDER); $uniqueMediaList = array_unique($mediaList[0]); $report = new common_report_Report(common_report_Report::TYPE_SUCCESS, __('Retrieving external resources')); foreach ($uniqueMediaList as $mediaUrl) { // This is a file that has to be stored in the item compilation folder itself... // I do not get why they are all copied. They are all there they were copied from the item module... // But I agree that remote resources (somewhere on the Internet) should be copied via curl. // So if the URL does not matches a place where the TAO server is, we curl the resource and store it. // FileManager files should be considered as remote resources to avoid 404 issues. Indeed, a backoffice // user might delete an image in the filemanager during a delivery campain. This is dangerous. $decodedMediaUrl = str_replace('\\/', '/', $mediaUrl); $mediaPath = self::retrieveFile($decodedMediaUrl, $destination); if (!empty($mediaPath) && $mediaPath !== false) { $xhtml = str_replace($mediaUrl, basename($mediaPath), $xhtml, $replaced); //replace only when copyFile is successful } else { $report->add(new common_report_Report(common_report_Report::TYPE_ERROR, __('Failed retrieving %s', $decodedMediaUrl))); $report->setType(common_report_Report::TYPE_ERROR); } } if ($report->getType() == common_report_Report::TYPE_SUCCESS) { $report->setData($xhtml); } return $report; }
/** * Compile the items referended by $compactDoc. * * @param XmlCompactDocument $compactDoc An XmlCompactDocument object referencing the items of the test. * @throws taoQtiTest_models_classes_QtiTestCompilationFailedException If the test does not refer to at least one item. * @return common_report_Report */ protected function compileItems(XmlCompactDocument $compactDoc) { $report = new common_report_Report(common_report_Report::TYPE_SUCCESS, __('Items Compilation')); $iterator = new QtiComponentIterator($compactDoc->getDocumentComponent(), array('assessmentItemRef')); $itemCount = 0; foreach ($iterator as $assessmentItemRef) { // Each item could take some time to be compiled, making the request to timeout. helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::SHORT); $itemToCompile = new core_kernel_classes_Resource($assessmentItemRef->getHref()); $subReport = $this->subCompile($itemToCompile); $report->add($subReport); if ($subReport->getType() == common_report_Report::TYPE_SUCCESS) { $itemService = $subReport->getdata(); $inputValues = tao_models_classes_service_ServiceCallHelper::getInputValues($itemService, array()); $assessmentItemRef->setHref($inputValues['itemUri'] . '|' . $inputValues['itemPath'] . '|' . $inputValues['itemDataPath']); } else { $report->setType(common_report_Report::TYPE_ERROR); } // Count the item even if it fails to avoid false "no item" error. $itemCount++; common_Logger::t("QTI Item successfully compiled and registered as a service call in the QTI Test Definition."); } if ($itemCount === 0) { $report->setType(common_report_Report::TYPE_ERROR); $report->setMessage(__("A QTI Test must contain at least one QTI Item to be compiled. None found.")); } return $report; }
/** * Update a specific extension * * @param common_ext_Extension $ext * @return common_report_Report */ protected function updateExtension(common_ext_Extension $ext) { helpers_ExtensionHelper::checkRequiredExtensions($ext); $installed = common_ext_ExtensionsManager::singleton()->getInstalledVersion($ext->getId()); $codeVersion = $ext->getVersion(); if ($installed !== $codeVersion) { $report = new common_report_Report(common_report_Report::TYPE_INFO, $ext->getName() . ' requires update from ' . $installed . ' to ' . $codeVersion); $updaterClass = $ext->getManifest()->getUpdateHandler(); if (is_null($updaterClass)) { $report = new common_report_Report(common_report_Report::TYPE_WARNING, 'No Updater found for ' . $ext->getName()); } elseif (!class_exists($updaterClass)) { $report = new common_report_Report(common_report_Report::TYPE_ERROR, 'Updater ' . $updaterClass . ' not found'); } else { $updater = new $updaterClass($ext); $returnedVersion = $updater->update($installed); $currentVersion = common_ext_ExtensionsManager::singleton()->getInstalledVersion($ext->getId()); if (!is_null($returnedVersion) && $returnedVersion != $currentVersion) { common_ext_ExtensionsManager::singleton()->updateVersion($ext, $returnedVersion); $report->add(new common_report_Report(common_report_Report::TYPE_WARNING, 'Manually saved extension version')); $currentVersion = $returnedVersion; } if ($currentVersion == $codeVersion) { $report->add(new common_report_Report(common_report_Report::TYPE_SUCCESS, 'Successfully updated ' . $ext->getName() . ' to ' . $currentVersion)); } else { $report->add(new common_report_Report(common_report_Report::TYPE_WARNING, 'Update of ' . $ext->getName() . ' exited with version ' . $currentVersion)); } common_cache_FileCache::singleton()->purge(); } } else { $report = new common_report_Report(common_report_Report::TYPE_INFO, $ext->getName() . ' already up to data'); } return $report; }
/** * Creates a report without title of the parsing result * @return common_report_Report */ public function getReport() { if ($this->isValid()) { return common_report_Report::createSuccess(''); } else { $report = new common_report_Report(''); foreach ($this->getErrors() as $error) { $report->add(common_report_Report::createFailure($error['message'])); } return $report; } }
/** * Imports the auxiliary files (file elements contained in the resource test element to be imported) into * the TAO Test Content directory. * * If some file cannot be copied, warnings will be committed. * * @param core_kernel_file_File $testContent The pointer to the TAO Test Content directory where auxilliary files will be stored. * @param oat\taoQtiItem\model\qti\Resource $qtiResource The manifest resource describing the test to be imported. * @param string $extractionFolder The absolute path to the temporary folder containing the content of the imported IMS QTI Package Archive. * @param common_report_Report A report about how the importation behaved. */ protected function importTestAuxiliaryFiles(core_kernel_file_File $testContent, Resource $qtiResource, $extractionFolder, common_report_Report $report) { foreach ($qtiResource->getAuxiliaryFiles() as $aux) { try { taoQtiTest_helpers_Utils::storeQtiResource($testContent, $aux, $extractionFolder); } catch (common_Exception $e) { $report->add(new common_report_Report(common_report_Report::TYPE_WARNING, __('Auxiliary file not found at location "%s".', $aux))); } } }
/** * @param $createdResources * @return common_report_Report * @throws common_exception_Error */ protected function getResult($createdResources) { $type = common_report_Report::TYPE_SUCCESS; if ($this->hasErrors()) { $type = common_report_Report::TYPE_WARNING; } if (!$createdResources) { $type = common_report_Report::TYPE_ERROR; } $report = new common_report_Report($type, __('Data imported')); foreach ($this->getErrorMessages() as $group) { $report->add($group); } return $report; }
/** * @param $createdResources * @return common_report_Report * @throws common_exception_Error */ protected function getResult($createdResources) { $message = __('Data imported'); $type = common_report_Report::TYPE_SUCCESS; if ($this->hasErrors()) { $type = common_report_Report::TYPE_WARNING; $message = __('Data imported. Some records are invalid.'); } if (!$createdResources) { $type = common_report_Report::TYPE_ERROR; $message = __('Data not imported. All records are invalid.'); } $report = new common_report_Report($type, $message); foreach ($this->getErrorMessages() as $group) { $report->add($group); } return $report; }