code: protected function storeVariable(
          QtiRunnerServiceContext $context,
          $itemUri,
          \taoResultServer_models_classes_Variable $metaVariable,
          $itemId = null
      ) {
          $sessionId = $context->getTestSession()->getSessionId();
  
          $testUri = $context->getTestDefinitionUri();
  
          /** @var DeliveryServerService $deliveryServerService */
          $deliveryServerService = $this->getServiceManager()->get(DeliveryServerService::SERVICE_ID);
          $resultStore = $deliveryServerService->getResultStoreWrapper($sessionId);
  
          if (!is_null($itemUri)) {
              $resultStore->storeItemVariable($testUri, $itemUri, $metaVariable, $this->getTransmissionId($context, $itemId));
          } else {
              $resultStore->storeTestVariable($testUri, $metaVariable, $sessionId);
          }
  
          return true;
      }
docs: Store a result variable to the result server
  
  @param QtiRunnerServiceContext $context
  @param string $itemUri This is the item identifier
  @param \taoResultServer_models_classes_Variable $metaVariable
  @param null $itemId The assessment item ref id (optional)
  @return bool
  @throws \common_exception_NotImplemented If the given $itemId is not the current assessment item ref