helpers/class.LegacyVariableFiller.php
public function fill($variableName, $clientSideValue) {
        $variable = null;
        
        $outcomeDeclarations = $this->getItemRef()->getOutcomeDeclarations();
        $responseDeclarations = $this->getItemRef()->getResponseDeclarations();
        
        if (isset($responseDeclarations[$variableName]) === true) {
            $variable = ResponseVariable::createFromDataModel($responseDeclarations[$variableName]);
        }
        else if (isset($outcomeDeclarations[$variableName]) === true) {
            $variable = OutcomeVariable::createFromDataModel($outcomeDeclarations[$variableName]);
        }
        
        if (empty($variable) === true) {
            $itemId = $this->getItemRef()->getIdentifier();
            $msg = "No variable declaration '${variableName}' found in '${itemId}'.";
            throw new OutOfBoundsException($msg);
        }
        
        common_Logger::d("Filling variable '" . $variable->getIdentifier() . "'.");
        
        if (is_array($clientSideValue) === false) {
            $clientSideValue = array($clientSideValue);
        }
        
        try {
            $finalValues = array();
            foreach ($clientSideValue as $val) {
                $finalValues[] = self::transform($variable->getBaseType(), $val);
            }
            
            if ($variable->getCardinality() === Cardinality::SINGLE) {
                $variable->setValue($finalValues[0]);
            }
            else if ($variable->getCardinality() === Cardinality::MULTIPLE) {
                $variable->setValue(new MultipleContainer($variable->getBaseType(), $finalValues));
            }
            else {
                // Cardinality is ORDERED.
                $variable->setValue(new OrderedContainer($variable->getBaseType(), $finalValues));
            }
            
            return $variable;
        }
        catch (InvalidArgumentException $e) {
            if (is_array($clientSideValue)) {
                $clientSideValue = implode(',', $clientSideValue);
            }
            
            $msg = "An error occured while filling variable '${variableName}' with client-side value '${clientSideValue}':" . $e->getMessage();
            throw new InvalidArgumentException($msg, 0, $e); 
        }
    }
public function fill($variableName, $clientSideValue) {
        $variable = null;
        
        $outcomeDeclarations = $this->getItemRef()->getOutcomeDeclarations();
        $responseDeclarations = $this->getItemRef()->getResponseDeclarations();
        
        if (isset($responseDeclarations[$variableName]) === true) {
            $variable = ResponseVariable::createFromDataModel($responseDeclarations[$variableName]);
        }
        else if (isset($outcomeDeclarations[$variableName]) === true) {
            $variable = OutcomeVariable::createFromDataModel($outcomeDeclarations[$variableName]);
        }
        
        if (empty($variable) === true) {
            $itemId = $this->getItemRef()->getIdentifier();
            $msg = "No variable declaration '${variableName}' found in '${itemId}'.";
            throw new OutOfBoundsException($msg);
        }
        
        common_Logger::d("Filling variable '" . $variable->getIdentifier() . "'.");
        
        if (is_array($clientSideValue) === false) {
            $clientSideValue = array($clientSideValue);
        }
        
        try {
            $finalValues = array();
            foreach ($clientSideValue as $val) {
                $finalValues[] = self::transform($variable->getBaseType(), $val);
            }
            
            if ($variable->getCardinality() === Cardinality::SINGLE) {
                $variable->setValue($finalValues[0]);
            }
            else if ($variable->getCardinality() === Cardinality::MULTIPLE) {
                $variable->setValue(new MultipleContainer($variable->getBaseType(), $finalValues));
            }
            else {
                // Cardinality is ORDERED.
                $variable->setValue(new OrderedContainer($variable->getBaseType(), $finalValues));
            }
            
            return $variable;
        }
        catch (InvalidArgumentException $e) {
            if (is_array($clientSideValue)) {
                $clientSideValue = implode(',', $clientSideValue);
            }
            
            $msg = "An error occured while filling variable '${variableName}' with client-side value '${clientSideValue}':" . $e->getMessage();
            throw new InvalidArgumentException($msg, 0, $e); 
        }
    }
Fille the variable $variableName with a correctly transformed
$clientSideValue.

@param string $variableName The variable identifier you want to fill.
@param string $clientSideValue The value received from the client-side.
@return Variable A Variable object filled with a correctly transformed $clientSideValue.
@throws OutOfBoundsException If no variable with $variableName is described in the item.
@throws OutOfRangeException If the $clientSideValue does not fit the target variable's baseType.