/**
  * Save session metadata.
  * 
  * @param array $metaData Meta data array to be saved.
  * Example:
  * array(
  *   'TEST' => array('TEST_EXIT_CODE' => 'IC'),
  *   'SECTION' => array('SECTION_EXIT_CODE' => 701),
  * )
  */
 public function save(array $metaData)
 {
     $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) {
                 $itemUri = \taoQtiTest_helpers_TestRunnerUtils::getCurrentItemUri($this);
                 $occurence = $this->session->getCurrentAssessmentItemRefOccurence();
                 $transmissionId = "{$sessionId}.{$item}.{$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}
                 $assessmentSectionId = $this->session->getCurrentAssessmentSection()->getIdentifier();
                 $metaVariable->setIdentifier($key . '_' . $assessmentSectionId);
                 $resultServer->storeTestVariable($testUri, $metaVariable, $this->session->getSessionId());
             }
         }
     }
 }
 /**
  * Action to call to comment an item.
  * 
  */
 public function comment()
 {
     if ($this->beforeAction()) {
         $testSession = $this->getTestSession();
         $resultServer = taoResultServer_models_classes_ResultServerStateFull::singleton();
         $transmitter = new taoQtiCommon_helpers_ResultTransmitter($resultServer);
         // prepare transmission Id for result server.
         $item = $testSession->getCurrentAssessmentItemRef()->getIdentifier();
         $occurence = $testSession->getCurrentAssessmentItemRefOccurence();
         $sessionId = $testSession->getSessionId();
         $transmissionId = "{$sessionId}.{$item}.{$occurence}";
         // retrieve comment's intrinsic value.
         $comment = $this->getRequestParameter('comment');
         // build variable and send it.
         $itemUri = taoQtiTest_helpers_TestRunnerUtils::getCurrentItemUri($testSession);
         $testUri = $testSession->getTest()->getUri();
         $variable = new ResponseVariable('comment', Cardinality::SINGLE, BaseType::STRING, new QtismString($comment));
         $transmitter->transmitItemVariable($variable, $transmissionId, $itemUri, $testUri);
     }
 }