-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2013-2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | ||
* Copyright (c) 2013-2024 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | ||
* | ||
* @author Jérôme Bogaerts <[email protected]> | ||
* @license GPLv2 | ||
|
@@ -563,10 +563,10 @@ public function getDataModelValues(): ValueCollection | |
break; | ||
|
||
case Cardinality::RECORD: | ||
foreach ($this->getValue() as $v) { | ||
foreach ($this->getValue() as $k => $v) { | ||
$values[] = $v === null | ||
? $this->createRecordNullValue() | ||
: $this->createRecordValue($v); | ||
? $this->createRecordNullValue($k) | ||
: $this->createRecordValue($v, $k); | ||
} | ||
break; | ||
} | ||
|
@@ -583,26 +583,23 @@ private function createValue(QtiDatatype $value): Value | |
return new Value($value instanceof QtiScalar ? $value->getValue() : $value); | ||
} | ||
|
||
/** | ||
* @param QtiDatatype $value | ||
* @return Value | ||
*/ | ||
private function createRecordValue(QtiDatatype $value): Value | ||
private function createRecordValue(QtiDatatype $qtiValue, string $fieldIdentifier): Value | ||
{ | ||
$value = $this->createValue($value); | ||
$value = $this->createValue($qtiValue); | ||
$value->setPartOfRecord(true); | ||
$value->setFieldIdentifier($fieldIdentifier); | ||
$value->setBaseType($qtiValue->getBaseType()); | ||
return $value; | ||
} | ||
|
||
/** | ||
* Creates a null value to fill a gap in a record set. | ||
* | ||
* @return Value | ||
*/ | ||
private function createRecordNullValue(): Value | ||
private function createRecordNullValue(string $fieldIdentifier): Value | ||
{ | ||
$value = new Value(null); | ||
$value->setPartOfRecord(true); | ||
$value->setFieldIdentifier($fieldIdentifier); | ||
return $value; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters