Get the list of providers for the current execution
@param DeliveryExecution $execution
@return array the list of providers
355122
public function getProviders(DeliveryExecution $execution)
    {
        $serviceManager = $this->getServiceManager();
        $providerService = $serviceManager->get(TestProviderService::SERVICE_ID);
        $providers = $providerService->getAllProviders();
        return array_filter($providers, function ($provider) {
            return !is_null($provider) && $provider->isActive();
        });
    }
927871
protected function action($deliveryExecution, $executionId, $isEndDate = false)
    {
        $this->getDeliveryStateService()->terminateExecution($deliveryExecution, [
            'reasons' =>[
                'category' => 'Technical'
            ],
            'comment' => $isEndDate
                ? 'The assessment was automatically terminated because end time expired.'
                : 'The assessment was automatically terminated.'
        ]);
        $this->report->add(Report::createSuccess('Execution terminated with success:'. $executionId ));
    }
535454
public function getReportExecutionDetails($executionId)
    {
        $url = $this->makeUrl($executionId);
        $response = $this->service->prepAndSend($url, array(200), 'GET', null, true);

        return ReportExecution::createFromJSON(json_decode($response));
    }
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;
    }
539964
public function legacyTransition(DeliveryExecution $deliveryExecution, $state)
    {
        switch ($state) {
            case DeliveryExecution::STATE_FINISHED:
                $result = $this->finish($deliveryExecution);
                break;
            case DeliveryExecution::STATE_ACTIVE:
                $result = $this->run($deliveryExecution);
                break;
            case DeliveryExecution::STATE_PAUSED:
                $result = $this->pause($deliveryExecution);
                break;
            default:
                $this->logWarning('Unrecognised state '.$state);
                $result = $this->setState($deliveryExecution, $state);
        }
        return $result;
    }
90919
public function getDeliveryColumns()
    {
        $columns = [];

        // add custom properties, it contains the group property as well
        $customProps = $this->getClass($this->delivery->getOnePropertyValue($this->getProperty(OntologyRdf::RDF_TYPE)))->getProperties();

        $deliveryProps = array_merge($this->deliveryProperties, $customProps);

        foreach ($deliveryProps as $property){
            $property = $this->getProperty($property);
            $loginCol = new ContextTypePropertyColumn(ContextTypePropertyColumn::CONTEXT_TYPE_DELIVERY, $property);

            if ($property->getUri() == OntologyRdfs::RDFS_LABEL) {
                $loginCol->label = __('Delivery');
            }

            $columns[] = $loginCol->toArray();
        }

        return $columns;
    }
646448
public function updateDeliveryExecutionStatus(KVDeliveryExecution $deliveryExecution, $old, $new)
    {
        $this->update($deliveryExecution);
        $userId = $deliveryExecution->getUserIdentifier();
        if ($old != null) {
            $oldReferences = $this->getDeliveryExecutionsByStatus($userId, $old);
            foreach (array_keys($oldReferences) as $key) {
                if ($oldReferences[$key]->getIdentifier() == $deliveryExecution->getIdentifier()) {
                    unset($oldReferences[$key]);
                }
            }
            $this->setDeliveryExecutions($userId, $old, $oldReferences);
        }

        $newReferences = $this->getDeliveryExecutionsByStatus($userId, $new);
        $newReferences[$deliveryExecution->getIdentifier()] = $deliveryExecution;
        return $this->setDeliveryExecutions($userId, $new, $newReferences);
    }
538058
protected function isExpired(DeliveryExecution $deliveryExecution)
    {
        $result = false;
        $executionState = $deliveryExecution->getState()->getUri();

        if (in_array($executionState, [
                DeliveryExecutionState::STATE_PAUSED,
                DeliveryExecutionState::STATE_ACTIVE,
            ])
        ) {
            /** @var \oat\taoProctoring\model\implementation\DeliveryExecutionStateService $deliveryExecutionStateService */
            $deliveryExecutionStateService = $this->getServiceLocator()->get(DeliveryExecutionStateService::SERVICE_ID);

            if ($executionState === DeliveryExecutionState::STATE_ACTIVE) {
                $lastTestTakersEvent = $this->getLastTestTakersEvent($deliveryExecution);
                $lastEventTime = (new DateTimeImmutable())->setTimestamp($lastTestTakersEvent['created_at']);
            } else {
                $lastEventTime = $this->getLastPause($deliveryExecution);
            }

            if ($lastEventTime && $deliveryExecutionStateService->hasOption(DeliveryExecutionStateService::OPTION_TERMINATION_DELAY_AFTER_PAUSE)) {
                $delay = $deliveryExecutionStateService->getOption(DeliveryExecutionStateService::OPTION_TERMINATION_DELAY_AFTER_PAUSE);
                $result = ($lastEventTime->add(new DateInterval($delay)) < (new DateTimeImmutable('now')));
            }
        }

        return $result;
    }
632327
public function getDeliveryThemeIdFromDb($deliveryId)
    {
        try {
            $delivery = new core_kernel_classes_Resource($deliveryId);
            $property = $delivery->getProperty(static::DELIVERY_THEME_ID_URI);

            return (string)$delivery->getOnePropertyValue($property);
        } catch (common_exception_Error $e) {
            return '';
        }
    }
62189
public function getResultByDelivery($delivery, $options = array())
    {
        $returnValue = array();
        $sql = 'SELECT * FROM ' . self::RESULTS_TABLENAME;
        $params = array();


        if (count($delivery) > 0) {
            $sql .= ' WHERE ';
            $inQuery = implode(',', array_fill(0, count($delivery), '?'));
            $sql .= self::DELIVERY_COLUMN . ' IN (' . $inQuery . ')';
            $params = array_merge($params, $delivery);
        }


        if(isset($options['order']) && in_array($options['order'], [self::DELIVERY_COLUMN, self::TEST_TAKER_COLUMN, self::RESULTS_TABLE_ID])){
            $sql .= ' ORDER BY ' . $options['order'];
            if(isset($options['orderdir']) && (strtolower($options['orderdir']) === 'asc' || strtolower($options['orderdir']) === 'desc')) {
                $sql .= ' ' . $options['orderdir'];
            }
        }
        if(isset($options['offset']) || isset($options['limit'])){
            $offset = (isset($options['offset']))?$options['offset']:0;
            $limit = (isset($options['limit']))?$options['limit']:1000;
            $sql = $this->getPersistence()->getPlatForm()->limitStatement($sql, $limit, $offset);
        }
        $results = $this->getPersistence()->query($sql, $params);
        foreach ($results as $value) {
            $returnValue[] = array(
                "deliveryResultIdentifier" => $value[self::RESULTS_TABLE_ID],
                "testTakerIdentifier" => $value[self::TEST_TAKER_COLUMN],
                "deliveryIdentifier" => $value[self::DELIVERY_COLUMN]
            );
        }
        return $returnValue;

    }
260056
public static function getAllProviders()
    {
        if (is_null(self::$providers)) {
            self::$providers = array();
            $plugins   = PluginManager::getInstance()->getPluginsLoadedAndActivated();
            foreach ($plugins as $plugin) {
                foreach (self::getLocationProviders($plugin) as $instance) {
                    self::$providers[] = $instance;
                }
            }
        }

        return self::$providers;
    }
466834
protected function buildData(DeliveryExecutionInterface $deliveryExecution, $data)
    {
        $dataObject = $this->createMonitoringData($deliveryExecution, $data);

        return $dataObject;
    }
313659
public function getRDFaDeliverySetMethods()
    {
        $deliverySetList = oxNew(\OxidEsales\Eshop\Application\Model\DeliverySetList::class);
        $deliverySetList->loadRDFaDeliverySetList();

        return $deliverySetList;
    }
674702
public function doContinue($data)
    {
        // Set delivery details based billing details
        $delivery_data = array();
        $delivery_data['DeliveryCompany']     = $data['Company'];
        $delivery_data['DeliveryFirstnames'] = $data['FirstName'];
        $delivery_data['DeliverySurname']    = $data['Surname'];
        $delivery_data['DeliveryAddress1']   = $data['Address1'];
        $delivery_data['DeliveryAddress2']   = $data['Address2'];
        $delivery_data['DeliveryCity']       = $data['City'];
        $delivery_data['DeliveryPostCode']   = $data['PostCode'];
        $delivery_data['DeliveryCountry']    = $data['Country'];

        // Save both sets of data to sessions
        Session::set("Checkout.BillingDetailsForm.data", $data);
        Session::set("Checkout.DeliveryDetailsForm.data", $delivery_data);

        $this->save_address($data);

        $url = $this
            ->controller
            ->Link("finish");

        return $this
            ->controller
            ->redirect($url);
    }
942460
public function getProductsDeliveryList()
    {
        $article = $this->getProduct();
        $deliveryList = oxNew(\OxidEsales\Eshop\Application\Model\DeliveryList::class);
        $deliveryList->loadDeliveryListForProduct($article);

        return $deliveryList;
    }
306312
protected function getResultService(\core_kernel_classes_Resource $delivery)
    {
        /**
         * @var $ResultServiceWrapper ResultServiceWrapper
         */
        $ResultServiceWrapper = $this->getServiceManager()->get(ResultServiceWrapper::SERVICE_ID);

        $resultsService = $ResultServiceWrapper->getService();
        $implementation = $resultsService->getReadableImplementation($delivery);
        $resultsService->setImplementation($implementation);
        return $resultsService;
    }
928233
public function getDeliveryExecutionXml(DeliveryExecutionInterface $deliveryExecution)
    {
        return $this->getQtiResultXml($deliveryExecution->getDelivery()->getUri(), $deliveryExecution->getIdentifier());
    }