/**
  * Action to finish test attempts where the maximum time limit has been reached.
  * To end user will be sent array that contains id's of finished session.
  */
 public function endExpiredTests()
 {
     $started = \taoDelivery_models_classes_DeliveryServerService::singleton()->getResumableDeliveries();
     $resultServer = \taoResultServer_models_classes_ResultServerStateFull::singleton();
     $result = array();
     foreach ($started as $deliveryExecution) {
         $compiledDelivery = $deliveryExecution->getDelivery();
         $runtime = \taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRuntime($compiledDelivery);
         $inputParameters = \tao_models_classes_service_ServiceCallHelper::getInputValues($runtime, array());
         $testDefinition = \taoQtiTest_helpers_Utils::getTestDefinition($inputParameters['QtiTestCompilation']);
         $testResource = new \core_kernel_classes_Resource($inputParameters['QtiTestDefinition']);
         $subjectProp = new \core_kernel_classes_Property(PROPERTY_DELVIERYEXECUTION_SUBJECT);
         $delvieryExecutionSubject = $deliveryExecution->getOnePropertyValue($subjectProp);
         $sessionManager = new \taoQtiTest_helpers_SessionManager($resultServer, $testResource);
         $qtiStorage = new \taoQtiTest_helpers_TestSessionStorage($sessionManager, new BinaryAssessmentTestSeeker($testDefinition), $delvieryExecutionSubject->getUri());
         $session = $qtiStorage->retrieve($testDefinition, $deliveryExecution->getUri());
         $resultServerUri = $compiledDelivery->getOnePropertyValue(new \core_kernel_classes_Property(TAO_DELIVERY_RESULTSERVER_PROP));
         $resultServerObject = new \taoResultServer_models_classes_ResultServer($resultServerUri, array());
         $resultServer->setValue('resultServerUri', $resultServerUri->getUri());
         $resultServer->setValue('resultServerObject', array($resultServerUri->getUri() => $resultServerObject));
         $resultServer->setValue('resultServer_deliveryResultIdentifier', $deliveryExecution->getUri());
         if ($session->isRunning() === false) {
             continue;
         }
         try {
             $session->checkTimeLimits(false, false, false);
         } catch (AssessmentTestSessionException $e) {
             if (AssessmentTestSessionException::ASSESSMENT_TEST_DURATION_OVERFLOW) {
                 $testSessionMetaData = new TestSessionMetaData($session);
                 $testSessionMetaData->save(array('TEST' => array('TEST_EXIT_CODE' => TestSessionMetaData::TEST_CODE_INCOMPLETE), 'SECTION' => array('SECTION_EXIT_CODE' => TestSessionMetaData::SECTION_CODE_TIMEOUT)));
                 $session->endTestSession();
                 $deliveryExecution->setState(INSTANCE_DELIVERYEXEC_FINISHED);
                 \common_Logger::i("Expired test session {$session->getSessionId()} has finished.");
                 $result[] = $session->getSessionId();
             }
         }
     }
     echo json_encode($result);
 }
 /**
  * (non-PHPdoc)
  * @see \oat\taoFrontOffice\model\Delivery::isTakeable()
  */
 public function isTakeable(User $testTaker)
 {
     return taoDelivery_models_classes_DeliveryServerService::singleton()->isDeliveryExecutionAllowed($this, $testTaker);
 }
 /**
  * constructor: initialize the service and the default data
  * @return DeliveryServer
  */
 public function __construct()
 {
     $this->service = taoDelivery_models_classes_DeliveryServerService::singleton();
     $this->executionService = taoDelivery_models_classes_execution_ServiceProxy::singleton();
 }
 /**
  * constructor: initialize the service and the default data
  * @return DeliveryServer
  */
 public function __construct()
 {
     $this->service = taoDelivery_models_classes_DeliveryServerService::singleton();
     $this->executionService = taoDelivery_models_classes_execution_ServiceProxy::singleton();
     $this->deliveryServerConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery')->getConfig('deliveryServer');
 }