/**
  * Build the Service Call ID of the current Assessment Item to be presented to a candidate
  * in a given Assessment Test $session.
  *
  * @return string A service call id composed of the session identifier,  the identifier of the item and its occurence number in the route.
  */
 public static function buildServiceCallId(AssessmentTestSession $session)
 {
     $sessionId = $session->getSessionId();
     $itemId = $session->getCurrentAssessmentItemRef()->getIdentifier();
     $occurence = $session->getCurrentAssessmentItemRefOccurence();
     return "{$sessionId}.{$itemId}.{$occurence}";
 }
 /**
  * Save session metadata.
  * 
  * @param array $metaData Meta data array to be saved.
  * @param RouteItem $routeItem item for which data will be saved
  * @param string $assessmentSectionId section id for which data will be saved
  * Example:
  * array(
  *   'TEST' => array('TEST_EXIT_CODE' => 'IC'),
  *   'SECTION' => array('SECTION_EXIT_CODE' => 701),
  * )
  */
 public function save(array $metaData, RouteItem $routeItem = null, $assessmentSectionId = null)
 {
     $testUri = $this->session->getTest()->getUri();
     $resultServer = \taoResultServer_models_classes_ResultServerStateFull::singleton();
     foreach ($metaData as $type => $data) {
         foreach ($data as $key => $value) {
             $metaVariable = $this->getVariable($key, $value);
             if (strcasecmp($type, 'ITEM') === 0) {
                 if ($routeItem === null) {
                     $itemRef = $this->session->getCurrentAssessmentItemRef();
                     $occurence = $this->session->getCurrentAssessmentItemRefOccurence();
                 } else {
                     $itemRef = $routeItem->getAssessmentItemRef();
                     $occurence = $routeItem->getOccurence();
                 }
                 $itemUri = $this->getItemUri($itemRef);
                 $sessionId = $this->session->getSessionId();
                 $transmissionId = "{$sessionId}.{$itemRef}.{$occurence}";
                 $resultServer->storeItemVariable($testUri, $itemUri, $metaVariable, $transmissionId);
             } elseif (strcasecmp($type, 'TEST') === 0) {
                 $resultServer->storeTestVariable($testUri, $metaVariable, $this->session->getSessionId());
             } elseif (strcasecmp($type, 'SECTION') === 0) {
                 //suffix section variables with _{SECTION_IDENTIFIER}
                 if ($assessmentSectionId === null) {
                     $assessmentSectionId = $this->session->getCurrentAssessmentSection()->getIdentifier();
                 }
                 $metaVariable->setIdentifier($key . '_' . $assessmentSectionId);
                 $resultServer->storeTestVariable($testUri, $metaVariable, $this->session->getSessionId());
             }
         }
     }
 }