Skip to content

Commit

Permalink
Merge branch 'release-19.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
oat-github-bot committed Feb 15, 2024
2 parents 507bafa + b8e27a4 commit 95347ec
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/qtism/runtime/common/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@

use InvalidArgumentException;
use qtism\common\datatypes\QtiDatatype;
use qtism\common\datatypes\QtiFile;
use qtism\common\datatypes\QtiScalar;
use qtism\common\enums\BaseType;
use qtism\common\enums\Cardinality;
use qtism\data\state\Value;
use qtism\data\state\ValueCollection;
use qtism\data\state\VariableDeclaration;
use qtism\data\storage\Utils as StorageUtils;
use qtism\runtime\common\Utils as RuntimeUtils;
use UnexpectedValueException;

Expand Down Expand Up @@ -577,19 +576,11 @@ public function getDataModelValues(): ValueCollection

/**
* @param QtiDatatype $value
* @param int|null $baseType
* @return Value
*/
private function createValue(QtiDatatype $value, int $baseType = null): Value
private function createValue(QtiDatatype $value): Value
{
if (!$value instanceof QtiFile || !$this->isFile()) {
$value = StorageUtils::stringToDatatype(
(string)$value,
$baseType ?? $this->getBaseType()
);
}

return new Value($value);
return new Value($value instanceof QtiScalar ? $value->getValue() : $value);
}

/**
Expand All @@ -598,7 +589,7 @@ private function createValue(QtiDatatype $value, int $baseType = null): Value
*/
private function createRecordValue(QtiDatatype $value): Value
{
$value = $this->createValue($value, $value->getBaseType());
$value = $this->createValue($value);
$value->setPartOfRecord(true);
return $value;
}
Expand Down

0 comments on commit 95347ec

Please sign in to comment.