@param string $deliveryResultIdentifier

@return string
510286
public function getDirPath($deliveryResultIdentifier)
    {
        $path = md5($deliveryResultIdentifier);

        $slashPosition = 1;
        for ($i = 1; $i < 4; $i++) {
            $path = substr_replace($path, '/', $slashPosition, 0);
            $slashPosition += 2;
        }

        return $path;
    }
287229
public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled)
    {
        $query = $this->getQueryBuilder()
            ->select("*")
            ->from(self::TABLE_NAME)
            ->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
            ->setParameter("deliveryId", $compiled->getUri())
        ;

        return array_map(function($row) {
            return $this->parseQueryResult($row);
        }, $query->execute()->fetchAll());
    }
58605
public function getDeliveryThemeIdFromCache($deliveryId)
    {
        if ($this->getCachePersistence() === null) {
            return false;
        }

        return $this->getCachePersistence()->get($this->getCacheKey($deliveryId));
    }
928233
public function getDeliveryExecutionXml(DeliveryExecutionInterface $deliveryExecution)
    {
        return $this->getQtiResultXml($deliveryExecution->getDelivery()->getUri(), $deliveryExecution->getIdentifier());
    }
543507
public function getSoftDescriptor(\TdbShopOrder $order, $invoiceNumber = null)
    {
        $text = $this->getValue('softDescriptor');
        $data = $this->getTemplateDataFromOrder($order);
        $data['invoiceNumber'] = $invoiceNumber;

        return mb_substr($this->render($text, $data), 0, 16);
    }
639210
public function getDeliveryData(DeliveryExecutionInterface $deliveryExecution)
    {
        $result = [
            'start' => $deliveryExecution->getStartTime(),
            'end' => $deliveryExecution->getFinishTime(),
            'label' => $deliveryExecution->getLabel()
        ];
        return $result;
    }
1263921
public function getResultStorage($deliveryId = null)
    {
        if ($deliveryId !== null) {
            $delivery = $this->getResource($deliveryId);
            $deliveryResultServer = $delivery->getOnePropertyValue($this->getProperty(self::PROPERTY_RESULT_SERVER));
        }
        if (!isset($deliveryResultServer) || !$deliveryResultServer) {
            $deliveryResultServer = \taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer();
        }

        if(is_null($deliveryResultServer)){
            throw new \common_exception_Error(__('This delivery has no Result Server'));
        }
        $resultServerModel = $deliveryResultServer->getPropertyValues($this->getProperty(static::PROPERTY_HAS_MODEL));

        if(is_null($resultServerModel)){
            throw new \common_exception_Error(__('This delivery has no readable Result Server'));
        }

        $implementations = array();
        foreach($resultServerModel as $model){
            $model = $this->getClass($model);

            /** @var $implementation \core_kernel_classes_Literal*/
            $implementation = $model->getOnePropertyValue($this->getProperty(static::PROPERTY_MODEL_IMPL));

            if ($implementation !== null) {
                $implementations[] = $this->instantiateResultStorage($implementation->literal);
            }
        }

        if (empty($implementations)) {
            throw new \common_exception_Error(__('This delivery has no readable Result Server'));
        } elseif (count($implementations) == 1) {
            return reset($implementations);
        } else {
            return new StorageAggregation($implementations);
        }
    }
598021
public function getIdentifier() : ?string 
    {
        if ( ! $this->hasIdentifier()) {
            $this->setIdentifier($this->getDefaultIdentifier());
        }
        return $this->identifier;
    }
986322
public function storeItemVariables($deliveryResultIdentifier, $test, $item, array $itemVariables, $callIdItem)
    {
        $varContents = array_map(
            function ($value) {
                return serialize($value);
            },
            $itemVariables
        );
        common_logger::i("LoggerStorage - StoreItemVariables :" . $test . " item:" . $item . " callid:" . $callIdItem . "variables:" . implode(' - ', $varContents) . " into " . $deliveryResultIdentifier);
    }
555468
public function get(string $entryIdentifier)
    {
        return $this->uncompress($this->redis->get($this->buildKey('entry:' . $entryIdentifier)));
    }
1164146
public function getResultsData(DeliveryExecutionInterface $deliveryExecution)
    {
        $result = [];
        $resultService = $this->getResultService($deliveryExecution->getDelivery());

        $itemsData = $resultService->getItemVariableDataFromDeliveryResult($deliveryExecution->getIdentifier(), 'lastSubmitted');

        foreach ($itemsData as $itemData) {
            $rawResult = [];
            $rawResult['label'] = $itemData['label'];
            foreach ($itemData['sortedVars'] as $variables) {
                $variableValues = array_map(function ($variable) {
                    $variable = current($variable);
                    return $variable['var']->getValue();
                }, $variables);
                $rawResult = array_merge($rawResult, $variableValues);
            };
            $result[] = $rawResult;
        }
        return $result;
    }
1006401
public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = "            ", $phpType = null)
    {
        return sprintf(
            "
%s%s = %s%s->lastInsertId(%s);",
            $tab,
            $columnValueMutator,
            $connectionVariableName,
            $phpType ? '('.$phpType.') ' : '',
            $sequenceName ? ("'" . $sequenceName . "'") : ''
        );
    }
945765
public function getPrintableRubric(DeliveryExecutionInterface $deliveryExecution)
    {
        $testSessionService = ServiceManager::getServiceManager()->get(TestSessionService::SERVICE_ID);
        $session = $testSessionService->getTestSession($deliveryExecution);

        $inputParameters = $testSessionService->getRuntimeInputParameters($deliveryExecution);
        $testDefinition = \taoQtiTest_helpers_Utils::getTestDefinition($inputParameters['QtiTestCompilation']);
        $sections = $testDefinition->getComponentsByClassName('assessmentSection');

        $tag = $this->getOption(self::OPTION_PRINTABLE_RUBRIC_TAG);

        $directoryIds = explode('|', $inputParameters['QtiTestCompilation']);
        $compilationDirs = array(
            'private' => \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[0]),
            'public' => \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[1]),
        );

        $rubrics = [];

        // -- variables used in the included rubric block templates.
        // base path (base URI to be used for resource inclusion).
        $basePathVarName = taoQtiTest_models_classes_QtiTestService::TEST_BASE_PATH_NAME;
        $$basePathVarName = $compilationDirs['public']->getPublicAccessUrl();

        // state name (the variable to access to get the state of the assessmentTestSession).
        $stateName = taoQtiTest_models_classes_QtiTestService::TEST_RENDERING_STATE_NAME;
        $$stateName = $session;

        // views name (the variable to be accessed for the visibility of rubric blocks).
        $viewsName = taoQtiTest_models_classes_QtiTestService::TEST_VIEWS_NAME;
        $$viewsName = array(View::CANDIDATE);

        foreach ($sections as $section) {
            $assessmentItemsRef = $section->getComponentsByClassName('assessmentItemRef');
            foreach ($assessmentItemsRef as $item) {
                foreach($item->getCategories() as $category) {
                    if ($category === $tag) {
                        foreach ($section->getRubricBlockRefs() as $rubric) {
                            ob_start();
                            include $compilationDirs['private']->getPath() . '/' . ltrim($rubric->getHref(), './\\');
                            $rubrics[] = ob_get_clean();
                        }
                    }
                };
            };
        }

        return $rubrics;
    }
608724
public function getDeliveryIdFromSession($deliveryExecutionId)
    {
        if (\PHPSession::singleton()->hasAttribute(static::getDeliveryIdSessionKey($deliveryExecutionId))){
            return \PHPSession::singleton()->getAttribute(static::getDeliveryIdSessionKey($deliveryExecutionId));
        }

        return false;
    }
539379
public function editDelivery()
    {
        $this->defaultData();

        $class = $this->getCurrentClass();
        $delivery = $this->getCurrentInstance();

        //Removing Result Server form field if it is hardcoded in configuration
        //since property name (and possibly property itself) is deprecated then this lines will go away to
        //when "deprecation period" will be over
        /** @var ResultServerService $resultServerService */
        $resultServerService = $this->getServiceManager()->get(ResultServerService::SERVICE_ID);
        if (!$resultServerService->isConfigurable()) {
            $options = [];
        } else {
            $options = [
                'excludedProperties' => [
                    OntologyService::PROPERTY_RESULT_SERVER
                ]
            ];
        }

        $formContainer = new DeliveryForm($class, $delivery, $options);
        $myForm = $formContainer->getForm();
        $deliveryUri = $delivery->getUri();

        if ($myForm->isSubmited() && $myForm->isValid()) {
            $this->validateInstanceRoot($deliveryUri);
            $propertyValues = $myForm->getValues();

            // then save the property values as usual
            $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
            $delivery = $binder->bind($propertyValues);

            $this->getEventManager()->trigger(new DeliveryUpdatedEvent($deliveryUri, $propertyValues));

            $this->setData('selectNode', \tao_helpers_Uri::encode($deliveryUri));
            $this->setData('message', __('Delivery saved'));
            $this->setData('reload', true);
        }

        $this->setData('label', $delivery->getLabel());

        // history
        $this->setData('date', $this->getClassService()->getCompilationDate($delivery));
        $serviceProxy = $this->getServiceLocator()->get(ServiceProxy::SERVICE_ID);
        if ($serviceProxy instanceof Monitoring) {
            $execs = $serviceProxy->getExecutionsByDelivery($delivery);
            $this->setData('exec', count($execs));
        }

        // define the groups related to the current delivery
        $property = $this->getProperty(GroupAssignment::PROPERTY_GROUP_DELIVERY);
        $tree = \tao_helpers_form_GenerisTreeForm::buildReverseTree($delivery, $property);
        $tree->setTitle(__('Assigned to'));
        $tree->setTemplate(Template::getTemplate('widgets/assignGroup.tpl'));
        $this->setData('groupTree', $tree->render());

        // testtaker brick
        $this->setData('assemblyUri', $deliveryUri);

        // define the subjects excluded from the current delivery
        $property = $this->getProperty(DeliveryContainerService::PROPERTY_EXCLUDED_SUBJECTS);
        $excluded = $delivery->getPropertyValues($property);
        $this->setData('ttexcluded', count($excluded));

        $users = $this->getServiceLocator()->get(AssignmentService::SERVICE_ID)->getAssignedUsers($deliveryUri);
        $assigned = array_diff(array_unique($users), $excluded);
        $this->setData('ttassigned', count($assigned));
        $updatedAt = $this->getServiceLocator()->get(ResourceWatcher::SERVICE_ID)->getUpdatedAt($delivery);
        $this->setData('updatedAt', $updatedAt);
        $this->setData('formTitle', __('Properties'));
        $this->setData('myForm', $myForm->render());

        if ($this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID)->isEnabled('taoCampaign')) {
            $this->setData('campaign', taoCampaign_helpers_Campaign::renderCampaignTree($delivery));
        }
        $this->setView('DeliveryMgmt/editDelivery.tpl');
    }
158363
public function getVariableDataFromDeliveryResult($resultIdentifier, $wantedTypes = array(\taoResultServer_models_classes_ResponseVariable::class,\taoResultServer_models_classes_OutcomeVariable::class, \taoResultServer_models_classes_TraceVariable::class)) {
        $variablesData = array();
        foreach ($this->getTestsFromDeliveryResult($resultIdentifier) as $testResult) {
            foreach ($this->getVariablesFromObjectResult($testResult) as $variable) {
                if($variable[0]->callIdTest != "" && in_array(get_class($variable[0]->variable), $wantedTypes)){
                    $variablesData[] = $variable[0]->variable;
                }
            }
        }
        usort($variablesData, function($a, $b){
            list($usec, $sec) = explode(" ", $a->getEpoch());
            $floata = ((float) $usec + (float) $sec);
            list($usec, $sec) = explode(" ", $b->getEpoch());
            $floatb = ((float) $usec + (float) $sec);

            if ((floatval($floata) - floatval($floatb)) > 0) {
                return 1;
            } elseif ((floatval($floata) - floatval($floatb)) < 0) {
                return -1;
            } else {
                return 0;
            }
        });
        return $variablesData;
    }
415776
private static function adjustDeliveryExecutions($deliveryExecutions) {

        /** @var TestSessionConnectivityStatusService $testSessionConnectivityStatusService */
        $testSessionConnectivityStatusService = ServiceManager::getServiceManager()->get(TestSessionConnectivityStatusService::SERVICE_ID);

        $executions = [];
        foreach ($deliveryExecutions as $cachedData) {

            $state = [
                'status' => $cachedData[DeliveryMonitoringService::STATUS],
                'progress' => $cachedData[DeliveryMonitoringService::CURRENT_ASSESSMENT_ITEM]
            ];

            $testTaker = [];
            $extraFields = [];

            /* @var $user User */
            $testTaker['id'] = $cachedData[DeliveryMonitoringService::TEST_TAKER];
            $testTaker['test_taker_last_name'] = (isset($cachedData[DeliveryMonitoringService::TEST_TAKER_LAST_NAME]))?_dh($cachedData[DeliveryMonitoringService::TEST_TAKER_LAST_NAME]):'';
            $testTaker['test_taker_first_name'] = (isset($cachedData[DeliveryMonitoringService::TEST_TAKER_FIRST_NAME]))?_dh($cachedData[DeliveryMonitoringService::TEST_TAKER_FIRST_NAME]):'';

            foreach(self::_getUserExtraFields() as $field){
                $extraFields[$field['id']] = isset($cachedData[$field['id']]) ? _dh($cachedData[$field['id']]) : '';
            }

            $online = null;
            if ($testSessionConnectivityStatusService->hasOnlineMode()) {
                $rawConnectivity = isset($cachedData[DeliveryMonitoringService::CONNECTIVITY]) ? $cachedData[DeliveryMonitoringService::CONNECTIVITY] : false;
                $online = $testSessionConnectivityStatusService->isOnline($cachedData[DeliveryMonitoringService::DELIVERY_EXECUTION_ID], $rawConnectivity);
            }

            if (isset($cachedData[DeliveryMonitoringService::LAST_TEST_TAKER_ACTIVITY]) && $online) {
                $lastActivity = $cachedData[DeliveryMonitoringService::LAST_TEST_TAKER_ACTIVITY];
            } else {
                $lastActivity = null;
            }

            $executionState = $cachedData[DeliveryMonitoringService::STATUS];
            $extraTime = (isset($cachedData[DeliveryMonitoringService::EXTRA_TIME])) ? floatval($cachedData[DeliveryMonitoringService::EXTRA_TIME]) : 0;
            $remaining = self::getRemainingTime($cachedData);
            $approximatedRemaining = self::getApproximatedRemainingTime($cachedData, $online, $lastActivity);

            $execution = array(
                'id' => $cachedData[DeliveryMonitoringService::DELIVERY_EXECUTION_ID],
                'delivery' => array(
                    'uri' => $cachedData[DeliveryMonitoringService::DELIVERY_ID],
                    'label' => _dh($cachedData[DeliveryMonitoringService::DELIVERY_NAME]),
                ),
                'start_time' => $cachedData[DeliveryMonitoringService::START_TIME],
                'allowExtraTime' => (isset($cachedData[DeliveryMonitoringService::ALLOW_EXTRA_TIME])) ? boolval($cachedData[DeliveryMonitoringService::ALLOW_EXTRA_TIME]) : null,
                'timer' => [
                    'lastActivity' => $lastActivity,
                    'countDown' => (DeliveryExecution::STATE_ACTIVE == $executionState && $online) ? true : false,
                    'approximatedRemaining' => $approximatedRemaining,
                    'remaining_time' => $remaining,
                    'extraTime' => $extraTime,
                    'extendedTime' => (isset($cachedData[DeliveryMonitoringService::EXTENDED_TIME]) && $cachedData[DeliveryMonitoringService::EXTENDED_TIME] > 1) ? floatval($cachedData[DeliveryMonitoringService::EXTENDED_TIME]) : '',
                    'consumedExtraTime' => (isset($cachedData[DeliveryMonitoringService::CONSUMED_EXTRA_TIME])) ? floatval($cachedData[DeliveryMonitoringService::CONSUMED_EXTRA_TIME]) : 0
                ],
                'testTaker' => $testTaker,
                'extraFields' => $extraFields,
                'state' => $state,
            );

            if ($online) {
                $execution['online'] = $online;
            }

            $executions[] = $execution;
        }

        return $executions;
    }