public function pause(DeliveryExecution $deliveryExecution, $reason = null)
    {
        $executionState = $deliveryExecution->getState()->getUri();
        $result = false;

        if (ProctoredDeliveryExecution::STATE_TERMINATED !== $executionState && ProctoredDeliveryExecution::STATE_FINISHED !== $executionState) {
            $session = $this->getTestSessionService()->getTestSession($deliveryExecution);
            $data = [
                'reason' => $reason,
                'timestamp' => microtime(true),
                'context' => $this->getContext($deliveryExecution),
            ];
            $this->setState($deliveryExecution, ProctoredDeliveryExecution::STATE_PAUSED);
            if ($session) {
                $data['itemId'] = $this->getCurrentItemId($deliveryExecution);
                if ($session->getState() !== AssessmentTestSessionState::SUSPENDED) {
                    $session->suspend();
                    $this->getTestSessionService()->persist($session);
                }
                $this->getServiceLocator()->get(ExtendedStateService::SERVICE_ID)->persist($session->getSessionId());
            }
            $this->getDeliveryLogService()->log($deliveryExecution->getIdentifier(), 'TEST_PAUSE', $data);
            $result = true;
        }

        return $result;
    }
public function pause(DeliveryExecution $deliveryExecution, $reason = null)
    {
        $executionState = $deliveryExecution->getState()->getUri();
        $result = false;

        if (ProctoredDeliveryExecution::STATE_TERMINATED !== $executionState && ProctoredDeliveryExecution::STATE_FINISHED !== $executionState) {
            $session = $this->getTestSessionService()->getTestSession($deliveryExecution);
            $data = [
                'reason' => $reason,
                'timestamp' => microtime(true),
                'context' => $this->getContext($deliveryExecution),
            ];
            $this->setState($deliveryExecution, ProctoredDeliveryExecution::STATE_PAUSED);
            if ($session) {
                $data['itemId'] = $this->getCurrentItemId($deliveryExecution);
                if ($session->getState() !== AssessmentTestSessionState::SUSPENDED) {
                    $session->suspend();
                    $this->getTestSessionService()->persist($session);
                }
                $this->getServiceLocator()->get(ExtendedStateService::SERVICE_ID)->persist($session->getSessionId());
            }
            $this->getDeliveryLogService()->log($deliveryExecution->getIdentifier(), 'TEST_PAUSE', $data);
            $result = true;
        }

        return $result;
    }
public function pause ( DeliveryExecution $ deliveryExecution , $ reason = null ) { $ executionState = $ deliveryExecution -> getState ( ) -> getUri ( ) ; $ result = false ; if ( ProctoredDeliveryExecution :: STATE_TERMINATED !== $ executionState && ProctoredDeliveryExecution :: STATE_FINISHED !== $ executionState ) { $ session = $ this -> getTestSessionService ( ) -> getTestSession ( $ deliveryExecution ) ; $ data = [ 'reason' => $ reason , 'timestamp' => microtime ( true ) , 'context' => $ this -> getContext ( $ deliveryExecution ) , ] ; $ this -> setState ( $ deliveryExecution , ProctoredDeliveryExecution :: STATE_PAUSED ) ; if ( $ session ) { $ data [ 'itemId' ] = $ this -> getCurrentItemId ( $ deliveryExecution ) ; if ( $ session -> getState ( ) !== AssessmentTestSessionState :: SUSPENDED ) { $ session -> suspend ( ) ; $ this -> getTestSessionService ( ) -> persist ( $ session ) ; } $ this -> getServiceLocator ( ) -> get ( ExtendedStateService :: SERVICE_ID ) -> persist ( $ session -> getSessionId ( ) ) ; } $ this -> getDeliveryLogService ( ) -> log ( $ deliveryExecution -> getIdentifier ( ) , 'TEST_PAUSE' , $ data ) ; $ result = true ; } return $ result ; }
Pauses a delivery execution

@param DeliveryExecution $deliveryExecution
@param array $reason
@return bool
@throws \common_exception_NotFound
@throws \common_exception_Error
@throws \common_exception_MissingParameter
@throws \oat\oatbox\service\exception\InvalidServiceManagerException
Pauses a delivery execution