Exemplo n.º 1
0
 /**
  * Entrypoint of every tool
  */
 public function launch()
 {
     try {
         taoLti_models_classes_LtiService::singleton()->startLtiSession(common_http_Request::currentRequest());
         // check if cookie has been set
         if (tao_models_classes_accessControl_AclProxy::hasAccess('verifyCookie', 'CookieUtils', 'taoLti')) {
             $this->redirect(_url('verifyCookie', 'CookieUtils', 'taoLti', array('session' => session_id(), 'redirect' => _url('run', null, null, $_GET))));
         } else {
             $this->returnError(__('You are not authorized to use this system'));
         }
     } catch (common_user_auth_AuthFailedException $e) {
         common_Logger::i($e->getMessage());
         $this->returnError(__('The LTI connection could not be established'), false);
     } catch (taoLti_models_classes_LtiException $e) {
         // In regard of the IMS LTI standard, we have to show a back button that refer to the
         // launch_presentation_return_url url param. So we have to retrieve this parameter before trying to start
         // the session
         $params = common_http_Request::currentRequest()->getParams();
         if (isset($params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_NAME])) {
             $this->setData('consumerLabel', $params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_NAME]);
         } elseif (isset($params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_DESCRIPTION])) {
             $this->setData('consumerLabel', $params[taoLti_models_classes_LtiLaunchData::TOOL_CONSUMER_INSTANCE_DESCRIPTION]);
         }
         if (isset($params[taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL])) {
             $this->setData('returnUrl', $params[taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL]);
         }
         common_Logger::i($e->getMessage());
         $this->returnError(__('The LTI connection could not be established'), false);
     } catch (tao_models_classes_oauth_Exception $e) {
         common_Logger::i($e->getMessage());
         $this->returnError(__('The LTI connection could not be established'), false);
     }
 }
Exemplo n.º 2
0
 /**
  * uninstall an extension
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return boolean
  */
 public function uninstall()
 {
     common_Logger::i('Uninstalling ' . $this->extension->getId(), 'UNINSTALL');
     // uninstall possible
     if (is_null($this->extension->getManifest()->getUninstallData())) {
         throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Uninstall not supported');
     }
     // installed?
     if (!common_ext_ExtensionsManager::singleton()->isInstalled($this->extension->getId())) {
         throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Not installed');
     }
     // check dependcies
     if (helpers_ExtensionHelper::isRequired($this->extension)) {
         throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Still required');
     }
     common_Logger::d('uninstall script for ' . $this->extension->getId());
     $this->uninstallScripts();
     // hook
     $this->extendedUninstall();
     common_Logger::d('unregister extension ' . $this->extension->getId());
     $this->unregister();
     // we purge the whole cache.
     $cache = common_cache_FileCache::singleton();
     $cache->purge();
     common_Logger::i('Uninstalled ' . $this->extension->getId());
     return true;
 }
 /**
  * Creates a new delivery
  * 
  * @param core_kernel_classes_Class $deliveryClass
  * @param core_kernel_classes_Resource $test
  * @param array $properties Array of properties of delivery
  * @return common_report_Report
  */
 public static function create(\core_kernel_classes_Class $deliveryClass, \core_kernel_classes_Resource $test, $properties = array())
 {
     \common_Logger::i('Creating delivery with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel());
     $storage = new TrackedStorage();
     $testCompilerClass = \taoTests_models_classes_TestsService::singleton()->getCompilerClass($test);
     $compiler = new $testCompilerClass($test, $storage);
     $report = $compiler->compile();
     if ($report->getType() == \common_report_Report::TYPE_SUCCESS) {
         //$tz = new \DateTimeZone(\common_session_SessionManager::getSession()->getTimeZone());
         $tz = new \DateTimeZone('UTC');
         if (!empty($properties[TAO_DELIVERY_START_PROP])) {
             $dt = new \DateTime($properties[TAO_DELIVERY_START_PROP], $tz);
             $properties[TAO_DELIVERY_START_PROP] = (string) $dt->getTimestamp();
         }
         if (!empty($properties[TAO_DELIVERY_END_PROP])) {
             $dt = new \DateTime($properties[TAO_DELIVERY_END_PROP], $tz);
             $properties[TAO_DELIVERY_END_PROP] = (string) $dt->getTimestamp();
         }
         $serviceCall = $report->getData();
         $properties[PROPERTY_COMPILEDDELIVERY_DIRECTORY] = $storage->getSpawnedDirectoryIds();
         $compilationInstance = DeliveryAssemblyService::singleton()->createAssemblyFromServiceCall($deliveryClass, $serviceCall, $properties);
         $report->setData($compilationInstance);
     }
     return $report;
 }
 /**
  * @param array $conditions
  * @param string $conditionService
  * @return bool
  */
 protected function complies(array $conditions, $conditionService)
 {
     $clientName = $conditionService::singleton()->getClientName();
     $clientVersion = $conditionService::singleton()->getClientVersion();
     $clientNameResource = $conditionService::singleton()->getClientNameResource();
     \common_Logger::i("Detected client: {$clientName} @ {$clientVersion}");
     $result = false;
     /** @var \core_kernel_classes_Property $browser */
     foreach ($conditions as $condition) {
         if ($condition->exists() === true) {
             /** @var \core_kernel_classes_Resource $requiredName */
             $requiredName = $condition->getOnePropertyValue(new \core_kernel_classes_Property($conditionService::PROPERTY_NAME));
             if ($clientNameResource && !$clientNameResource->equals($requiredName)) {
                 \common_Logger::i("Client rejected. Required name is {$requiredName} but current name is {$clientName}.");
                 continue;
             } elseif ($clientNameResource === null) {
                 \common_Logger::i("Client rejected. Unknown client.");
                 continue;
             }
             $requiredVersion = $condition->getOnePropertyValue(new \core_kernel_classes_Property($conditionService::PROPERTY_VERSION));
             if (-1 !== version_compare($conditionService::singleton()->getClientVersion(), $requiredVersion)) {
                 $result = true;
                 break;
             }
         }
     }
     return $result;
 }
 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'));
 }
 /**
  * Short description of method evaluate
  *
  * @access public
  * @author firstname and lastname of author, <*****@*****.**>
  * @param  array $variable
  * @return mixed
  */
 public function evaluate($variable = array())
 {
     common_Logger::i('Evaluating Term uri : ' . $this->getUri(), array('Generis Term'));
     common_Logger::i('Evaluating Term name : ' . $this->getLabel(), array('Generis Term'));
     $termType = $this->getUniquePropertyValue(new core_kernel_classes_Property(RDF_TYPE));
     common_Logger::d('Term s type : ' . $termType->getUri(), array('Generis Term'));
     switch ($termType->getUri()) {
         case CLASS_TERM:
             throw new common_Exception("Forbidden Type of Term");
             break;
         case CLASS_TERM_SUJET_PREDICATE_X:
             $returnValue = $this->evaluateSPX($variable);
             break;
         case CLASS_TERM_X_PREDICATE_OBJECT:
             $returnValue = $this->evaluateXPO();
             break;
         case CLASS_CONSTRUCTED_SET:
             $returnValue = $this->evaluateSet();
             break;
         case CLASS_TERM_CONST:
             $returnValue = $this->evaluateConst();
             break;
         case CLASS_OPERATION:
             $returnValue = $this->evaluateOperation($variable);
             break;
         default:
             throw new common_Exception('problem evaluating Term');
     }
     return $returnValue;
 }
 /**
  *
  * @param array callOptions an array of parameters sent to the results storage configuration
  * @param mixed $resultServer
  * @param string uri or resource
  */
 public function __construct($resultServer, $additionalStorages = array())
 {
     $this->implementations = array();
     if (is_object($resultServer) and get_class($resultServer) == 'core_kernel_classes_Resource') {
         $this->resultServer = $resultServer;
     } else {
         if (common_Utils::isUri($resultServer)) {
             $this->resultServer = new core_kernel_classes_Resource($resultServer);
         }
     }
     // the static storages
     if ($this->resultServer->getUri() != TAO_VOID_RESULT_SERVER) {
         $resultServerModels = $this->resultServer->getPropertyValues(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_PROP));
         if (!isset($resultServerModels) or count($resultServerModels) == 0) {
             throw new common_Exception("The result server is not correctly configured (Resource definition)");
         }
         foreach ($resultServerModels as $resultServerModelUri) {
             $resultServerModel = new core_kernel_classes_Resource($resultServerModelUri);
             $this->addImplementation($resultServerModel->getUniquePropertyValue(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_IMPL_PROP))->literal);
         }
     }
     if (!is_null($additionalStorages)) {
         // the dynamic storages
         foreach ($additionalStorages as $additionalStorage) {
             $this->addImplementation($additionalStorage["implementation"], $additionalStorage["parameters"]);
         }
     }
     common_Logger::i("Result Server Initialized using defintion:" . $this->resultServer->getUri());
     // sets the details required depending on the type of storage
 }
 public function __invoke($params)
 {
     $persistenceId = count($params) > 0 ? reset($params) : 'default';
     $persistence = $this->getServiceLocator()->get(\common_persistence_Manager::SERVICE_KEY)->getPersistenceById($persistenceId);
     $schemaManager = $persistence->getDriver()->getSchemaManager();
     $schema = $schemaManager->createSchema();
     $fromSchema = clone $schema;
     try {
         $revisionTable = $schema->createtable(Storage::REVISION_TABLE_NAME);
         $revisionTable->addOption('engine', 'MyISAM');
         $revisionTable->addColumn(Storage::REVISION_RESOURCE, "string", array("notnull" => false, "length" => 255));
         $revisionTable->addColumn(Storage::REVISION_VERSION, "string", array("notnull" => false, "length" => 50));
         $revisionTable->addColumn(Storage::REVISION_USER, "string", array("notnull" => true, "length" => 255));
         $revisionTable->addColumn(Storage::REVISION_CREATED, "string", array("notnull" => true));
         $revisionTable->addColumn(Storage::REVISION_MESSAGE, "string", array("notnull" => true, "length" => 4000));
         $revisionTable->setPrimaryKey(array(Storage::REVISION_RESOURCE, Storage::REVISION_VERSION));
         $dataTable = $schema->createtable(Storage::DATA_TABLE_NAME);
         $dataTable->addOption('engine', 'MyISAM');
         $dataTable->addColumn(Storage::DATA_RESOURCE, "string", array("notnull" => false, "length" => 255));
         $dataTable->addColumn(Storage::DATA_VERSION, "string", array("notnull" => false, "length" => 50));
         $dataTable->addColumn(Storage::DATA_SUBJECT, "string", array("notnull" => true, "length" => 255));
         $dataTable->addColumn(Storage::DATA_PREDICATE, "string", array("length" => 255));
         // not compatible with oracle
         $dataTable->addColumn(Storage::DATA_OBJECT, "text", array("default" => null, "notnull" => false));
         $dataTable->addColumn(Storage::DATA_LANGUAGE, "string", array("length" => 50));
         $dataTable->addForeignKeyConstraint($revisionTable, array(Storage::REVISION_RESOURCE, Storage::REVISION_VERSION), array(Storage::REVISION_RESOURCE, Storage::REVISION_VERSION));
     } 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);
     }
 }
Exemplo n.º 9
0
 /**
  * Update all the item files found within the $itemRootPath
  * @param boolean $changeItemContent - tells if the item files will be written with the updated content or not
  * @return array of modified item instances
  */
 public function update($changeItemContent = false)
 {
     $returnValue = array();
     $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->itemPath), RecursiveIteratorIterator::SELF_FIRST);
     $i = 0;
     $fixed = 0;
     foreach ($objects as $itemFile => $cursor) {
         if (is_file($itemFile)) {
             $this->checkedFiles[$itemFile] = false;
             if (basename($itemFile) === 'qti.xml') {
                 $i++;
                 $xml = new \DOMDocument();
                 $xml->load($itemFile);
                 $parser = new ParserFactory($xml);
                 $item = $parser->load();
                 \common_Logger::i('checking item #' . $i . ' id:' . $item->attr('identifier') . ' file:' . $itemFile);
                 if ($this->updateItem($item, $itemFile)) {
                     $this->checkedFiles[$itemFile] = true;
                     $returnValue[$itemFile] = $item;
                     \common_Logger::i('fixed required for #' . $i . ' id:' . $item->attr('identifier') . ' file:' . $itemFile);
                     if ($changeItemContent) {
                         $fixed++;
                         \common_Logger::i('item fixed #' . $i . ' id:' . $item->attr('identifier') . ' file:' . $itemFile);
                         file_put_contents($itemFile, $item->toXML());
                     }
                 }
             }
         }
     }
     \common_Logger::i('total item fixed : ' . $fixed);
     return $returnValue;
 }
Exemplo n.º 10
0
 /**
  * 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));
 }
Exemplo n.º 11
0
 /**
  * Short description of method authenticate
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Repository vcs
  * @param  string login
  * @param  string password
  * @return boolean
  */
 public function authenticate(core_kernel_versioning_Repository $vcs, $login, $password)
 {
     $returnValue = (bool) false;
     common_Logger::i(__FUNCTION__ . ' called on local directory', 'LOCALVCS');
     $returnValue = is_dir($vcs->getPath());
     return (bool) $returnValue;
 }
Exemplo n.º 12
0
 public function setUp()
 {
     TaoPhpUnitTestRunner::initTest();
     $this->disableCache();
     // creates a user using remote script from joel
     $testUserData = array(PROPERTY_USER_LOGIN => 'tjdoe', PROPERTY_USER_PASSWORD => 'test123', PROPERTY_USER_LASTNAME => 'Doe', PROPERTY_USER_FIRSTNAME => 'John', PROPERTY_USER_MAIL => '*****@*****.**', PROPERTY_USER_DEFLG => \tao_models_classes_LanguageService::singleton()->getLanguageByCode(DEFAULT_LANG)->getUri(), PROPERTY_USER_UILG => \tao_models_classes_LanguageService::singleton()->getLanguageByCode(DEFAULT_LANG)->getUri(), PROPERTY_USER_ROLES => array(INSTANCE_ROLE_GLOBALMANAGER));
     $testUserData[PROPERTY_USER_PASSWORD] = 'test' . rand();
     $data = $testUserData;
     $data[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($data[PROPERTY_USER_PASSWORD]);
     $tmclass = new \core_kernel_classes_Class(CLASS_TAO_USER);
     $user = $tmclass->createInstanceWithProperties($data);
     \common_Logger::i('Created user ' . $user->getUri());
     // prepare a lookup table of languages and values
     $usage = new \core_kernel_classes_Resource(INSTANCE_LANGUAGE_USAGE_GUI);
     $propValue = new \core_kernel_classes_Property(RDF_VALUE);
     $langService = \tao_models_classes_LanguageService::singleton();
     $lookup = array();
     foreach ($langService->getAvailableLanguagesByUsage($usage) as $lang) {
         $lookup[$lang->getUri()] = (string) $lang->getUniquePropertyValue($propValue);
     }
     $data = array('rootUrl' => ROOT_URL, 'userUri' => $user->getUri(), 'userData' => $testUserData, 'lang' => $lookup);
     $this->login = $data['userData'][PROPERTY_USER_LOGIN];
     $this->password = $data['userData'][PROPERTY_USER_PASSWORD];
     $this->userUri = $data['userUri'];
 }
Exemplo n.º 13
0
 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'));
 }
Exemplo n.º 14
0
 /**
  * Export models by id
  * 
  * @param array $modelIds
  * @return string
  */
 public static function exportModels($modelIds)
 {
     $dbWrapper = core_kernel_classes_DbWrapper::singleton();
     $result = $dbWrapper->query('SELECT DISTINCT "subject", "predicate", "object", "l_language" FROM "statements" 
         WHERE "modelid" IN (\'' . implode('\',\'', $modelIds) . '\')');
     common_Logger::i('Found ' . $result->rowCount() . ' entries for models ' . implode(',', $modelIds));
     return self::statement2rdf($result);
 }
Exemplo n.º 15
0
 protected static function cloneFile($fileUri)
 {
     \common_Logger::i('clone file ' . $fileUri);
     $file = new \core_kernel_versioning_File($fileUri);
     $newFile = $file->getRepository()->spawnFile($file->getAbsolutePath(), $file->getLabel(), function ($originalName) {
         return md5($originalName);
     });
     return $newFile->getUri();
 }
 /**
  * Creates a new simple delivery
  * 
  * @param core_kernel_classes_Class $deliveryClass
  * @param core_kernel_classes_Resource $test
  * @param string $label
  * @return common_report_Report
  */
 public function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label)
 {
     common_Logger::i('Creating ' . $label . ' with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel());
     $contentClass = new core_kernel_classes_Class(CLASS_SIMPLE_DELIVERYCONTENT);
     $content = $contentClass->createInstanceWithProperties(array(PROPERTY_DELIVERYCONTENT_TEST => $test->getUri()));
     $report = TemplateAssemblyService::singleton()->createAssemblyByContent($deliveryClass, $content, array(RDFS_LABEL => $label));
     $content->delete();
     return $report;
 }
 /**
  * Builds a simple Diagram of the Process
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource process
  * @return string
  */
 public static function buildDiagramData(core_kernel_classes_Resource $process)
 {
     $returnValue = (string) '';
     common_Logger::i("Building diagram for " . $process->getLabel());
     $authoringService = wfAuthoring_models_classes_ProcessService::singleton();
     $activityService = wfEngine_models_classes_ActivityService::singleton();
     $connectorService = wfEngine_models_classes_ConnectorService::singleton();
     $activityCardinalityService = wfEngine_models_classes_ActivityCardinalityService::singleton();
     $activities = $authoringService->getActivitiesByProcess($process);
     $todo = array();
     foreach ($activities as $activity) {
         if ($activityService->isInitial($activity)) {
             $todo[] = $activity;
         }
     }
     $currentLevel = 0;
     $diagram = new wfAuthoring_models_classes_ProcessDiagram();
     $done = array();
     while (!empty($todo)) {
         $nextLevel = array();
         $posOnLevel = 0;
         foreach ($todo as $item) {
             $next = array();
             if ($activityService->isActivity($item)) {
                 // add this activity
                 $diagram->addActivity($item, 54 + 200 * $posOnLevel + 10 * $currentLevel, 35 + 80 * $currentLevel);
                 $next = array_merge($next, $activityService->getNextConnectors($item));
                 common_Logger::d('Activity added ' . $item->getUri());
             } elseif ($connectorService->isConnector($item)) {
                 // add this connector
                 $diagram->addConnector($item, 100 + 200 * $posOnLevel + 10 * $currentLevel, 40 + 80 * $currentLevel);
                 $next = array_merge($next, $connectorService->getNextActivities($item));
             } else {
                 common_Logger::w('unexpected ressource in process ' . $item->getUri());
             }
             //replace cardinalities
             foreach ($next as $key => $destination) {
                 if ($activityCardinalityService->isCardinality($destination)) {
                     // not represented on diagram
                     $next[$key] = $activityCardinalityService->getDestination($destination);
                 }
             }
             //add arrows
             foreach ($next as $destination) {
                 $diagram->addArrow($item, $destination);
             }
             $posOnLevel++;
             $nextLevel = array_merge($nextLevel, $next);
         }
         $done = array_merge($done, $todo);
         $todo = array_diff($nextLevel, $done);
         $currentLevel++;
     }
     $returnValue = $diagram->toJSON();
     return (string) $returnValue;
 }
Exemplo n.º 18
0
 public static function getLgDependencyCache($uri)
 {
     try {
         $lgDependencyCache = common_cache_FileCache::singleton()->get(self::getSerial($uri));
     } catch (common_cache_NotFoundException $e) {
         common_Logger::i('Could not find Lgdependent cache , initializing for ' . $uri);
         return null;
     }
     return $lgDependencyCache;
 }
 /**
  * (non-PHPdoc)
  * 
  * @see taoTests_models_classes_TestModel::getAuthoring()
  */
 public function getAuthoring(core_kernel_classes_Resource $content)
 {
     common_Logger::i('Generating form for delivery content ' . $content->getUri());
     $widget = new Renderer($this->extension->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl');
     $form = new taoSimpleDelivery_actions_form_ContentForm($this->getClass(), $content);
     $widget->setData('formContent', $form->getForm()->render());
     $widget->setData('saveUrl', _url('save', 'Authoring', 'taoSimpleDelivery'));
     $widget->setData('formId', $form->getForm()->getName());
     return $widget->render();
 }
 /**
  * Overriden export from QTI items.
  *
  * @param array $options An array of options.
  * @see taoItems_models_classes_ItemExporter::export()
  */
 public function export($options = array())
 {
     $asApip = isset($options['apip']) && $options['apip'] === true;
     $lang = \common_session_SessionManager::getSession()->getDataLanguage();
     $basePath = $this->buildBasePath();
     $dataFile = (string) $this->getItemModel()->getOnePropertyValue(new core_kernel_classes_Property(TAO_ITEM_MODEL_DATAFILE_PROPERTY));
     $content = $this->getItemService()->getItemContent($this->getItem());
     $resolver = new ItemMediaResolver($this->getItem(), $lang);
     // get the local resources and add them
     foreach ($this->getAssets($this->getItem(), $lang) as $assetUrl) {
         $mediaAsset = $resolver->resolve($assetUrl);
         $mediaSource = $mediaAsset->getMediaSource();
         if (get_class($mediaSource) !== 'oat\\tao\\model\\media\\sourceStrategy\\HttpSource') {
             $srcPath = $mediaSource->download($mediaAsset->getMediaIdentifier());
             $fileInfo = $mediaSource->getFileInfo($mediaAsset->getMediaIdentifier());
             $filename = $fileInfo['filePath'];
             $replacement = $mediaAsset->getMediaIdentifier();
             if ($mediaAsset->getMediaIdentifier() !== $fileInfo['uri']) {
                 $replacement = $filename;
             }
             $destPath = ltrim($filename, '/');
             if (file_exists($srcPath)) {
                 $this->addFile($srcPath, $basePath . '/' . $destPath);
                 $content = str_replace($assetUrl, $replacement, $content);
             } else {
                 throw new \Exception('Missing resource ' . $srcPath);
             }
         }
     }
     if ($asApip === true) {
         // 1. let's merge qti.xml and apip.xml.
         // 2. retrieve apip related assets.
         $apipService = ApipService::singleton();
         $apipContentDoc = $apipService->getApipAccessibilityContent($this->getItem());
         if ($apipContentDoc === null) {
             \common_Logger::i("No APIP accessibility content found for item '" . $this->getItem()->getUri() . "', default inserted.");
             $apipContentDoc = $apipService->getDefaultApipAccessibilityContent($this->getItem());
         }
         $qtiItemDoc = new DOMDocument('1.0', 'UTF-8');
         $qtiItemDoc->formatOutput = true;
         $qtiItemDoc->loadXML($content);
         // Let's merge QTI and APIP Accessibility!
         Apip::mergeApipAccessibility($qtiItemDoc, $apipContentDoc);
         $content = $qtiItemDoc->saveXML();
         $fileHrefElts = $qtiItemDoc->getElementsByTagName('fileHref');
         for ($i = 0; $i < $fileHrefElts->length; $i++) {
             $fileHrefElt = $fileHrefElts->item($i);
             $destPath = $basePath . '/' . $fileHrefElt->nodeValue;
             $sourcePath = $this->getItemLocation() . $fileHrefElt->nodeValue;
             $this->addFile($sourcePath, $destPath);
         }
     }
     // add xml file
     $this->getZip()->addFromString($basePath . '/' . $dataFile, $content);
 }
 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'));
 }
Exemplo n.º 22
0
 /**
  * Short description of method getExpression
  *
  * @access public
  * @author firstname and lastname of author, <*****@*****.**>
  * @return core_kernel_rules_Expression
  */
 public function getExpression()
 {
     $returnValue = null;
     common_Logger::i('Evaluating rule ' . $this->getLabel() . '(' . $this->getUri() . ')', array('Generis Rule'));
     if (empty($this->expression)) {
         $property = new core_kernel_classes_Property(PROPERTY_RULE_IF);
         $this->expression = new core_kernel_rules_Expression($this->getUniquePropertyValue($property)->getUri(), __METHOD__);
     }
     $returnValue = $this->expression;
     return $returnValue;
 }
Exemplo n.º 23
0
 public function getApipAccessibilityContent(\core_kernel_classes_Resource $item)
 {
     $apipContent = null;
     $itemService = taoItems_models_classes_ItemsService::singleton();
     $finalLocation = $itemService->getItemFolder($item) . 'apip.xml';
     if (is_readable($finalLocation) === true) {
         $apipContent = new \DOMDocument('1.0', 'UTF-8');
         $apipContent->load($finalLocation);
         \common_Logger::i("APIP content retrieved at '{$finalLocation}'.");
     }
     return $apipContent;
 }
 public function index()
 {
     $test = $this->getCurrentInstance();
     $testService = taoTests_models_classes_TestsService::singleton();
     $class = new core_kernel_classes_Class(CLASS_LTI_TESTCONTENT);
     $content = $test->getOnePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP));
     common_Logger::i('Generating form for ' . $content->getUri());
     $form = new ltiTestConsumer_actions_form_LtiLinkForm($content);
     $this->setData('saveUrl', _url('save', 'Authoring', 'ltiTestConsumer'));
     $this->setData('formContent', $form->getForm()->render());
     $this->setView('authoring.tpl');
 }
 /**
  * @deprecated
  * @see taoTests_models_classes_TestModel::getAuthoring()
  */
 public function getAuthoring(core_kernel_classes_Resource $test)
 {
     $testService = taoTests_models_classes_TestsService::singleton();
     $class = new core_kernel_classes_Class(CLASS_LTI_TESTCONTENT);
     $content = $test->getOnePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP));
     common_Logger::i('Generating form for ' . $content->getUri());
     $form = new ltiTestConsumer_actions_form_LtiLinkForm($content);
     $form->getForm()->setActions(array());
     $widget = new Renderer($this->extension->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl');
     $widget->setData('formContent', $form->getForm()->render());
     $widget->setData('saveUrl', _url('save', 'Authoring', 'ltiTestConsumer'));
     $widget->setData('formName', $form->getForm()->getName());
     return $widget->render();
 }
Exemplo n.º 26
0
 /**
  * Gets a user from a URI
  *
  * @todo Make a stronger helper which take care of provider (LDAP, OAUTH, etc.)
  *
  * @param string $userId
  * @return User
  */
 public static function getUser($userId)
 {
     if (is_string($userId)) {
         $userId = new core_kernel_classes_Resource($userId);
     }
     if ($userId instanceof core_kernel_classes_Resource) {
         $userId = new core_kernel_users_GenerisUser($userId);
     }
     if (!$userId instanceof core_kernel_users_GenerisUser) {
         \common_Logger::i('Unable to get user from ' . $userId);
         $userId = null;
     }
     return $userId;
 }
Exemplo n.º 27
0
 /**
  * (non-PHPdoc)
  * @see \oat\tao\model\search\Search::index()
  */
 public function index(\Traversable $resourceTraversable)
 {
     // flush existing index
     $this->flushIndex();
     $count = 0;
     // index the resources
     foreach ($resourceTraversable as $resource) {
         $indexer = new ZendIndexer($resource);
         $this->getIndex()->addDocument($indexer->toDocument());
         $count++;
     }
     \common_Logger::i('Reindexed ' . $count . ' resources');
     return $count;
 }
 /**
  * Handle the process to add file from $itemSource->add()
  *
  * @param $absolutePath
  * @param $relativePath
  * @return array
  * @throws \common_Exception
  * @throws \common_exception_Error
  */
 public function handle($absolutePath, $relativePath)
 {
     if (!$this->itemSource) {
         throw new \common_Exception('Missing required parameter: item source');
     }
     // store locally, in a safe directory
     $safePath = '';
     if (dirname($relativePath) !== '.') {
         $safePath = str_replace('../', '', dirname($relativePath)) . '/';
     }
     $info = $this->itemSource->add($absolutePath, basename($absolutePath), $safePath);
     \common_Logger::i('Asset file \'' . $absolutePath . '\' copied.');
     return $info;
 }
 public function __invoke($params)
 {
     $storageService = $this->getServiceManager()->get(Storage::SERVICE_ID);
     if (!$storageService instanceof Sql) {
         return new \common_report_Report(\common_report_Report::TYPE_WARNING, 'Diagnostic tool storage is not compatible to create table');
     }
     $persistence = $storageService->getPersistence();
     $schemaManager = $persistence->getDriver()->getSchemaManager();
     $schema = $schemaManager->createSchema();
     $fromSchema = clone $schema;
     try {
         $tableResults = $schema->createtable(Sql::DIAGNOSTIC_TABLE);
         $tableResults->addOption('engine', 'MyISAM');
         $tableResults->addColumn(Sql::DIAGNOSTIC_ID, 'string', ['length' => 16]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_LOGIN, 'string', ['length' => 32]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_IP, 'string', ['length' => 32]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BROWSER, 'string', ['length' => 32, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BROWSERVERSION, 'string', ['length' => 32, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_OS, 'string', ['length' => 32, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_OSVERSION, 'string', ['length' => 32, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_COMPATIBLE, 'integer', ['length' => 1, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_VERSION, 'string', ['length' => 16]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_MIN, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_MAX, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_SUM, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_COUNT, 'integer', ['length' => 16, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_AVERAGE, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_MEDIAN, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_VARIANCE, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_DURATION, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_BANDWIDTH_SIZE, 'integer', ['length' => 16, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_PERFORMANCE_MIN, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_PERFORMANCE_MAX, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_PERFORMANCE_SUM, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_PERFORMANCE_COUNT, 'integer', ['length' => 16, 'notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_PERFORMANCE_AVERAGE, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_PERFORMANCE_MEDIAN, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_PERFORMANCE_VARIANCE, 'float', ['notnull' => false]);
         $tableResults->addColumn(Sql::DIAGNOSTIC_CREATED_AT, 'datetime');
         $tableResults->setPrimaryKey(array(Sql::DIAGNOSTIC_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.');
     }
     return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'Diagnostic successfully created');
 }
Exemplo n.º 30
0
 public function setUp()
 {
     TaoPhpUnitTestRunner::initTest();
     $this->disableCache();
     // creates a user using remote script from joel
     $userdata = $this->getUserData();
     $password = $userdata[PROPERTY_USER_PASSWORD];
     $userdata[PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($userdata[PROPERTY_USER_PASSWORD]);
     $tmclass = new \core_kernel_classes_Class(CLASS_TAO_USER);
     $user = $tmclass->createInstanceWithProperties($userdata);
     \common_Logger::i('Created user ' . $user->getUri());
     $this->login = $userdata[PROPERTY_USER_LOGIN];
     $this->password = $password;
     $this->userUri = $user->getUri();
 }