Skip to content

Commit

Permalink
Merge pull request #393 from oat-sa/fix/PISA25-468/encrypted-response…
Browse files Browse the repository at this point in the history
…s-encoding

fix: simplify result variable generation by skipping string-to-typed object conversion
  • Loading branch information
wazelin authored Feb 15, 2024
2 parents 507bafa + da0eca0 commit b8e27a4
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 b8e27a4

Please sign in to comment.