code: protected function storeResult(array $results)
      {
          /** @var QtiRunnerService $runnerService */
          $runnerService = $this->getServiceLocator()->get(QtiRunnerService::SERVICE_ID);
  
          $success = true;
          try {
              foreach ($results as $result) {
  
                  if (!$result instanceof AbstractResult) {
                      throw new \common_Exception(__FUNCTION__ . ' requires a CAT result to store it.');
                  }
  
                  $variables = $this->convertCatVariables($result->getVariables());
                  if (empty($variables)) {
                      \common_Logger::t('No Cat result variables to store.');
                      continue;
                  }
  
                  if ($result instanceof ItemResult) {
                      $itemId = $result->getItemRefId();
                      $itemUri = $this->getItemUriFromRefId($itemId);
                  } else {
                      $itemUri = $itemId = null;
                      $sectionId = $this
                          ->getTestSession()
                          ->getRoute()
                          ->current()
                          ->getAssessmentSection()
                          ->getIdentifier();
                      /** @var \taoResultServer_models_classes_Variable $variable */
                      foreach ($variables as $variable) {
                          $variable->setIdentifier($sectionId . '-' . $variable->getIdentifier());
                      }
                  }
  
                  if (!$runnerService->storeVariables($this, $itemUri, $variables, $itemId)) {
                      $success = false;
                  }
              }
          } catch (\Exception $e) {
              \common_Logger::w('An error has occurred during CAT result storing: ' . $e->getMessage());
              $success = false;
          }
  
          return $success;
      }
docs: Store a Cat Result variable
  
  The result has to be an ItemResult and TestResult to embed CAT variables
  After converted them to taoResultServer variables
  Use the runner service to store the variables
  
  @param AbstractResult[] $results
  @return bool