/**
  * Init a delivery execution from the current delivery
  * 
  * @return core_kernel_classes_Resource
  */
 protected function _initDeliveryExecution()
 {
     $compiledDelivery = new \core_kernel_classes_Resource(\tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $user = common_session_SessionManager::getSession()->getUser();
     $assignmentService = $this->getServiceManager()->get(AssignmentService::CONFIG_ID);
     if (!$assignmentService->isDeliveryExecutionAllowed($compiledDelivery->getUri(), $user)) {
         throw new \common_exception_Unauthorized();
     }
     return $this->executionService->initDeliveryExecution($compiledDelivery, $user->getIdentifier());
 }
 public function initDeliveryExecution()
 {
     $compiledDelivery = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $user = common_session_SessionManager::getSession()->getUser();
     if ($this->service->isDeliveryExecutionAllowed($compiledDelivery, $user)) {
         $deliveryExecution = $this->executionService->initDeliveryExecution($compiledDelivery, $user->getIdentifier());
     } else {
         common_Logger::i('Testtaker ' . $user->getIdentifier() . ' not authorised to initialise delivery ' . $compiledDelivery->getUri());
         return $this->returnError(__('You are no longer allowed to take the test %s', $compiledDelivery->getLabel()), true);
     }
     $this->redirect(_url('runDeliveryExecution', null, null, array('deliveryExecution' => $deliveryExecution->getIdentifier())));
 }
 /**
  * Init a delivery execution from the current delivery.
  *
  * @throws \common_exception_Unauthorized
  * @return DeliveryExecution the selected execution
  */
 protected function _initDeliveryExecution()
 {
     $compiledDelivery = new \core_kernel_classes_Resource(\tao_helpers_Uri::decode($this->getRequestParameter('uri')));
     $user = common_session_SessionManager::getSession()->getUser();
     $assignmentService = $this->getServiceManager()->get(AssignmentService::CONFIG_ID);
     $this->verifyDeliveryStartAuthorized($compiledDelivery->getUri());
     //check if the assignment allows the user to start the delivery and the authorization provider
     if (!$assignmentService->isDeliveryExecutionAllowed($compiledDelivery->getUri(), $user)) {
         throw new \common_exception_Unauthorized();
     }
     $deliveryExecution = $this->executionService->initDeliveryExecution($compiledDelivery, $user->getIdentifier());
     return $deliveryExecution;
 }