/** * Verify that a given delivery execution is allowed to be executed * * @param DeliveryExecution $deliveryExecution * @param User $user * @throws \common_exception_Unauthorized */ public function verifyResumeAuthorization(DeliveryExecution $deliveryExecution, User $user) { $stateId = $deliveryExecution->getState()->getUri(); if (!in_array($stateId, $this->getResumableStates())) { \common_Logger::w('Unexpected state "' . $stateId); throw new \common_exception_Unauthorized(); } }
/** * (non-PHPdoc) * @see \oat\taoDelivery\model\authorization\AuthorizationProvider::verifyResumeAuthorization() */ public function verifyResumeAuthorization(DeliveryExecution $deliveryExecution, User $user) { $eligibilityService = $this->getEligibilityService(); $testCenter = $eligibilityService->getTestCenter($deliveryExecution->getDelivery(), $user); if (!empty($testCenter)) { $eligibility = $eligibilityService->getEligibility($testCenter, $deliveryExecution->getDelivery()); $state = $deliveryExecution->getState()->getUri(); if (in_array($state, [ProctoredDeliveryExecution::STATE_FINISHED, ProctoredDeliveryExecution::STATE_TERMINATED])) { throw new UnAuthorizedException(_url('index', 'DeliveryServer', 'taoProctoring'), 'Terminated/Finished delivery cannot be resumed'); } if (!$eligibilityService->canByPassProctor($eligibility)) { // proctoring is required if ($state !== ProctoredDeliveryExecution::STATE_AUTHORIZED) { $errorPage = _url('awaitingAuthorization', 'DeliveryServer', 'taoProctoring', array('deliveryExecution' => $deliveryExecution->getIdentifier())); throw new UnAuthorizedException($errorPage, 'Proctor authorization missing'); } } } }
protected function revoke(DeliveryExecution $deliveryExecution) { if ($deliveryExecution->getState()->getUri() != DeliveryExecutionState::STATE_PAUSED) { /** @var DeliveryExecutionStateService $deliveryExecutionStateService */ $deliveryExecutionStateService = $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID); $deliveryExecutionStateService->pauseExecution($deliveryExecution, ['reasons' => ['category' => 'focus-loss'], 'comment' => __('Assessment has been paused due to attempt to switch to another window/tab.')]); } }