validate(); try { /** @var QtiRunnerServiceContext $serviceContext */ $serviceContext = $this->getServiceContext(); $this->saveToolStates(); if (!$this->getRunnerService()->isTerminated($serviceContext)) { $this->endItemTimer($this->getTime()); $this->saveItemState(); } $this->initServiceContext(); $this->saveItemResponses(); $response = [ 'success' => $this->getRunnerService()->exitTest($serviceContext), ]; } catch (Exception $e) { common_Logger::e($e->getMessage()); $response = $this->getErrorResponse($e); } return $response; } }