public static function createFromDataModel(VariableDeclaration $variableDeclaration)
    {
        $variable = parent::createFromDataModel($variableDeclaration);

        if ($variableDeclaration instanceof ResponseDeclaration) {

            $variable->setMapping($variableDeclaration->getMapping());
            $variable->setAreaMapping($variableDeclaration->getAreaMapping());

            $dataModelCorrectResponse = $variableDeclaration->getCorrectResponse();
            if (!empty($dataModelCorrectResponse)) {
                $baseType = $variable->getBaseType();
                $cardinality = $variable->getCardinality();
                $dataModelValues = $dataModelCorrectResponse->getValues();
                $correctResponse = static::dataModelValuesToRuntime($dataModelValues, $baseType, $cardinality);

                $variable->setCorrectResponse($correctResponse);
            }

            return $variable;
        } else {
            $msg = "ResponseVariable::createFromDataModel only accept 'qtism\\data\\state\\ResponseDeclaration' objects, '" . get_class($variableDeclaration) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
public static function createFromDataModel(VariableDeclaration $variableDeclaration)
    {
        $variable = parent::createFromDataModel($variableDeclaration);

        if ($variableDeclaration instanceof ResponseDeclaration) {

            $variable->setMapping($variableDeclaration->getMapping());
            $variable->setAreaMapping($variableDeclaration->getAreaMapping());

            $dataModelCorrectResponse = $variableDeclaration->getCorrectResponse();
            if (!empty($dataModelCorrectResponse)) {
                $baseType = $variable->getBaseType();
                $cardinality = $variable->getCardinality();
                $dataModelValues = $dataModelCorrectResponse->getValues();
                $correctResponse = static::dataModelValuesToRuntime($dataModelValues, $baseType, $cardinality);

                $variable->setCorrectResponse($correctResponse);
            }

            return $variable;
        } else {
            $msg = "ResponseVariable::createFromDataModel only accept 'qtism\\data\\state\\ResponseDeclaration' objects, '" . get_class($variableDeclaration) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
public static function createFromDataModel ( VariableDeclaration $ variableDeclaration ) { $ variable = parent :: createFromDataModel ( $ variableDeclaration ) ; if ( $ variableDeclaration instanceof ResponseDeclaration ) { $ variable -> setMapping ( $ variableDeclaration -> getMapping ( ) ) ; $ variable -> setAreaMapping ( $ variableDeclaration -> getAreaMapping ( ) ) ; $ dataModelCorrectResponse = $ variableDeclaration -> getCorrectResponse ( ) ; if ( ! empty ( $ dataModelCorrectResponse ) ) { $ baseType = $ variable -> getBaseType ( ) ; $ cardinality = $ variable -> getCardinality ( ) ; $ dataModelValues = $ dataModelCorrectResponse -> getValues ( ) ; $ correctResponse = static :: dataModelValuesToRuntime ( $ dataModelValues , $ baseType , $ cardinality ) ; $ variable -> setCorrectResponse ( $ correctResponse ) ; } return $ variable ; } else { $ msg = "ResponseVariable::createFromDataModel only accept 'qtism\\data\\state\\ResponseDeclaration' objects, '" . get_class ( $ variableDeclaration ) . "' given." ; throw new InvalidArgumentException ( $ msg ) ; } }
Create a ResponseVariable object from its data model representation.

@param \qtism\data\state\VariableDeclaration $variableDeclaration
@throws \InvalidArgumentException
@return \qtism\runtime\common\ResponseVariable
Create a ResponseVariable object from its data model representation .