Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 19.4.1 #394

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: simplify result variable generation by skipping string-to-typed …
…object conversion
  • Loading branch information
wazelin committed Feb 15, 2024
commit da0eca07f1af1f14da507b3be5f2a55bf8f2097c
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
Loading