repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.initialize | public function initialize()
{
if ($this->cardinality === Cardinality::MULTIPLE) {
$value = new MultipleContainer($this->baseType);
} elseif ($this->cardinality === Cardinality::ORDERED) {
$value = new OrderedContainer($this->baseType);
} elseif ($this->cardinality === Cardinality::RECORD) {
$value = new RecordContainer();
} else {
$value = null;
}
$this->value = $value;
} | php | public function initialize()
{
if ($this->cardinality === Cardinality::MULTIPLE) {
$value = new MultipleContainer($this->baseType);
} elseif ($this->cardinality === Cardinality::ORDERED) {
$value = new OrderedContainer($this->baseType);
} elseif ($this->cardinality === Cardinality::RECORD) {
$value = new RecordContainer();
} else {
$value = null;
}
$this->value = $value;
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cardinality",
"===",
"Cardinality",
"::",
"MULTIPLE",
")",
"{",
"$",
"value",
"=",
"new",
"MultipleContainer",
"(",
"$",
"this",
"->",
"baseType",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"cardinality",
"===",
"Cardinality",
"::",
"ORDERED",
")",
"{",
"$",
"value",
"=",
"new",
"OrderedContainer",
"(",
"$",
"this",
"->",
"baseType",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"cardinality",
"===",
"Cardinality",
"::",
"RECORD",
")",
"{",
"$",
"value",
"=",
"new",
"RecordContainer",
"(",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"}"
] | Initialize the variable with the appropriate default value.
* If the variable is supposed to contain a Container (Multiple, Ordered or Record cardinality), the variable's value becomes an empty container.
* If the variable is scalar (Cardinality single), the value becomes NULL. | [
"Initialize",
"the",
"variable",
"with",
"the",
"appropriate",
"default",
"value",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L112-L125 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.setBaseType | public function setBaseType($baseType)
{
if ($baseType === -1 && $this->isRecord() === false) {
$msg = "You are forced to specify a baseType if cardinality is not RECORD.";
throw new InvalidArgumentException($msg);
}
$this->baseType = $baseType;
} | php | public function setBaseType($baseType)
{
if ($baseType === -1 && $this->isRecord() === false) {
$msg = "You are forced to specify a baseType if cardinality is not RECORD.";
throw new InvalidArgumentException($msg);
}
$this->baseType = $baseType;
} | [
"public",
"function",
"setBaseType",
"(",
"$",
"baseType",
")",
"{",
"if",
"(",
"$",
"baseType",
"===",
"-",
"1",
"&&",
"$",
"this",
"->",
"isRecord",
"(",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"You are forced to specify a baseType if cardinality is not RECORD.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"this",
"->",
"baseType",
"=",
"$",
"baseType",
";",
"}"
] | Set the baseType of the Variable.
@param integer $baseType A value from the Cardinality enumeration or -1 if there is no baseType in a Cardinality::RECORD context.
@throws \InvalidArgumentException If -1 is passed but Cardinality::RECORD is not set. | [
"Set",
"the",
"baseType",
"of",
"the",
"Variable",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L183-L191 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.setValue | public function setValue(QtiDatatype $value = null)
{
if (Utils::isBaseTypeCompliant($this->getBaseType(), $value) && Utils::isCardinalityCompliant($this->getCardinality(), $value)) {
$this->value = $value;
} else {
Utils::throwBaseTypeTypingError($this->baseType, $value);
}
} | php | public function setValue(QtiDatatype $value = null)
{
if (Utils::isBaseTypeCompliant($this->getBaseType(), $value) && Utils::isCardinalityCompliant($this->getCardinality(), $value)) {
$this->value = $value;
} else {
Utils::throwBaseTypeTypingError($this->baseType, $value);
}
} | [
"public",
"function",
"setValue",
"(",
"QtiDatatype",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"Utils",
"::",
"isBaseTypeCompliant",
"(",
"$",
"this",
"->",
"getBaseType",
"(",
")",
",",
"$",
"value",
")",
"&&",
"Utils",
"::",
"isCardinalityCompliant",
"(",
"$",
"this",
"->",
"getCardinality",
"(",
")",
",",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"Utils",
"::",
"throwBaseTypeTypingError",
"(",
"$",
"this",
"->",
"baseType",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Set the value of the Variable.
@param \qtism\common\datatypes\QtiDatatype|null $value A QtiDatatype object or null.
@throws \InvalidArgumentException If the baseType and cardinality of $value are not compliant with the Variable. | [
"Set",
"the",
"value",
"of",
"the",
"Variable",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L209-L216 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.setDefaultValue | public function setDefaultValue(QtiDatatype $defaultValue = null)
{
if (Utils::isBaseTypeCompliant($this->getBaseType(), $defaultValue) && Utils::isCardinalityCompliant($this->getCardinality(), $defaultValue)) {
$this->defaultValue = $defaultValue;
return;
} else {
Utils::throwBaseTypeTypingError($this->getBaseType(), $defaultValue);
}
} | php | public function setDefaultValue(QtiDatatype $defaultValue = null)
{
if (Utils::isBaseTypeCompliant($this->getBaseType(), $defaultValue) && Utils::isCardinalityCompliant($this->getCardinality(), $defaultValue)) {
$this->defaultValue = $defaultValue;
return;
} else {
Utils::throwBaseTypeTypingError($this->getBaseType(), $defaultValue);
}
} | [
"public",
"function",
"setDefaultValue",
"(",
"QtiDatatype",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"if",
"(",
"Utils",
"::",
"isBaseTypeCompliant",
"(",
"$",
"this",
"->",
"getBaseType",
"(",
")",
",",
"$",
"defaultValue",
")",
"&&",
"Utils",
"::",
"isCardinalityCompliant",
"(",
"$",
"this",
"->",
"getCardinality",
"(",
")",
",",
"$",
"defaultValue",
")",
")",
"{",
"$",
"this",
"->",
"defaultValue",
"=",
"$",
"defaultValue",
";",
"return",
";",
"}",
"else",
"{",
"Utils",
"::",
"throwBaseTypeTypingError",
"(",
"$",
"this",
"->",
"getBaseType",
"(",
")",
",",
"$",
"defaultValue",
")",
";",
"}",
"}"
] | Set the default value of the Variable.
@param \qtism\common\datatypes\QtiDatatype|null $defaultValue A QtiDatatype object or null.
@throws \InvalidArgumentException If $defaultValue's type is not compliant with the qti:baseType of the Variable. | [
"Set",
"the",
"default",
"value",
"of",
"the",
"Variable",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L234-L243 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.createFromDataModel | public static function createFromDataModel(VariableDeclaration $variableDeclaration)
{
$identifier = $variableDeclaration->getIdentifier();
$baseType = $variableDeclaration->getBaseType();
$cardinality = $variableDeclaration->getCardinality();
$variable = new static($identifier, $cardinality, $baseType);
// Default value?
$dataModelDefaultValue = $variableDeclaration->getDefaultValue();
if (!empty($dataModelDefaultValue)) {
$dataModelValues = $dataModelDefaultValue->getValues();
$defaultValue = static::dataModelValuesToRuntime($dataModelValues, $baseType, $cardinality);
$variable->setDefaultValue($defaultValue);
}
return $variable;
} | php | public static function createFromDataModel(VariableDeclaration $variableDeclaration)
{
$identifier = $variableDeclaration->getIdentifier();
$baseType = $variableDeclaration->getBaseType();
$cardinality = $variableDeclaration->getCardinality();
$variable = new static($identifier, $cardinality, $baseType);
// Default value?
$dataModelDefaultValue = $variableDeclaration->getDefaultValue();
if (!empty($dataModelDefaultValue)) {
$dataModelValues = $dataModelDefaultValue->getValues();
$defaultValue = static::dataModelValuesToRuntime($dataModelValues, $baseType, $cardinality);
$variable->setDefaultValue($defaultValue);
}
return $variable;
} | [
"public",
"static",
"function",
"createFromDataModel",
"(",
"VariableDeclaration",
"$",
"variableDeclaration",
")",
"{",
"$",
"identifier",
"=",
"$",
"variableDeclaration",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"baseType",
"=",
"$",
"variableDeclaration",
"->",
"getBaseType",
"(",
")",
";",
"$",
"cardinality",
"=",
"$",
"variableDeclaration",
"->",
"getCardinality",
"(",
")",
";",
"$",
"variable",
"=",
"new",
"static",
"(",
"$",
"identifier",
",",
"$",
"cardinality",
",",
"$",
"baseType",
")",
";",
"// Default value?",
"$",
"dataModelDefaultValue",
"=",
"$",
"variableDeclaration",
"->",
"getDefaultValue",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dataModelDefaultValue",
")",
")",
"{",
"$",
"dataModelValues",
"=",
"$",
"dataModelDefaultValue",
"->",
"getValues",
"(",
")",
";",
"$",
"defaultValue",
"=",
"static",
"::",
"dataModelValuesToRuntime",
"(",
"$",
"dataModelValues",
",",
"$",
"baseType",
",",
"$",
"cardinality",
")",
";",
"$",
"variable",
"->",
"setDefaultValue",
"(",
"$",
"defaultValue",
")",
";",
"}",
"return",
"$",
"variable",
";",
"}"
] | Create a runtime Variable object from its Data Model representation.
@param \qtism\data\state\VariableDeclaration $variableDeclaration A VariableDeclaration object from the QTI Data Model.
@return \qtism\runtime\common\Variable A Variable object.
@throws \UnexpectedValueException If $variableDeclaration is not consistent. | [
"Create",
"a",
"runtime",
"Variable",
"object",
"from",
"its",
"Data",
"Model",
"representation",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L252-L270 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.dataModelValuesToRuntime | protected static function dataModelValuesToRuntime(ValueCollection $valueCollection, $baseType, $cardinality)
{
// Cardinality?
// -> Single? Multiple? Ordered? Record?
if ($cardinality === Cardinality::SINGLE) {
// We should find a single value in the DefaultValue's values.
if (count($valueCollection) == 1) {
$dataModelValue = RuntimeUtils::valueToRuntime($valueCollection[0]->getValue(), $baseType);
return $dataModelValue;
} else {
// The Data Model is in an inconsistent state.
// This should be handled by the Data Model but
// I prefer to be defensive.
$msg = "A Data Model VariableDeclaration with 'single' cardinality must contain a single value, ";
$msg .= count($valueCollection) . " value(s) found.";
throw new UnexpectedValueException($msg);
}
} else {
// Multiple|Ordered|Record, use a container.
$container = null;
try {
// Create the appropriate Container object.
$className = ucfirst(Cardinality::getNameByConstant($cardinality)) . 'Container';
$nsClassName = 'qtism\\runtime\\common\\' . $className;
$callback = array($nsClassName , 'createFromDataModel');
$container = call_user_func_array($callback, array($valueCollection, $baseType));
return $container; // return container.
} catch (InvalidArgumentException $e) {
$msg = "The default value found in the Data Model Variable Declaration is not consistent. ";
$msg.= "The values must have a baseType compliant with the baseType of the VariableDeclaration.";
$msg.= "If the VariableDeclaration's cardinality is 'record', make sure the values it contains have ";
$msg.= "fieldIdentifiers.";
throw new UnexpectedValueException($msg, 0, $e);
}
}
} | php | protected static function dataModelValuesToRuntime(ValueCollection $valueCollection, $baseType, $cardinality)
{
// Cardinality?
// -> Single? Multiple? Ordered? Record?
if ($cardinality === Cardinality::SINGLE) {
// We should find a single value in the DefaultValue's values.
if (count($valueCollection) == 1) {
$dataModelValue = RuntimeUtils::valueToRuntime($valueCollection[0]->getValue(), $baseType);
return $dataModelValue;
} else {
// The Data Model is in an inconsistent state.
// This should be handled by the Data Model but
// I prefer to be defensive.
$msg = "A Data Model VariableDeclaration with 'single' cardinality must contain a single value, ";
$msg .= count($valueCollection) . " value(s) found.";
throw new UnexpectedValueException($msg);
}
} else {
// Multiple|Ordered|Record, use a container.
$container = null;
try {
// Create the appropriate Container object.
$className = ucfirst(Cardinality::getNameByConstant($cardinality)) . 'Container';
$nsClassName = 'qtism\\runtime\\common\\' . $className;
$callback = array($nsClassName , 'createFromDataModel');
$container = call_user_func_array($callback, array($valueCollection, $baseType));
return $container; // return container.
} catch (InvalidArgumentException $e) {
$msg = "The default value found in the Data Model Variable Declaration is not consistent. ";
$msg.= "The values must have a baseType compliant with the baseType of the VariableDeclaration.";
$msg.= "If the VariableDeclaration's cardinality is 'record', make sure the values it contains have ";
$msg.= "fieldIdentifiers.";
throw new UnexpectedValueException($msg, 0, $e);
}
}
} | [
"protected",
"static",
"function",
"dataModelValuesToRuntime",
"(",
"ValueCollection",
"$",
"valueCollection",
",",
"$",
"baseType",
",",
"$",
"cardinality",
")",
"{",
"// Cardinality?",
"// -> Single? Multiple? Ordered? Record?",
"if",
"(",
"$",
"cardinality",
"===",
"Cardinality",
"::",
"SINGLE",
")",
"{",
"// We should find a single value in the DefaultValue's values.",
"if",
"(",
"count",
"(",
"$",
"valueCollection",
")",
"==",
"1",
")",
"{",
"$",
"dataModelValue",
"=",
"RuntimeUtils",
"::",
"valueToRuntime",
"(",
"$",
"valueCollection",
"[",
"0",
"]",
"->",
"getValue",
"(",
")",
",",
"$",
"baseType",
")",
";",
"return",
"$",
"dataModelValue",
";",
"}",
"else",
"{",
"// The Data Model is in an inconsistent state.",
"// This should be handled by the Data Model but",
"// I prefer to be defensive.",
"$",
"msg",
"=",
"\"A Data Model VariableDeclaration with 'single' cardinality must contain a single value, \"",
";",
"$",
"msg",
".=",
"count",
"(",
"$",
"valueCollection",
")",
".",
"\" value(s) found.\"",
";",
"throw",
"new",
"UnexpectedValueException",
"(",
"$",
"msg",
")",
";",
"}",
"}",
"else",
"{",
"// Multiple|Ordered|Record, use a container.",
"$",
"container",
"=",
"null",
";",
"try",
"{",
"// Create the appropriate Container object.",
"$",
"className",
"=",
"ucfirst",
"(",
"Cardinality",
"::",
"getNameByConstant",
"(",
"$",
"cardinality",
")",
")",
".",
"'Container'",
";",
"$",
"nsClassName",
"=",
"'qtism\\\\runtime\\\\common\\\\'",
".",
"$",
"className",
";",
"$",
"callback",
"=",
"array",
"(",
"$",
"nsClassName",
",",
"'createFromDataModel'",
")",
";",
"$",
"container",
"=",
"call_user_func_array",
"(",
"$",
"callback",
",",
"array",
"(",
"$",
"valueCollection",
",",
"$",
"baseType",
")",
")",
";",
"return",
"$",
"container",
";",
"// return container.",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"The default value found in the Data Model Variable Declaration is not consistent. \"",
";",
"$",
"msg",
".=",
"\"The values must have a baseType compliant with the baseType of the VariableDeclaration.\"",
";",
"$",
"msg",
".=",
"\"If the VariableDeclaration's cardinality is 'record', make sure the values it contains have \"",
";",
"$",
"msg",
".=",
"\"fieldIdentifiers.\"",
";",
"throw",
"new",
"UnexpectedValueException",
"(",
"$",
"msg",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}",
"}"
] | Create a QTI Runtime value from Data Model ValueCollection
@param \qtism\data\state\ValueCollection $valueCollection A collection of qtism\data\state\Value objects.
@param integer $baseType The baseType the Value objects in the ValueCollection must respect.
@param integer $cardinality The cardinality the Value objects in the ValueCollection must respect.
@throws \UnexpectedValueException If $baseType or/and $cardinality are not respected by the Value objects in the ValueCollection.
@return mixed The resulting QTI Runtime value (primitive or container depending on baseType/cardinality). | [
"Create",
"a",
"QTI",
"Runtime",
"value",
"from",
"Data",
"Model",
"ValueCollection"
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L281-L320 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.isNumeric | public function isNumeric()
{
return ($this->IsNull()) ? false : ($this->baseType === BaseType::INTEGER || $this->baseType === BaseType::FLOAT);
} | php | public function isNumeric()
{
return ($this->IsNull()) ? false : ($this->baseType === BaseType::INTEGER || $this->baseType === BaseType::FLOAT);
} | [
"public",
"function",
"isNumeric",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"IsNull",
"(",
")",
")",
"?",
"false",
":",
"(",
"$",
"this",
"->",
"baseType",
"===",
"BaseType",
"::",
"INTEGER",
"||",
"$",
"this",
"->",
"baseType",
"===",
"BaseType",
"::",
"FLOAT",
")",
";",
"}"
] | Convenience method.
Whether the variable's value is numeric. If the variable value
contains NULL, this method return false.
@return boolean | [
"Convenience",
"method",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L378-L381 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.isNull | public function isNull()
{
$value = $this->getValue();
// Containers as per QTI Spec, are considered to be NULL if empty.
if ($value instanceof Container && $value->isNull() === true) {
return true;
} elseif (!$value instanceof Container && !is_null($value) && $this->getBaseType() === BaseType::STRING) {
return $value->getValue() === '';
} else {
return is_null($value);
}
} | php | public function isNull()
{
$value = $this->getValue();
// Containers as per QTI Spec, are considered to be NULL if empty.
if ($value instanceof Container && $value->isNull() === true) {
return true;
} elseif (!$value instanceof Container && !is_null($value) && $this->getBaseType() === BaseType::STRING) {
return $value->getValue() === '';
} else {
return is_null($value);
}
} | [
"public",
"function",
"isNull",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"// Containers as per QTI Spec, are considered to be NULL if empty.",
"if",
"(",
"$",
"value",
"instanceof",
"Container",
"&&",
"$",
"value",
"->",
"isNull",
"(",
")",
"===",
"true",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"!",
"$",
"value",
"instanceof",
"Container",
"&&",
"!",
"is_null",
"(",
"$",
"value",
")",
"&&",
"$",
"this",
"->",
"getBaseType",
"(",
")",
"===",
"BaseType",
"::",
"STRING",
")",
"{",
"return",
"$",
"value",
"->",
"getValue",
"(",
")",
"===",
"''",
";",
"}",
"else",
"{",
"return",
"is_null",
"(",
"$",
"value",
")",
";",
"}",
"}"
] | Convenience method.
Whether the variable's value has the NULL value.
Be carefull, the following values as per QTI specification will be considered NULL:
* An empty MultipleContainer, OrderedContainer or RecordContainer.
* An empty string.
@return boolean | [
"Convenience",
"method",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L395-L406 |
oat-sa/qti-sdk | src/qtism/runtime/common/Variable.php | Variable.isPair | public function isPair()
{
return (!$this->isNull() && ($this->getBaseType() === BaseType::PAIR) || $this->getBaseType() === BaseType::DIRECTED_PAIR);
} | php | public function isPair()
{
return (!$this->isNull() && ($this->getBaseType() === BaseType::PAIR) || $this->getBaseType() === BaseType::DIRECTED_PAIR);
} | [
"public",
"function",
"isPair",
"(",
")",
"{",
"return",
"(",
"!",
"$",
"this",
"->",
"isNull",
"(",
")",
"&&",
"(",
"$",
"this",
"->",
"getBaseType",
"(",
")",
"===",
"BaseType",
"::",
"PAIR",
")",
"||",
"$",
"this",
"->",
"getBaseType",
"(",
")",
"===",
"BaseType",
"::",
"DIRECTED_PAIR",
")",
";",
"}"
] | Convenience method.
Whether the variable's value is a pair. If the variable's value is NULL, the method
returns false.
Be carefull! This method considers that a directedPair is also a pair.
@return boolean | [
"Convenience",
"method",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/Variable.php#L470-L473 |
oat-sa/qti-sdk | src/qtism/data/ExtendedAssessmentSection.php | ExtendedAssessmentSection.createFromAssessmentSection | public static function createFromAssessmentSection(AssessmentSection $assessmentSection)
{
$extended = new static($assessmentSection->getIdentifier(), $assessmentSection->getTitle(), $assessmentSection->isVisible());
$extended->setKeepTogether($assessmentSection->mustKeepTogether());
$extended->setSelection($assessmentSection->getSelection());
$extended->setOrdering($assessmentSection->getOrdering());
$extended->setRubricBlocks($assessmentSection->getRubricBlocks());
$extended->setSectionParts($assessmentSection->getSectionParts());
$extended->setRequired($assessmentSection->isRequired());
$extended->setPreConditions($assessmentSection->getPreConditions());
$extended->setBranchRules($assessmentSection->getBranchRules());
$extended->setItemSessionControl($assessmentSection->getItemSessionControl());
$extended->setTimeLimits($assessmentSection->getTimeLimits());
return $extended;
} | php | public static function createFromAssessmentSection(AssessmentSection $assessmentSection)
{
$extended = new static($assessmentSection->getIdentifier(), $assessmentSection->getTitle(), $assessmentSection->isVisible());
$extended->setKeepTogether($assessmentSection->mustKeepTogether());
$extended->setSelection($assessmentSection->getSelection());
$extended->setOrdering($assessmentSection->getOrdering());
$extended->setRubricBlocks($assessmentSection->getRubricBlocks());
$extended->setSectionParts($assessmentSection->getSectionParts());
$extended->setRequired($assessmentSection->isRequired());
$extended->setPreConditions($assessmentSection->getPreConditions());
$extended->setBranchRules($assessmentSection->getBranchRules());
$extended->setItemSessionControl($assessmentSection->getItemSessionControl());
$extended->setTimeLimits($assessmentSection->getTimeLimits());
return $extended;
} | [
"public",
"static",
"function",
"createFromAssessmentSection",
"(",
"AssessmentSection",
"$",
"assessmentSection",
")",
"{",
"$",
"extended",
"=",
"new",
"static",
"(",
"$",
"assessmentSection",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"assessmentSection",
"->",
"getTitle",
"(",
")",
",",
"$",
"assessmentSection",
"->",
"isVisible",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setKeepTogether",
"(",
"$",
"assessmentSection",
"->",
"mustKeepTogether",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setSelection",
"(",
"$",
"assessmentSection",
"->",
"getSelection",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setOrdering",
"(",
"$",
"assessmentSection",
"->",
"getOrdering",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setRubricBlocks",
"(",
"$",
"assessmentSection",
"->",
"getRubricBlocks",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setSectionParts",
"(",
"$",
"assessmentSection",
"->",
"getSectionParts",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setRequired",
"(",
"$",
"assessmentSection",
"->",
"isRequired",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setPreConditions",
"(",
"$",
"assessmentSection",
"->",
"getPreConditions",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setBranchRules",
"(",
"$",
"assessmentSection",
"->",
"getBranchRules",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setItemSessionControl",
"(",
"$",
"assessmentSection",
"->",
"getItemSessionControl",
"(",
")",
")",
";",
"$",
"extended",
"->",
"setTimeLimits",
"(",
"$",
"assessmentSection",
"->",
"getTimeLimits",
"(",
")",
")",
";",
"return",
"$",
"extended",
";",
"}"
] | Create a new ExtendedAssessmentSection object from an existing
AssessmentSection object.
@param \qtism\data\AssessmentSection $assessmentSection An AssessmentSection object.
@return \qtism\data\ExtendedAssessmentSection An ExtendedAssessmentSection object built from $assessmentSection. | [
"Create",
"a",
"new",
"ExtendedAssessmentSection",
"object",
"from",
"an",
"existing",
"AssessmentSection",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/ExtendedAssessmentSection.php#L86-L101 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/ImgMarshaller.php | ImgMarshaller.marshall | protected function marshall(QtiComponent $component)
{
$element = self::getDOMCradle()->createElement('img');
$this->setDOMElementAttribute($element, 'src', $component->getSrc());
$this->setDOMElementAttribute($element, 'alt', $component->getAlt());
if ($component->hasWidth() === true) {
$this->setDOMElementAttribute($element, 'width', $component->getWidth());
}
if ($component->hasHeight() === true) {
$this->setDOMElementAttribute($element, 'height', $component->getHeight());
}
if ($component->hasLongdesc() === true) {
$this->setDOMElementAttribute($element, 'longdesc', $component->getLongdesc());
}
if ($component->hasXmlBase() === true) {
self::setXmlBase($element, $component->getXmlBase());
}
$this->fillElement($element, $component);
return $element;
} | php | protected function marshall(QtiComponent $component)
{
$element = self::getDOMCradle()->createElement('img');
$this->setDOMElementAttribute($element, 'src', $component->getSrc());
$this->setDOMElementAttribute($element, 'alt', $component->getAlt());
if ($component->hasWidth() === true) {
$this->setDOMElementAttribute($element, 'width', $component->getWidth());
}
if ($component->hasHeight() === true) {
$this->setDOMElementAttribute($element, 'height', $component->getHeight());
}
if ($component->hasLongdesc() === true) {
$this->setDOMElementAttribute($element, 'longdesc', $component->getLongdesc());
}
if ($component->hasXmlBase() === true) {
self::setXmlBase($element, $component->getXmlBase());
}
$this->fillElement($element, $component);
return $element;
} | [
"protected",
"function",
"marshall",
"(",
"QtiComponent",
"$",
"component",
")",
"{",
"$",
"element",
"=",
"self",
"::",
"getDOMCradle",
"(",
")",
"->",
"createElement",
"(",
"'img'",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'src'",
",",
"$",
"component",
"->",
"getSrc",
"(",
")",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'alt'",
",",
"$",
"component",
"->",
"getAlt",
"(",
")",
")",
";",
"if",
"(",
"$",
"component",
"->",
"hasWidth",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'width'",
",",
"$",
"component",
"->",
"getWidth",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"component",
"->",
"hasHeight",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'height'",
",",
"$",
"component",
"->",
"getHeight",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"component",
"->",
"hasLongdesc",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'longdesc'",
",",
"$",
"component",
"->",
"getLongdesc",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"component",
"->",
"hasXmlBase",
"(",
")",
"===",
"true",
")",
"{",
"self",
"::",
"setXmlBase",
"(",
"$",
"element",
",",
"$",
"component",
"->",
"getXmlBase",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"fillElement",
"(",
"$",
"element",
",",
"$",
"component",
")",
";",
"return",
"$",
"element",
";",
"}"
] | Marshall an Img object into a DOMElement object.
@param \qtism\data\QtiComponent $component An Img object.
@return \DOMElement The according DOMElement object.
@throws \qtism\data\storage\xml\marshalling\MarshallingException | [
"Marshall",
"an",
"Img",
"object",
"into",
"a",
"DOMElement",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/ImgMarshaller.php#L44-L70 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/ImgMarshaller.php | ImgMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
if (($src = $this->getDOMElementAttributeAs($element, 'src')) !== null) {
if (($alt = $this->getDOMElementAttributeAs($element, 'alt')) === null) {
// The XSD does not force the 'alt' attribute to be non-empty,
// thus we consider the 'alt' attribute value as an empty string ('').
$alt = '';
}
$component = new Img($src, $alt);
if (($longdesc = $this->getDOMElementAttributeAs($element, 'longdesc')) !== null) {
$component->setLongdesc($longdesc);
}
if (($height = $this->getDOMElementAttributeAs($element, 'height', 'string')) !== null) {
if (stripos($height, '%') === false) {
$component->setHeight(intval($height));
} else {
$component->setHeight($height);
}
}
if (($width = $this->getDOMElementAttributeAs($element, 'width', 'string')) !== null) {
if (stripos($width, '%') === false) {
$component->setWidth(intval($width));
} else {
$component->setWidth($width);
}
}
if (($xmlBase = self::getXmlBase($element)) !== false) {
$component->setXmlBase($xmlBase);
}
$this->fillBodyElement($component, $element);
return $component;
} else {
$msg = "The 'mandatory' attribute 'src' is missing from element 'img'.";
throw new UnmarshallingException($msg, $element);
}
} | php | protected function unmarshall(DOMElement $element)
{
if (($src = $this->getDOMElementAttributeAs($element, 'src')) !== null) {
if (($alt = $this->getDOMElementAttributeAs($element, 'alt')) === null) {
// The XSD does not force the 'alt' attribute to be non-empty,
// thus we consider the 'alt' attribute value as an empty string ('').
$alt = '';
}
$component = new Img($src, $alt);
if (($longdesc = $this->getDOMElementAttributeAs($element, 'longdesc')) !== null) {
$component->setLongdesc($longdesc);
}
if (($height = $this->getDOMElementAttributeAs($element, 'height', 'string')) !== null) {
if (stripos($height, '%') === false) {
$component->setHeight(intval($height));
} else {
$component->setHeight($height);
}
}
if (($width = $this->getDOMElementAttributeAs($element, 'width', 'string')) !== null) {
if (stripos($width, '%') === false) {
$component->setWidth(intval($width));
} else {
$component->setWidth($width);
}
}
if (($xmlBase = self::getXmlBase($element)) !== false) {
$component->setXmlBase($xmlBase);
}
$this->fillBodyElement($component, $element);
return $component;
} else {
$msg = "The 'mandatory' attribute 'src' is missing from element 'img'.";
throw new UnmarshallingException($msg, $element);
}
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"if",
"(",
"(",
"$",
"src",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'src'",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"alt",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'alt'",
")",
")",
"===",
"null",
")",
"{",
"// The XSD does not force the 'alt' attribute to be non-empty,",
"// thus we consider the 'alt' attribute value as an empty string ('').",
"$",
"alt",
"=",
"''",
";",
"}",
"$",
"component",
"=",
"new",
"Img",
"(",
"$",
"src",
",",
"$",
"alt",
")",
";",
"if",
"(",
"(",
"$",
"longdesc",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'longdesc'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"component",
"->",
"setLongdesc",
"(",
"$",
"longdesc",
")",
";",
"}",
"if",
"(",
"(",
"$",
"height",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'height'",
",",
"'string'",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"height",
",",
"'%'",
")",
"===",
"false",
")",
"{",
"$",
"component",
"->",
"setHeight",
"(",
"intval",
"(",
"$",
"height",
")",
")",
";",
"}",
"else",
"{",
"$",
"component",
"->",
"setHeight",
"(",
"$",
"height",
")",
";",
"}",
"}",
"if",
"(",
"(",
"$",
"width",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'width'",
",",
"'string'",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"width",
",",
"'%'",
")",
"===",
"false",
")",
"{",
"$",
"component",
"->",
"setWidth",
"(",
"intval",
"(",
"$",
"width",
")",
")",
";",
"}",
"else",
"{",
"$",
"component",
"->",
"setWidth",
"(",
"$",
"width",
")",
";",
"}",
"}",
"if",
"(",
"(",
"$",
"xmlBase",
"=",
"self",
"::",
"getXmlBase",
"(",
"$",
"element",
")",
")",
"!==",
"false",
")",
"{",
"$",
"component",
"->",
"setXmlBase",
"(",
"$",
"xmlBase",
")",
";",
"}",
"$",
"this",
"->",
"fillBodyElement",
"(",
"$",
"component",
",",
"$",
"element",
")",
";",
"return",
"$",
"component",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'mandatory' attribute 'src' is missing from element 'img'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}"
] | Unmarshall a DOMElement object corresponding to an XHTML img element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent n Img object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"an",
"XHTML",
"img",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/ImgMarshaller.php#L79-L122 |
oat-sa/qti-sdk | src/qtism/data/View.php | View.asArray | public static function asArray()
{
return array(
'AUTHOR' => self::AUTHOR,
'CANDIDATE' => self::CANDIDATE,
'PROCTOR' => self::PROCTOR,
'SCORER' => self::SCORER,
'TEST_CONSTRUCTOR' => self::TEST_CONSTRUCTOR,
'TUTOR' => self::TUTOR
);
} | php | public static function asArray()
{
return array(
'AUTHOR' => self::AUTHOR,
'CANDIDATE' => self::CANDIDATE,
'PROCTOR' => self::PROCTOR,
'SCORER' => self::SCORER,
'TEST_CONSTRUCTOR' => self::TEST_CONSTRUCTOR,
'TUTOR' => self::TUTOR
);
} | [
"public",
"static",
"function",
"asArray",
"(",
")",
"{",
"return",
"array",
"(",
"'AUTHOR'",
"=>",
"self",
"::",
"AUTHOR",
",",
"'CANDIDATE'",
"=>",
"self",
"::",
"CANDIDATE",
",",
"'PROCTOR'",
"=>",
"self",
"::",
"PROCTOR",
",",
"'SCORER'",
"=>",
"self",
"::",
"SCORER",
",",
"'TEST_CONSTRUCTOR'",
"=>",
"self",
"::",
"TEST_CONSTRUCTOR",
",",
"'TUTOR'",
"=>",
"self",
"::",
"TUTOR",
")",
";",
"}"
] | Get the possible values of the enumaration as an array.
@return array An array of integer constants. | [
"Get",
"the",
"possible",
"values",
"of",
"the",
"enumaration",
"as",
"an",
"array",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/View.php#L52-L62 |
oat-sa/qti-sdk | src/qtism/data/View.php | View.getNameByConstant | public static function getNameByConstant($constant)
{
switch ($constant) {
case self::AUTHOR:
return 'author';
break;
case self::CANDIDATE:
return 'candidate';
break;
case self::PROCTOR:
return 'proctor';
break;
case self::SCORER:
return 'scorer';
break;
case self::TEST_CONSTRUCTOR:
return 'testConstructor';
break;
case self::TUTOR:
return 'tutor';
break;
default:
return false;
break;
}
} | php | public static function getNameByConstant($constant)
{
switch ($constant) {
case self::AUTHOR:
return 'author';
break;
case self::CANDIDATE:
return 'candidate';
break;
case self::PROCTOR:
return 'proctor';
break;
case self::SCORER:
return 'scorer';
break;
case self::TEST_CONSTRUCTOR:
return 'testConstructor';
break;
case self::TUTOR:
return 'tutor';
break;
default:
return false;
break;
}
} | [
"public",
"static",
"function",
"getNameByConstant",
"(",
"$",
"constant",
")",
"{",
"switch",
"(",
"$",
"constant",
")",
"{",
"case",
"self",
"::",
"AUTHOR",
":",
"return",
"'author'",
";",
"break",
";",
"case",
"self",
"::",
"CANDIDATE",
":",
"return",
"'candidate'",
";",
"break",
";",
"case",
"self",
"::",
"PROCTOR",
":",
"return",
"'proctor'",
";",
"break",
";",
"case",
"self",
"::",
"SCORER",
":",
"return",
"'scorer'",
";",
"break",
";",
"case",
"self",
"::",
"TEST_CONSTRUCTOR",
":",
"return",
"'testConstructor'",
";",
"break",
";",
"case",
"self",
"::",
"TUTOR",
":",
"return",
"'tutor'",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"break",
";",
"}",
"}"
] | Get a constant name by its value.
@param integer $constant The constant value from the View enumeration.
@return string|boolean The name of the constant or false it if could not be resolved. | [
"Get",
"a",
"constant",
"name",
"by",
"its",
"value",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/View.php#L70-L101 |
oat-sa/qti-sdk | src/qtism/data/View.php | View.getConstantByName | public static function getConstantByName($name)
{
switch (strtolower($name)) {
case 'author':
return self::AUTHOR;
break;
case 'candidate':
return self::CANDIDATE;
break;
case 'proctor':
return self::PROCTOR;
break;
case 'scorer':
return self::SCORER;
break;
case 'testconstructor':
return self::TEST_CONSTRUCTOR;
break;
case 'tutor':
return self::TUTOR;
break;
default:
return false;
break;
}
} | php | public static function getConstantByName($name)
{
switch (strtolower($name)) {
case 'author':
return self::AUTHOR;
break;
case 'candidate':
return self::CANDIDATE;
break;
case 'proctor':
return self::PROCTOR;
break;
case 'scorer':
return self::SCORER;
break;
case 'testconstructor':
return self::TEST_CONSTRUCTOR;
break;
case 'tutor':
return self::TUTOR;
break;
default:
return false;
break;
}
} | [
"public",
"static",
"function",
"getConstantByName",
"(",
"$",
"name",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"name",
")",
")",
"{",
"case",
"'author'",
":",
"return",
"self",
"::",
"AUTHOR",
";",
"break",
";",
"case",
"'candidate'",
":",
"return",
"self",
"::",
"CANDIDATE",
";",
"break",
";",
"case",
"'proctor'",
":",
"return",
"self",
"::",
"PROCTOR",
";",
"break",
";",
"case",
"'scorer'",
":",
"return",
"self",
"::",
"SCORER",
";",
"break",
";",
"case",
"'testconstructor'",
":",
"return",
"self",
"::",
"TEST_CONSTRUCTOR",
";",
"break",
";",
"case",
"'tutor'",
":",
"return",
"self",
"::",
"TUTOR",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"break",
";",
"}",
"}"
] | Get the constant value from its name.
@param string $name The name of the constant you want to retrieve the value.
@return integer|boolean The value of the related constant or false if the name could not be resolved. | [
"Get",
"the",
"constant",
"value",
"from",
"its",
"name",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/View.php#L109-L140 |
oat-sa/qti-sdk | src/qtism/runtime/expressions/operators/OrderedProcessor.php | OrderedProcessor.appendValue | protected static function appendValue(OrderedContainer $container, $value)
{
if ($value instanceof OrderedContainer) {
foreach ($value as $v) {
$container[] = $v;
}
} else {
// primitive type.
$container[] = $value;
}
} | php | protected static function appendValue(OrderedContainer $container, $value)
{
if ($value instanceof OrderedContainer) {
foreach ($value as $v) {
$container[] = $v;
}
} else {
// primitive type.
$container[] = $value;
}
} | [
"protected",
"static",
"function",
"appendValue",
"(",
"OrderedContainer",
"$",
"container",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"OrderedContainer",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"v",
")",
"{",
"$",
"container",
"[",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"else",
"{",
"// primitive type.",
"$",
"container",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Append a value (An orderedContainer or a primitive datatype) to a given $container.
@param \qtism\runtime\common\OrderedContainer $container An OrderedContainer object you want to append something to.
@param scalar|\qtism\runtime\common\OrderedContainer $value A value to append to the $container. | [
"Append",
"a",
"value",
"(",
"An",
"orderedContainer",
"or",
"a",
"primitive",
"datatype",
")",
"to",
"a",
"given",
"$container",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/expressions/operators/OrderedProcessor.php#L108-L118 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/OrderInteraction.php | OrderInteraction.setSimpleChoices | public function setSimpleChoices(SimpleChoiceCollection $simpleChoices)
{
if (count($simpleChoices) > 0) {
$this->simpleChoices = $simpleChoices;
} else {
$msg = "An OrderInteraction object must be composed of at lease one SimpleChoice object, none given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setSimpleChoices(SimpleChoiceCollection $simpleChoices)
{
if (count($simpleChoices) > 0) {
$this->simpleChoices = $simpleChoices;
} else {
$msg = "An OrderInteraction object must be composed of at lease one SimpleChoice object, none given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setSimpleChoices",
"(",
"SimpleChoiceCollection",
"$",
"simpleChoices",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"simpleChoices",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"simpleChoices",
"=",
"$",
"simpleChoices",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"An OrderInteraction object must be composed of at lease one SimpleChoice object, none given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the ordered list of choices that are displayed to the user.
@param \qtism\data\content\interactions\SimpleChoiceCollection $simpleChoices A list of at lease one SimpleChoice object.
@throws InvalidArgumentException If $simpleChoices is empty. | [
"Set",
"the",
"ordered",
"list",
"of",
"choices",
"that",
"are",
"displayed",
"to",
"the",
"user",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/OrderInteraction.php#L143-L151 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/OrderInteraction.php | OrderInteraction.setMinChoices | public function setMinChoices($minChoices)
{
if (is_int($minChoices) === true && ($minChoices > 0 || $minChoices === -1)) {
if ($minChoices > count($this->getSimpleChoices())) {
$msg = "The value of 'minChoices' cannot exceed the number of available choices.";
throw new InvalidArgumentException($msg);
}
$this->minChoices = $minChoices;
} else {
$msg = "The 'minChoices' argument must be a strictly positive (> 0) integer or -1, '" . gettype($minChoices) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setMinChoices($minChoices)
{
if (is_int($minChoices) === true && ($minChoices > 0 || $minChoices === -1)) {
if ($minChoices > count($this->getSimpleChoices())) {
$msg = "The value of 'minChoices' cannot exceed the number of available choices.";
throw new InvalidArgumentException($msg);
}
$this->minChoices = $minChoices;
} else {
$msg = "The 'minChoices' argument must be a strictly positive (> 0) integer or -1, '" . gettype($minChoices) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setMinChoices",
"(",
"$",
"minChoices",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"minChoices",
")",
"===",
"true",
"&&",
"(",
"$",
"minChoices",
">",
"0",
"||",
"$",
"minChoices",
"===",
"-",
"1",
")",
")",
"{",
"if",
"(",
"$",
"minChoices",
">",
"count",
"(",
"$",
"this",
"->",
"getSimpleChoices",
"(",
")",
")",
")",
"{",
"$",
"msg",
"=",
"\"The value of 'minChoices' cannot exceed the number of available choices.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"this",
"->",
"minChoices",
"=",
"$",
"minChoices",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'minChoices' argument must be a strictly positive (> 0) integer or -1, '\"",
".",
"gettype",
"(",
"$",
"minChoices",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the minimum number of choices that the candidate may select.
@param integer $minChoices A strictly (> 0) positive integer or -1 if no value is specified for the attribute.
@throws \InvalidArgumentException If $minChoices is not a strictly positive integer nor -1. | [
"Set",
"the",
"minimum",
"number",
"of",
"choices",
"that",
"the",
"candidate",
"may",
"select",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/OrderInteraction.php#L195-L209 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/OrderInteraction.php | OrderInteraction.setMaxChoices | public function setMaxChoices($maxChoices)
{
if (is_int($maxChoices) === true && $maxChoices > 0 || $maxChoices === -1) {
if ($this->hasMinChoices() === true && $maxChoices > count($this->getSimpleChoices())) {
$msg = "The 'maxChoices' argument cannot exceed the number of available choices.";
throw new InvalidArgumentException($msg);
}
$this->maxChoices = $maxChoices;
} else {
$msg = "The 'maxChoices' argument must be a strictly positive (> 0) integer or -1, '" . gettype($maxChoices) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setMaxChoices($maxChoices)
{
if (is_int($maxChoices) === true && $maxChoices > 0 || $maxChoices === -1) {
if ($this->hasMinChoices() === true && $maxChoices > count($this->getSimpleChoices())) {
$msg = "The 'maxChoices' argument cannot exceed the number of available choices.";
throw new InvalidArgumentException($msg);
}
$this->maxChoices = $maxChoices;
} else {
$msg = "The 'maxChoices' argument must be a strictly positive (> 0) integer or -1, '" . gettype($maxChoices) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setMaxChoices",
"(",
"$",
"maxChoices",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"maxChoices",
")",
"===",
"true",
"&&",
"$",
"maxChoices",
">",
"0",
"||",
"$",
"maxChoices",
"===",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMinChoices",
"(",
")",
"===",
"true",
"&&",
"$",
"maxChoices",
">",
"count",
"(",
"$",
"this",
"->",
"getSimpleChoices",
"(",
")",
")",
")",
"{",
"$",
"msg",
"=",
"\"The 'maxChoices' argument cannot exceed the number of available choices.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"this",
"->",
"maxChoices",
"=",
"$",
"maxChoices",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'maxChoices' argument must be a strictly positive (> 0) integer or -1, '\"",
".",
"gettype",
"(",
"$",
"maxChoices",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the maximum number of choices that the candidate may select and order when responding to the interaction.
@param integer $maxChoices A strictly positive (> 0) integer or -1 if no value is specified for the attribuite.
@throws \InvalidArgumentException If $maxChoices is not a strictly positive integer nor -1. | [
"Set",
"the",
"maximum",
"number",
"of",
"choices",
"that",
"the",
"candidate",
"may",
"select",
"and",
"order",
"when",
"responding",
"to",
"the",
"interaction",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/OrderInteraction.php#L237-L251 |
oat-sa/qti-sdk | src/qtism/runtime/expressions/NumberRespondedProcessor.php | NumberRespondedProcessor.process | public function process()
{
$testSession = $this->getState();
$itemSubset = $this->getItemSubset();
$numberResponded = 0;
foreach ($itemSubset as $item) {
$itemSessions = $testSession->getAssessmentItemSessions($item->getIdentifier());
if ($itemSessions !== false) {
foreach ($itemSessions as $itemSession) {
if ($itemSession->isResponded() === true) {
$numberResponded++;
}
}
}
}
return new QtiInteger($numberResponded);
} | php | public function process()
{
$testSession = $this->getState();
$itemSubset = $this->getItemSubset();
$numberResponded = 0;
foreach ($itemSubset as $item) {
$itemSessions = $testSession->getAssessmentItemSessions($item->getIdentifier());
if ($itemSessions !== false) {
foreach ($itemSessions as $itemSession) {
if ($itemSession->isResponded() === true) {
$numberResponded++;
}
}
}
}
return new QtiInteger($numberResponded);
} | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"testSession",
"=",
"$",
"this",
"->",
"getState",
"(",
")",
";",
"$",
"itemSubset",
"=",
"$",
"this",
"->",
"getItemSubset",
"(",
")",
";",
"$",
"numberResponded",
"=",
"0",
";",
"foreach",
"(",
"$",
"itemSubset",
"as",
"$",
"item",
")",
"{",
"$",
"itemSessions",
"=",
"$",
"testSession",
"->",
"getAssessmentItemSessions",
"(",
"$",
"item",
"->",
"getIdentifier",
"(",
")",
")",
";",
"if",
"(",
"$",
"itemSessions",
"!==",
"false",
")",
"{",
"foreach",
"(",
"$",
"itemSessions",
"as",
"$",
"itemSession",
")",
"{",
"if",
"(",
"$",
"itemSession",
"->",
"isResponded",
"(",
")",
"===",
"true",
")",
"{",
"$",
"numberResponded",
"++",
";",
"}",
"}",
"}",
"}",
"return",
"new",
"QtiInteger",
"(",
"$",
"numberResponded",
")",
";",
"}"
] | Process the related NumberResponded expression.
@return integer The number of items in the given sub-set that been attempted (at least once) and for which a response was given.
@throws \qtism\runtime\expressions\ExpressionProcessingException | [
"Process",
"the",
"related",
"NumberResponded",
"expression",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/expressions/NumberRespondedProcessor.php#L53-L72 |
oat-sa/qti-sdk | src/qtism/data/TimeLimits.php | TimeLimits.setMinTime | public function setMinTime(QtiDuration $minTime = null)
{
// Prevent to get 0s durations stored.
if (is_null($minTime) === false && $minTime->getSeconds(true) === 0) {
$minTime = null;
}
$this->minTime = $minTime;
} | php | public function setMinTime(QtiDuration $minTime = null)
{
// Prevent to get 0s durations stored.
if (is_null($minTime) === false && $minTime->getSeconds(true) === 0) {
$minTime = null;
}
$this->minTime = $minTime;
} | [
"public",
"function",
"setMinTime",
"(",
"QtiDuration",
"$",
"minTime",
"=",
"null",
")",
"{",
"// Prevent to get 0s durations stored.",
"if",
"(",
"is_null",
"(",
"$",
"minTime",
")",
"===",
"false",
"&&",
"$",
"minTime",
"->",
"getSeconds",
"(",
"true",
")",
"===",
"0",
")",
"{",
"$",
"minTime",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"minTime",
"=",
"$",
"minTime",
";",
"}"
] | Set the minimum time.
@param \qtism\common\datatypes\Duration $minTime A Duration object or null if unlimited. | [
"Set",
"the",
"minimum",
"time",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/TimeLimits.php#L119-L127 |
oat-sa/qti-sdk | src/qtism/data/TimeLimits.php | TimeLimits.setMaxTime | public function setMaxTime(QtiDuration $maxTime = null)
{
// Prevent to get 0s durations stored.
if (is_null($maxTime) === false && $maxTime->getSeconds(true) === 0) {
$maxTime = null;
}
$this->maxTime = $maxTime;
} | php | public function setMaxTime(QtiDuration $maxTime = null)
{
// Prevent to get 0s durations stored.
if (is_null($maxTime) === false && $maxTime->getSeconds(true) === 0) {
$maxTime = null;
}
$this->maxTime = $maxTime;
} | [
"public",
"function",
"setMaxTime",
"(",
"QtiDuration",
"$",
"maxTime",
"=",
"null",
")",
"{",
"// Prevent to get 0s durations stored.",
"if",
"(",
"is_null",
"(",
"$",
"maxTime",
")",
"===",
"false",
"&&",
"$",
"maxTime",
"->",
"getSeconds",
"(",
"true",
")",
"===",
"0",
")",
"{",
"$",
"maxTime",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"maxTime",
"=",
"$",
"maxTime",
";",
"}"
] | Set the maximum time or null if unlimited.
@param \qtism\common\datatypes\Duration $maxTime A duration object or null if unlimited. | [
"Set",
"the",
"maximum",
"time",
"or",
"null",
"if",
"unlimited",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/TimeLimits.php#L154-L162 |
oat-sa/qti-sdk | src/qtism/data/TimeLimits.php | TimeLimits.setAllowLateSubmission | public function setAllowLateSubmission($allowLateSubmission)
{
if (is_bool($allowLateSubmission)) {
$this->allowLateSubmission = $allowLateSubmission;
} else {
$msg = "AllowLateSubmission must be a boolean, '" . gettype($allowLateSubmission) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setAllowLateSubmission($allowLateSubmission)
{
if (is_bool($allowLateSubmission)) {
$this->allowLateSubmission = $allowLateSubmission;
} else {
$msg = "AllowLateSubmission must be a boolean, '" . gettype($allowLateSubmission) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setAllowLateSubmission",
"(",
"$",
"allowLateSubmission",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"allowLateSubmission",
")",
")",
"{",
"$",
"this",
"->",
"allowLateSubmission",
"=",
"$",
"allowLateSubmission",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"AllowLateSubmission must be a boolean, '\"",
".",
"gettype",
"(",
"$",
"allowLateSubmission",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set wether a candidate's response that is beyond the maxTime should be still
accepted.
@param boolean $allowLateSubmission true if the candidate's response should still be accepted, false if not.
@throws \InvalidArgumentException If $allowLateSubmission is not a boolean. | [
"Set",
"wether",
"a",
"candidate",
"s",
"response",
"that",
"is",
"beyond",
"the",
"maxTime",
"should",
"be",
"still",
"accepted",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/TimeLimits.php#L182-L190 |
oat-sa/qti-sdk | src/qtism/common/storage/AbstractStreamAccess.php | AbstractStreamAccess.setStream | protected function setStream(IStream $stream)
{
if ($stream->isOpen() === false) {
$msg = "An AbstractStreamAccess do not accept closed streams to be read.";
throw new StreamAccessException($msg, $this, StreamAccessException::NOT_OPEN);
}
$this->stream = $stream;
} | php | protected function setStream(IStream $stream)
{
if ($stream->isOpen() === false) {
$msg = "An AbstractStreamAccess do not accept closed streams to be read.";
throw new StreamAccessException($msg, $this, StreamAccessException::NOT_OPEN);
}
$this->stream = $stream;
} | [
"protected",
"function",
"setStream",
"(",
"IStream",
"$",
"stream",
")",
"{",
"if",
"(",
"$",
"stream",
"->",
"isOpen",
"(",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"An AbstractStreamAccess do not accept closed streams to be read.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"StreamAccessException",
"::",
"NOT_OPEN",
")",
";",
"}",
"$",
"this",
"->",
"stream",
"=",
"$",
"stream",
";",
"}"
] | Set the IStream object to be read.
@param \qtism\common\storage\IStream $stream An IStream object.
@throws \qtism\common\storage\StreamAccessException If the $stream is not open yet. | [
"Set",
"the",
"IStream",
"object",
"to",
"be",
"read",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/storage/AbstractStreamAccess.php#L67-L75 |
oat-sa/qti-sdk | src/qtism/common/collections/IdentifierCollection.php | IdentifierCollection.checkType | protected function checkType($value)
{
if (gettype($value) !== 'string') {
$msg = "IdentifierCollection class only accept string values, '" . gettype($value) . "' given.";
throw new InvalidArgumentException($msg);
} elseif (!Format::isIdentifier($value)) {
$msg = "IdentifierCollection class only accept valid QTI Identifiers, '${value}' given.";
throw new InvalidArgumentException($msg);
}
} | php | protected function checkType($value)
{
if (gettype($value) !== 'string') {
$msg = "IdentifierCollection class only accept string values, '" . gettype($value) . "' given.";
throw new InvalidArgumentException($msg);
} elseif (!Format::isIdentifier($value)) {
$msg = "IdentifierCollection class only accept valid QTI Identifiers, '${value}' given.";
throw new InvalidArgumentException($msg);
}
} | [
"protected",
"function",
"checkType",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"gettype",
"(",
"$",
"value",
")",
"!==",
"'string'",
")",
"{",
"$",
"msg",
"=",
"\"IdentifierCollection class only accept string values, '\"",
".",
"gettype",
"(",
"$",
"value",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"elseif",
"(",
"!",
"Format",
"::",
"isIdentifier",
"(",
"$",
"value",
")",
")",
"{",
"$",
"msg",
"=",
"\"IdentifierCollection class only accept valid QTI Identifiers, '${value}' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Check if $value is a valid QTI Identifier.
@throws \InvalidArgumentException If $value is not a valid QTI Identifier. | [
"Check",
"if",
"$value",
"is",
"a",
"valid",
"QTI",
"Identifier",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/collections/IdentifierCollection.php#L40-L49 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeScalar | public function writeScalar($scalar)
{
if (Utils::isScalar($scalar) === false) {
$msg = "A '" . gettype($scalar) . "' value is not a PHP scalar value nor null.";
throw new InvalidArgumentException($msg);
}
try {
if (is_int($scalar) === true) {
$this->getStream()->write($scalar);
} elseif (is_double($scalar) === true) {
if (strpos('' . $scalar, '.') === false) {
$scalar = $scalar . '.0';
}
$this->getStream()->write($scalar);
} elseif (is_string($scalar) === true) {
$this->getStream()->write(PhpUtils::doubleQuotedPhpString($scalar));
} elseif (is_bool($scalar) === true) {
$this->getStream()->write(($scalar === true) ? 'true' : 'false');
} elseif (is_null($scalar) === true) {
$this->getStream()->write('null');
}
} catch (StreamException $e) {
$msg = "An error occured while writing the scalar value '${scalar}'.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeScalar($scalar)
{
if (Utils::isScalar($scalar) === false) {
$msg = "A '" . gettype($scalar) . "' value is not a PHP scalar value nor null.";
throw new InvalidArgumentException($msg);
}
try {
if (is_int($scalar) === true) {
$this->getStream()->write($scalar);
} elseif (is_double($scalar) === true) {
if (strpos('' . $scalar, '.') === false) {
$scalar = $scalar . '.0';
}
$this->getStream()->write($scalar);
} elseif (is_string($scalar) === true) {
$this->getStream()->write(PhpUtils::doubleQuotedPhpString($scalar));
} elseif (is_bool($scalar) === true) {
$this->getStream()->write(($scalar === true) ? 'true' : 'false');
} elseif (is_null($scalar) === true) {
$this->getStream()->write('null');
}
} catch (StreamException $e) {
$msg = "An error occured while writing the scalar value '${scalar}'.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeScalar",
"(",
"$",
"scalar",
")",
"{",
"if",
"(",
"Utils",
"::",
"isScalar",
"(",
"$",
"scalar",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"A '\"",
".",
"gettype",
"(",
"$",
"scalar",
")",
".",
"\"' value is not a PHP scalar value nor null.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"try",
"{",
"if",
"(",
"is_int",
"(",
"$",
"scalar",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"$",
"scalar",
")",
";",
"}",
"elseif",
"(",
"is_double",
"(",
"$",
"scalar",
")",
"===",
"true",
")",
"{",
"if",
"(",
"strpos",
"(",
"''",
".",
"$",
"scalar",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"scalar",
"=",
"$",
"scalar",
".",
"'.0'",
";",
"}",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"$",
"scalar",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"scalar",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"PhpUtils",
"::",
"doubleQuotedPhpString",
"(",
"$",
"scalar",
")",
")",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"scalar",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"(",
"$",
"scalar",
"===",
"true",
")",
"?",
"'true'",
":",
"'false'",
")",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"scalar",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'null'",
")",
";",
"}",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing the scalar value '${scalar}'.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a scalar value into the current stream.
If the given value is a string, it will be output surrounded by double quotes (") characters.
@param mixed $scalar A PHP scalar value or null.
@throws InvalidArgumentException If $scalar is not a PHP scalar value nor null.
@throws StreamAccessException If an error occurs while writing the scalar value. | [
"Write",
"a",
"scalar",
"value",
"into",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L63-L90 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeEquals | public function writeEquals($spaces = true)
{
try {
if ($spaces === true) {
$this->getStream()->write(' = ');
} else {
$this->getStream()->write('=');
}
} catch (StreamException $e) {
$msg = "An error occured while writing the PHP equality symbol (=).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeEquals($spaces = true)
{
try {
if ($spaces === true) {
$this->getStream()->write(' = ');
} else {
$this->getStream()->write('=');
}
} catch (StreamException $e) {
$msg = "An error occured while writing the PHP equality symbol (=).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeEquals",
"(",
"$",
"spaces",
"=",
"true",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"spaces",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"' = '",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'='",
")",
";",
"}",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing the PHP equality symbol (=).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write the PHP equality symbol into the current stream.
@param boolean $spaces Whether to surround the equality symbol with spaces.
@throws StreamAccessException If an error occurs while writing the equality symbol. | [
"Write",
"the",
"PHP",
"equality",
"symbol",
"into",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L98-L110 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeNewline | public function writeNewline()
{
try {
$this->getStream()->write("\n");
} catch (StreamException $e) {
$msg = "An error occured while writing a newline escape sequence (\\n).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeNewline()
{
try {
$this->getStream()->write("\n");
} catch (StreamException $e) {
$msg = "An error occured while writing a newline escape sequence (\\n).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeNewline",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"\"\\n\"",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a newline escape sequence (\\\\n).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a newline escape sequence in the current stream.
@throws StreamAccessException If an error occurs while writing the equality symbol. | [
"Write",
"a",
"newline",
"escape",
"sequence",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L117-L125 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeOpeningTag | public function writeOpeningTag($newline = true)
{
try {
$this->getStream()->write('<?php');
if ($newline === true) {
$this->writeNewline();
}
} catch (StreamException $e) {
$msg = "An error occured while writing a PHP opening tag (<?php).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeOpeningTag($newline = true)
{
try {
$this->getStream()->write('<?php');
if ($newline === true) {
$this->writeNewline();
}
} catch (StreamException $e) {
$msg = "An error occured while writing a PHP opening tag (<?php).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeOpeningTag",
"(",
"$",
"newline",
"=",
"true",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'<?php'",
")",
";",
"if",
"(",
"$",
"newline",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"writeNewline",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a PHP opening tag (<?php).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a PHP opening tag in the current stream.
@param boolean $newline Whether a newline escape sequence must be written after the opening tag.
@throws StreamAccessException If an error occurs while writing the opening tag. | [
"Write",
"a",
"PHP",
"opening",
"tag",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L133-L144 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeClosingTag | public function writeClosingTag($newline = true)
{
try {
if ($newline === true) {
$this->writeNewline();
}
$this->getStream()->write('?>');
} catch (Exception $e) {
$msg = "An error occured while writing a PHP closing tag (?>).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeClosingTag($newline = true)
{
try {
if ($newline === true) {
$this->writeNewline();
}
$this->getStream()->write('?>');
} catch (Exception $e) {
$msg = "An error occured while writing a PHP closing tag (?>).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeClosingTag",
"(",
"$",
"newline",
"=",
"true",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"newline",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"writeNewline",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'?>'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a PHP closing tag (?>).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a PHP closing tag in the current string.
@param boolean $newline | [
"Write",
"a",
"PHP",
"closing",
"tag",
"in",
"the",
"current",
"string",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L151-L162 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeColon | public function writeColon()
{
try {
$this->getStream()->write(':');
} catch (StreamException $e) {
$msg = "An error occured while writing a colon (:).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeColon()
{
try {
$this->getStream()->write(':');
} catch (StreamException $e) {
$msg = "An error occured while writing a colon (:).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeColon",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"':'",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a colon (:).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a PHP colon (:) in the current stream.
@throws StreamAccessException If an error occurs while writing the colon. | [
"Write",
"a",
"PHP",
"colon",
"(",
":",
")",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L188-L196 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeScopeResolution | public function writeScopeResolution()
{
try {
$this->getStream()->write('::');
} catch (StreamException $e) {
$msg = "An error occured while writing a scope resolution operator (::).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeScopeResolution()
{
try {
$this->getStream()->write('::');
} catch (StreamException $e) {
$msg = "An error occured while writing a scope resolution operator (::).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeScopeResolution",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'::'",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a scope resolution operator (::).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a PHP scope resolution operator (::) in the current stream.
@throws StreamAccessException If an error occurs while writing the scope resolution operator. | [
"Write",
"a",
"PHP",
"scope",
"resolution",
"operator",
"(",
"::",
")",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L203-L211 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writePaamayimNekudotayim | public function writePaamayimNekudotayim()
{
try {
$this->writeScopeResolution();
} catch (StreamAccessException $e) {
$msg = "An error occured while writing a Paamayim Nekudotayim.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writePaamayimNekudotayim()
{
try {
$this->writeScopeResolution();
} catch (StreamAccessException $e) {
$msg = "An error occured while writing a Paamayim Nekudotayim.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writePaamayimNekudotayim",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"writeScopeResolution",
"(",
")",
";",
"}",
"catch",
"(",
"StreamAccessException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a Paamayim Nekudotayim.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | An alias to PhpStreamAccess::writeScopeResolution ;-).
@see PhpStreamAccess::writeScopeResolution
@throws StreamAccessException If an error occurs while writing the "Paamayim Nekudotayim". | [
"An",
"alias",
"to",
"PhpStreamAccess",
"::",
"writeScopeResolution",
";",
"-",
")",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L219-L227 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeOpeningParenthesis | public function writeOpeningParenthesis()
{
try {
$this->getStream()->write('(');
} catch (StreamException $e) {
$msg = "An error occured while writing an opening parenthesis (().";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeOpeningParenthesis()
{
try {
$this->getStream()->write('(');
} catch (StreamException $e) {
$msg = "An error occured while writing an opening parenthesis (().";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeOpeningParenthesis",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'('",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing an opening parenthesis (().\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write an opening parenthesis in the current stream.
@throws StreamAccessException If an error occurs while writing the opening parenthesis. | [
"Write",
"an",
"opening",
"parenthesis",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L234-L242 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeClosingParenthesis | public function writeClosingParenthesis()
{
try {
$this->getStream()->write(')');
} catch (StreamException $e) {
$msg = "An error occured while writing a closing parenthesis ()).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeClosingParenthesis()
{
try {
$this->getStream()->write(')');
} catch (StreamException $e) {
$msg = "An error occured while writing a closing parenthesis ()).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeClosingParenthesis",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"')'",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a closing parenthesis ()).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a closing parenthesis in the current stream.
@throws StreamAccessException If an error occurs while writing the closing parenthesis. | [
"Write",
"a",
"closing",
"parenthesis",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L249-L257 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeComma | public function writeComma($space = true)
{
try {
$this->getStream()->write(',');
if ($space === true) {
$this->writeSpace();
}
} catch (StreamException $e) {
$msg = "An error occured while writing a comma (,).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeComma($space = true)
{
try {
$this->getStream()->write(',');
if ($space === true) {
$this->writeSpace();
}
} catch (StreamException $e) {
$msg = "An error occured while writing a comma (,).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeComma",
"(",
"$",
"space",
"=",
"true",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"','",
")",
";",
"if",
"(",
"$",
"space",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"writeSpace",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a comma (,).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a comma in the current stream.
@param boolean $space Whether a white space must be written after the comma.
@throws StreamAccessException If an error occurs while writing the comma. | [
"Write",
"a",
"comma",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L265-L276 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeSpace | public function writeSpace()
{
try {
$this->getStream()->write(' ');
} catch (StreamException $e) {
$msg = "An error occured while writing a white space ( ).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeSpace()
{
try {
$this->getStream()->write(' ');
} catch (StreamException $e) {
$msg = "An error occured while writing a white space ( ).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeSpace",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"' '",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a white space ( ).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a white space in the current stream.
@throws StreamAccessException If an error occurs while writing the white space. | [
"Write",
"a",
"white",
"space",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L283-L291 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeVariable | public function writeVariable($varname)
{
try {
$this->getStream()->write('$' . $varname);
} catch (StreamException $e) {
$msg = "An error occured while writing a variable reference.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeVariable($varname)
{
try {
$this->getStream()->write('$' . $varname);
} catch (StreamException $e) {
$msg = "An error occured while writing a variable reference.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeVariable",
"(",
"$",
"varname",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'$'",
".",
"$",
"varname",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a variable reference.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a variable reference in the current stream.
@param string $varname The name of the variable reference to write.
@throws StreamAccessException If an error occurs while writing the variable reference. | [
"Write",
"a",
"variable",
"reference",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L299-L307 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeObjectOperator | public function writeObjectOperator()
{
try {
$this->getStream()->write('->');
} catch (StreamException $e) {
$msg = "An error occured while writing an object operator (->).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeObjectOperator()
{
try {
$this->getStream()->write('->');
} catch (StreamException $e) {
$msg = "An error occured while writing an object operator (->).";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeObjectOperator",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'->'",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing an object operator (->).\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a object operator (->) in the current stream.
@throws StreamAccessException If an error occurs while writing the object operator. | [
"Write",
"a",
"object",
"operator",
"(",
"-",
">",
")",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L314-L322 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeFunctionCall | public function writeFunctionCall($funcname, PhpArgumentCollection $arguments = null)
{
try {
$this->getStream()->write($funcname);
$this->writeOpeningParenthesis();
if (is_null($arguments) === false) {
$this->writeArguments($arguments);
}
$this->writeClosingParenthesis();
} catch (StreamException $e) {
$msg = "An error occured while writing a function call.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeFunctionCall($funcname, PhpArgumentCollection $arguments = null)
{
try {
$this->getStream()->write($funcname);
$this->writeOpeningParenthesis();
if (is_null($arguments) === false) {
$this->writeArguments($arguments);
}
$this->writeClosingParenthesis();
} catch (StreamException $e) {
$msg = "An error occured while writing a function call.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeFunctionCall",
"(",
"$",
"funcname",
",",
"PhpArgumentCollection",
"$",
"arguments",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"$",
"funcname",
")",
";",
"$",
"this",
"->",
"writeOpeningParenthesis",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"arguments",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"writeArguments",
"(",
"$",
"arguments",
")",
";",
"}",
"$",
"this",
"->",
"writeClosingParenthesis",
"(",
")",
";",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a function call.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a function call in the current stream.
@param string $funcname The name of the function that has to be called.
@param PhpArgumentCollection $arguments A collection of PhpArgument objects representing the arguments to be given to the function call.
@throws StreamAccessException If an error occurs while writing the function call. | [
"Write",
"a",
"function",
"call",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L331-L346 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeMethodCall | public function writeMethodCall($objectname, $methodname, PhpArgumentCollection $arguments = null, $static = false)
{
try {
$this->writeVariable($objectname);
if ($static === false) {
$this->writeObjectOperator();
} else {
$this->writePaamayimNekudotayim();
}
$this->getStream()->write($methodname);
$this->writeOpeningParenthesis();
if (is_null($arguments) === false) {
$this->writeArguments($arguments);
}
$this->writeClosingParenthesis();
} catch (Exception $e) {
$msg = "An error occured while writing a method call.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeMethodCall($objectname, $methodname, PhpArgumentCollection $arguments = null, $static = false)
{
try {
$this->writeVariable($objectname);
if ($static === false) {
$this->writeObjectOperator();
} else {
$this->writePaamayimNekudotayim();
}
$this->getStream()->write($methodname);
$this->writeOpeningParenthesis();
if (is_null($arguments) === false) {
$this->writeArguments($arguments);
}
$this->writeClosingParenthesis();
} catch (Exception $e) {
$msg = "An error occured while writing a method call.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeMethodCall",
"(",
"$",
"objectname",
",",
"$",
"methodname",
",",
"PhpArgumentCollection",
"$",
"arguments",
"=",
"null",
",",
"$",
"static",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"writeVariable",
"(",
"$",
"objectname",
")",
";",
"if",
"(",
"$",
"static",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"writeObjectOperator",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"writePaamayimNekudotayim",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"$",
"methodname",
")",
";",
"$",
"this",
"->",
"writeOpeningParenthesis",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"arguments",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"writeArguments",
"(",
"$",
"arguments",
")",
";",
"}",
"$",
"this",
"->",
"writeClosingParenthesis",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a method call.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a method call in the current stream.
@param string $objectname The name of the variable where the object on which you want to call the method is stored e.g. 'foobar'.
@param string $methodname The name of the method you want to call.
@param PhpArgumentCollection $arguments A collection of PhpArgument objects.
@param boolean $static Whether or not the call is static.
@throws StreamAccessException If an error occurs while writing the method call. | [
"Write",
"a",
"method",
"call",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L357-L380 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeInstantiation | public function writeInstantiation($classname, PhpArgumentCollection $arguments = null)
{
try {
$this->writeNew();
$this->getStream()->write($classname);
$this->writeOpeningParenthesis();
if (is_null($arguments) === false) {
$this->writeArguments($arguments);
}
$this->writeClosingParenthesis();
} catch (Exception $e) {
$msg = "An error occured while writing an object instantiation.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeInstantiation($classname, PhpArgumentCollection $arguments = null)
{
try {
$this->writeNew();
$this->getStream()->write($classname);
$this->writeOpeningParenthesis();
if (is_null($arguments) === false) {
$this->writeArguments($arguments);
}
$this->writeClosingParenthesis();
} catch (Exception $e) {
$msg = "An error occured while writing an object instantiation.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeInstantiation",
"(",
"$",
"classname",
",",
"PhpArgumentCollection",
"$",
"arguments",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"writeNew",
"(",
")",
";",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"$",
"classname",
")",
";",
"$",
"this",
"->",
"writeOpeningParenthesis",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"arguments",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"writeArguments",
"(",
"$",
"arguments",
")",
";",
"}",
"$",
"this",
"->",
"writeClosingParenthesis",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing an object instantiation.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write the instantiation of a given $classname with some $arguments.
@param string $classname The name of the class to be instantiated. Fully qualified class names are supported.
@param PhpArgumentCollection $arguments A collection of PhpArgument objects. | [
"Write",
"the",
"instantiation",
"of",
"a",
"given",
"$classname",
"with",
"some",
"$arguments",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L407-L423 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeArguments | public function writeArguments(PhpArgumentCollection $arguments)
{
try {
$argsCount = count($arguments);
for ($i = 0; $i < $argsCount; $i++) {
$this->writeArgument($arguments[$i]);
if ($i < $argsCount - 1) {
$this->writeComma();
}
}
} catch (Exception $e) {
$msg = "An error occured while writing a sequence of arguments.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeArguments(PhpArgumentCollection $arguments)
{
try {
$argsCount = count($arguments);
for ($i = 0; $i < $argsCount; $i++) {
$this->writeArgument($arguments[$i]);
if ($i < $argsCount - 1) {
$this->writeComma();
}
}
} catch (Exception $e) {
$msg = "An error occured while writing a sequence of arguments.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeArguments",
"(",
"PhpArgumentCollection",
"$",
"arguments",
")",
"{",
"try",
"{",
"$",
"argsCount",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"argsCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"writeArgument",
"(",
"$",
"arguments",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"$",
"i",
"<",
"$",
"argsCount",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"writeComma",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing a sequence of arguments.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a sequence of arguments in the current stream.
@param PhpArgumentCollection $arguments A collection of PhpArgument objects.
@throws StreamAccessException If an error occurs while writing the sequence of arguments. | [
"Write",
"a",
"sequence",
"of",
"arguments",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L431-L448 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpStreamAccess.php | PhpStreamAccess.writeArgument | public function writeArgument(PhpArgument $argument)
{
try {
$value = $argument->getValue();
if ($argument->isVariableReference() === true) {
$this->getStream()->write('$' . $value->getName());
} else {
$this->writeScalar($value);
}
} catch (StreamException $e) {
$msg = "An error occured while writing an argument with value '${value}'.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | php | public function writeArgument(PhpArgument $argument)
{
try {
$value = $argument->getValue();
if ($argument->isVariableReference() === true) {
$this->getStream()->write('$' . $value->getName());
} else {
$this->writeScalar($value);
}
} catch (StreamException $e) {
$msg = "An error occured while writing an argument with value '${value}'.";
throw new StreamAccessException($msg, $this, 0, $e);
}
} | [
"public",
"function",
"writeArgument",
"(",
"PhpArgument",
"$",
"argument",
")",
"{",
"try",
"{",
"$",
"value",
"=",
"$",
"argument",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"argument",
"->",
"isVariableReference",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"write",
"(",
"'$'",
".",
"$",
"value",
"->",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"writeScalar",
"(",
"$",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"StreamException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while writing an argument with value '${value}'.\"",
";",
"throw",
"new",
"StreamAccessException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Write a PHP function/method argument in the current stream.
@param PhpArgument $argument A PhpArgument object.
@throws StreamAccessException If an error occurs while writing the PHP argument. | [
"Write",
"a",
"PHP",
"function",
"/",
"method",
"argument",
"in",
"the",
"current",
"stream",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpStreamAccess.php#L456-L470 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php | ExtendedAssessmentItemRefMarshaller.marshall | protected function marshall(QtiComponent $component)
{
$element = parent::marshall($component);
foreach ($component->getResponseDeclarations() as $responseDeclaration) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseDeclaration);
$element->appendChild($marshaller->marshall($responseDeclaration));
}
foreach ($component->getOutcomeDeclarations() as $outcomeDeclaration) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeDeclaration);
$element->appendChild($marshaller->marshall($outcomeDeclaration));
}
foreach ($component->getTemplateDeclarations() as $templateDeclaration) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($templateDeclaration);
$element->appendChild($marshaller->marshall($templateDeclaration));
}
if ($component->hasTemplateProcessing() === true) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($component->getTemplateProcessing());
$templProcElt = $marshaller->marshall($component->getTemplateProcessing());
$element->appendChild($templProcElt);
}
if ($component->hasResponseProcessing() === true) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($component->getResponseProcessing());
$respProcElt = $marshaller->marshall($component->getResponseProcessing());
$element->appendChild($respProcElt);
}
foreach ($component->getModalFeedbackRules() as $modalFeedbackRule) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($modalFeedbackRule);
$element->appendChild($marshaller->marshall($modalFeedbackRule));
}
foreach ($component->getShufflings() as $shuffling) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($shuffling);
$element->appendChild($marshaller->marshall($shuffling));
}
foreach ($component->getResponseValidityConstraints() as $responseValidityConstraint) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseValidityConstraint);
$element->appendChild($marshaller->marshall($responseValidityConstraint));
}
$this->setDOMElementAttribute($element, 'adaptive', $component->isAdaptive());
$this->setDOMElementAttribute($element, 'timeDependent', $component->isTimeDependent());
$endAttemptIdentifiers = $component->getEndAttemptIdentifiers();
if (count($endAttemptIdentifiers) > 0) {
$this->setDOMElementAttribute($element, 'endAttemptIdentifiers', implode("\x20", $endAttemptIdentifiers->getArrayCopy()));
}
return $element;
} | php | protected function marshall(QtiComponent $component)
{
$element = parent::marshall($component);
foreach ($component->getResponseDeclarations() as $responseDeclaration) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseDeclaration);
$element->appendChild($marshaller->marshall($responseDeclaration));
}
foreach ($component->getOutcomeDeclarations() as $outcomeDeclaration) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeDeclaration);
$element->appendChild($marshaller->marshall($outcomeDeclaration));
}
foreach ($component->getTemplateDeclarations() as $templateDeclaration) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($templateDeclaration);
$element->appendChild($marshaller->marshall($templateDeclaration));
}
if ($component->hasTemplateProcessing() === true) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($component->getTemplateProcessing());
$templProcElt = $marshaller->marshall($component->getTemplateProcessing());
$element->appendChild($templProcElt);
}
if ($component->hasResponseProcessing() === true) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($component->getResponseProcessing());
$respProcElt = $marshaller->marshall($component->getResponseProcessing());
$element->appendChild($respProcElt);
}
foreach ($component->getModalFeedbackRules() as $modalFeedbackRule) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($modalFeedbackRule);
$element->appendChild($marshaller->marshall($modalFeedbackRule));
}
foreach ($component->getShufflings() as $shuffling) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($shuffling);
$element->appendChild($marshaller->marshall($shuffling));
}
foreach ($component->getResponseValidityConstraints() as $responseValidityConstraint) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseValidityConstraint);
$element->appendChild($marshaller->marshall($responseValidityConstraint));
}
$this->setDOMElementAttribute($element, 'adaptive', $component->isAdaptive());
$this->setDOMElementAttribute($element, 'timeDependent', $component->isTimeDependent());
$endAttemptIdentifiers = $component->getEndAttemptIdentifiers();
if (count($endAttemptIdentifiers) > 0) {
$this->setDOMElementAttribute($element, 'endAttemptIdentifiers', implode("\x20", $endAttemptIdentifiers->getArrayCopy()));
}
return $element;
} | [
"protected",
"function",
"marshall",
"(",
"QtiComponent",
"$",
"component",
")",
"{",
"$",
"element",
"=",
"parent",
"::",
"marshall",
"(",
"$",
"component",
")",
";",
"foreach",
"(",
"$",
"component",
"->",
"getResponseDeclarations",
"(",
")",
"as",
"$",
"responseDeclaration",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"responseDeclaration",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"responseDeclaration",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"component",
"->",
"getOutcomeDeclarations",
"(",
")",
"as",
"$",
"outcomeDeclaration",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"outcomeDeclaration",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"outcomeDeclaration",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"component",
"->",
"getTemplateDeclarations",
"(",
")",
"as",
"$",
"templateDeclaration",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"templateDeclaration",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"templateDeclaration",
")",
")",
";",
"}",
"if",
"(",
"$",
"component",
"->",
"hasTemplateProcessing",
"(",
")",
"===",
"true",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"component",
"->",
"getTemplateProcessing",
"(",
")",
")",
";",
"$",
"templProcElt",
"=",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"component",
"->",
"getTemplateProcessing",
"(",
")",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"templProcElt",
")",
";",
"}",
"if",
"(",
"$",
"component",
"->",
"hasResponseProcessing",
"(",
")",
"===",
"true",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"component",
"->",
"getResponseProcessing",
"(",
")",
")",
";",
"$",
"respProcElt",
"=",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"component",
"->",
"getResponseProcessing",
"(",
")",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"respProcElt",
")",
";",
"}",
"foreach",
"(",
"$",
"component",
"->",
"getModalFeedbackRules",
"(",
")",
"as",
"$",
"modalFeedbackRule",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"modalFeedbackRule",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"modalFeedbackRule",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"component",
"->",
"getShufflings",
"(",
")",
"as",
"$",
"shuffling",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"shuffling",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"shuffling",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"component",
"->",
"getResponseValidityConstraints",
"(",
")",
"as",
"$",
"responseValidityConstraint",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"responseValidityConstraint",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"marshaller",
"->",
"marshall",
"(",
"$",
"responseValidityConstraint",
")",
")",
";",
"}",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'adaptive'",
",",
"$",
"component",
"->",
"isAdaptive",
"(",
")",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'timeDependent'",
",",
"$",
"component",
"->",
"isTimeDependent",
"(",
")",
")",
";",
"$",
"endAttemptIdentifiers",
"=",
"$",
"component",
"->",
"getEndAttemptIdentifiers",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"endAttemptIdentifiers",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'endAttemptIdentifiers'",
",",
"implode",
"(",
"\"\\x20\"",
",",
"$",
"endAttemptIdentifiers",
"->",
"getArrayCopy",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] | Marshall a ExtendedAssessmentItemRef object into its DOMElement representation.
@param \qtism\data\QtiComponent
@return \DOMElement The according DOMElement object. | [
"Marshall",
"a",
"ExtendedAssessmentItemRef",
"object",
"into",
"its",
"DOMElement",
"representation",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php#L50-L105 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php | ExtendedAssessmentItemRefMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
$baseComponent = parent::unmarshall($element);
$identifier = $baseComponent->getIdentifier();
$href = $baseComponent->getHref();
$compactAssessmentItemRef = new ExtendedAssessmentItemRef($identifier, $href);
$compactAssessmentItemRef->setRequired($baseComponent->isRequired());
$compactAssessmentItemRef->setFixed($baseComponent->isFixed());
$compactAssessmentItemRef->setPreConditions($baseComponent->getPreConditions());
$compactAssessmentItemRef->setBranchRules($baseComponent->getBranchRules());
$compactAssessmentItemRef->setItemSessionControl($baseComponent->getItemSessionControl());
$compactAssessmentItemRef->setTimeLimits($baseComponent->getTimeLimits());
$compactAssessmentItemRef->setTemplateDefaults($baseComponent->getTemplateDefaults());
$compactAssessmentItemRef->setWeights($baseComponent->getWeights());
$compactAssessmentItemRef->setVariableMappings($baseComponent->getVariableMappings());
$compactAssessmentItemRef->setCategories($baseComponent->getCategories());
// ResponseDeclarations.
$responseDeclarationElts = $this->getChildElementsByTagName($element, 'responseDeclaration');
$responseDeclarations = new ResponseDeclarationCollection();
foreach ($responseDeclarationElts as $responseDeclarationElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseDeclarationElt);
$responseDeclarations[] = $marshaller->unmarshall($responseDeclarationElt);
}
$compactAssessmentItemRef->setResponseDeclarations($responseDeclarations);
// OutcomeDeclarations.
$outcomeDeclarationElts = $this->getChildElementsByTagName($element, 'outcomeDeclaration');
$outcomeDeclarations = new OutcomeDeclarationCollection();
foreach ($outcomeDeclarationElts as $outcomeDeclarationElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeDeclarationElt);
$outcomeDeclarations[] = $marshaller->unmarshall($outcomeDeclarationElt);
}
$compactAssessmentItemRef->setOutcomeDeclarations($outcomeDeclarations);
// TemplateDeclarations.
$templateDeclarationElts = $this->getChildElementsByTagName($element, 'templateDeclaration');
$templateDeclarations = new TemplateDeclarationCollection();
foreach ($templateDeclarationElts as $templateDeclarationElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($templateDeclarationElt);
$templateDeclarations[] = $marshaller->unmarshall($templateDeclarationElt);
}
$compactAssessmentItemRef->setTemplateDeclarations($templateDeclarations);
// TemplateProcessing.
$templateProcessingElts = $this->getChildElementsByTagName($element, 'templateProcessing');
if (count($templateProcessingElts) === 1) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($templateProcessingElts[0]);
$compactAssessmentItemRef->setTemplateProcessing($marshaller->unmarshall($templateProcessingElts[0]));
}
// ResponseProcessing.
$responseProcessingElts = $this->getChildElementsByTagName($element, 'responseProcessing');
if (count($responseProcessingElts) === 1) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseProcessingElts[0]);
$compactAssessmentItemRef->setResponseProcessing($marshaller->unmarshall($responseProcessingElts[0]));
}
// ModalFeedbacks (transformed in ModalFeedbackRules).
$modalFeedbackElts = $this->getChildElementsByTagName($element, 'modalFeedbackRule');
$modalFeedbackRules = new ModalFeedbackRuleCollection();
foreach ($modalFeedbackElts as $modalFeedbackElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($modalFeedbackElt);
$modalFeedbackRules[] = $marshaller->unmarshall($modalFeedbackElt);
}
$compactAssessmentItemRef->setModalFeedbackRules($modalFeedbackRules);
// Shufflings.
$shufflingElts = $this->getChildElementsByTagName($element, 'shuffling');
$shufflings = new ShufflingCollection();
foreach ($shufflingElts as $shufflingElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($shufflingElt);
$shufflings[] = $marshaller->unmarshall($shufflingElt);
}
$compactAssessmentItemRef->setShufflings($shufflings);
// ResponseValidityConstraints.
$responseValidityConstraintElts = $this->getChildElementsByTagName($element, 'responseValidityConstraint');
$responseValidityConstraints = new ResponseValidityConstraintCollection();
foreach ($responseValidityConstraintElts as $responseValidityConstraintElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseValidityConstraintElt);
$responseValidityConstraints[] = $marshaller->unmarshall($responseValidityConstraintElt);
}
$compactAssessmentItemRef->setResponseValidityConstraints($responseValidityConstraints);
if (($adaptive = $this->getDOMElementAttributeAs($element, 'adaptive', 'boolean')) !== null) {
$compactAssessmentItemRef->setAdaptive($adaptive);
}
if (($timeDependent = $this->getDOMElementAttributeAs($element, 'timeDependent', 'boolean')) !== null) {
$compactAssessmentItemRef->setTimeDependent($timeDependent);
} else {
$msg = "The mandatory attribute 'timeDependent' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
if (($endAttemptIdentifiers = $this->getDOMElementAttributeAs($element, 'endAttemptIdentifiers')) !== null) {
$identifiersArray = explode("\x20", $endAttemptIdentifiers);
if (count($identifiersArray) > 0) {
$compactAssessmentItemRef->setEndAttemptIdentifiers(new IdentifierCollection($identifiersArray));
}
}
return $compactAssessmentItemRef;
} | php | protected function unmarshall(DOMElement $element)
{
$baseComponent = parent::unmarshall($element);
$identifier = $baseComponent->getIdentifier();
$href = $baseComponent->getHref();
$compactAssessmentItemRef = new ExtendedAssessmentItemRef($identifier, $href);
$compactAssessmentItemRef->setRequired($baseComponent->isRequired());
$compactAssessmentItemRef->setFixed($baseComponent->isFixed());
$compactAssessmentItemRef->setPreConditions($baseComponent->getPreConditions());
$compactAssessmentItemRef->setBranchRules($baseComponent->getBranchRules());
$compactAssessmentItemRef->setItemSessionControl($baseComponent->getItemSessionControl());
$compactAssessmentItemRef->setTimeLimits($baseComponent->getTimeLimits());
$compactAssessmentItemRef->setTemplateDefaults($baseComponent->getTemplateDefaults());
$compactAssessmentItemRef->setWeights($baseComponent->getWeights());
$compactAssessmentItemRef->setVariableMappings($baseComponent->getVariableMappings());
$compactAssessmentItemRef->setCategories($baseComponent->getCategories());
// ResponseDeclarations.
$responseDeclarationElts = $this->getChildElementsByTagName($element, 'responseDeclaration');
$responseDeclarations = new ResponseDeclarationCollection();
foreach ($responseDeclarationElts as $responseDeclarationElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseDeclarationElt);
$responseDeclarations[] = $marshaller->unmarshall($responseDeclarationElt);
}
$compactAssessmentItemRef->setResponseDeclarations($responseDeclarations);
// OutcomeDeclarations.
$outcomeDeclarationElts = $this->getChildElementsByTagName($element, 'outcomeDeclaration');
$outcomeDeclarations = new OutcomeDeclarationCollection();
foreach ($outcomeDeclarationElts as $outcomeDeclarationElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeDeclarationElt);
$outcomeDeclarations[] = $marshaller->unmarshall($outcomeDeclarationElt);
}
$compactAssessmentItemRef->setOutcomeDeclarations($outcomeDeclarations);
// TemplateDeclarations.
$templateDeclarationElts = $this->getChildElementsByTagName($element, 'templateDeclaration');
$templateDeclarations = new TemplateDeclarationCollection();
foreach ($templateDeclarationElts as $templateDeclarationElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($templateDeclarationElt);
$templateDeclarations[] = $marshaller->unmarshall($templateDeclarationElt);
}
$compactAssessmentItemRef->setTemplateDeclarations($templateDeclarations);
// TemplateProcessing.
$templateProcessingElts = $this->getChildElementsByTagName($element, 'templateProcessing');
if (count($templateProcessingElts) === 1) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($templateProcessingElts[0]);
$compactAssessmentItemRef->setTemplateProcessing($marshaller->unmarshall($templateProcessingElts[0]));
}
// ResponseProcessing.
$responseProcessingElts = $this->getChildElementsByTagName($element, 'responseProcessing');
if (count($responseProcessingElts) === 1) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseProcessingElts[0]);
$compactAssessmentItemRef->setResponseProcessing($marshaller->unmarshall($responseProcessingElts[0]));
}
// ModalFeedbacks (transformed in ModalFeedbackRules).
$modalFeedbackElts = $this->getChildElementsByTagName($element, 'modalFeedbackRule');
$modalFeedbackRules = new ModalFeedbackRuleCollection();
foreach ($modalFeedbackElts as $modalFeedbackElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($modalFeedbackElt);
$modalFeedbackRules[] = $marshaller->unmarshall($modalFeedbackElt);
}
$compactAssessmentItemRef->setModalFeedbackRules($modalFeedbackRules);
// Shufflings.
$shufflingElts = $this->getChildElementsByTagName($element, 'shuffling');
$shufflings = new ShufflingCollection();
foreach ($shufflingElts as $shufflingElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($shufflingElt);
$shufflings[] = $marshaller->unmarshall($shufflingElt);
}
$compactAssessmentItemRef->setShufflings($shufflings);
// ResponseValidityConstraints.
$responseValidityConstraintElts = $this->getChildElementsByTagName($element, 'responseValidityConstraint');
$responseValidityConstraints = new ResponseValidityConstraintCollection();
foreach ($responseValidityConstraintElts as $responseValidityConstraintElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($responseValidityConstraintElt);
$responseValidityConstraints[] = $marshaller->unmarshall($responseValidityConstraintElt);
}
$compactAssessmentItemRef->setResponseValidityConstraints($responseValidityConstraints);
if (($adaptive = $this->getDOMElementAttributeAs($element, 'adaptive', 'boolean')) !== null) {
$compactAssessmentItemRef->setAdaptive($adaptive);
}
if (($timeDependent = $this->getDOMElementAttributeAs($element, 'timeDependent', 'boolean')) !== null) {
$compactAssessmentItemRef->setTimeDependent($timeDependent);
} else {
$msg = "The mandatory attribute 'timeDependent' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
if (($endAttemptIdentifiers = $this->getDOMElementAttributeAs($element, 'endAttemptIdentifiers')) !== null) {
$identifiersArray = explode("\x20", $endAttemptIdentifiers);
if (count($identifiersArray) > 0) {
$compactAssessmentItemRef->setEndAttemptIdentifiers(new IdentifierCollection($identifiersArray));
}
}
return $compactAssessmentItemRef;
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"baseComponent",
"=",
"parent",
"::",
"unmarshall",
"(",
"$",
"element",
")",
";",
"$",
"identifier",
"=",
"$",
"baseComponent",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"href",
"=",
"$",
"baseComponent",
"->",
"getHref",
"(",
")",
";",
"$",
"compactAssessmentItemRef",
"=",
"new",
"ExtendedAssessmentItemRef",
"(",
"$",
"identifier",
",",
"$",
"href",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setRequired",
"(",
"$",
"baseComponent",
"->",
"isRequired",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setFixed",
"(",
"$",
"baseComponent",
"->",
"isFixed",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setPreConditions",
"(",
"$",
"baseComponent",
"->",
"getPreConditions",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setBranchRules",
"(",
"$",
"baseComponent",
"->",
"getBranchRules",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setItemSessionControl",
"(",
"$",
"baseComponent",
"->",
"getItemSessionControl",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setTimeLimits",
"(",
"$",
"baseComponent",
"->",
"getTimeLimits",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setTemplateDefaults",
"(",
"$",
"baseComponent",
"->",
"getTemplateDefaults",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setWeights",
"(",
"$",
"baseComponent",
"->",
"getWeights",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setVariableMappings",
"(",
"$",
"baseComponent",
"->",
"getVariableMappings",
"(",
")",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setCategories",
"(",
"$",
"baseComponent",
"->",
"getCategories",
"(",
")",
")",
";",
"// ResponseDeclarations.",
"$",
"responseDeclarationElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'responseDeclaration'",
")",
";",
"$",
"responseDeclarations",
"=",
"new",
"ResponseDeclarationCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"responseDeclarationElts",
"as",
"$",
"responseDeclarationElt",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"responseDeclarationElt",
")",
";",
"$",
"responseDeclarations",
"[",
"]",
"=",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"responseDeclarationElt",
")",
";",
"}",
"$",
"compactAssessmentItemRef",
"->",
"setResponseDeclarations",
"(",
"$",
"responseDeclarations",
")",
";",
"// OutcomeDeclarations.",
"$",
"outcomeDeclarationElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'outcomeDeclaration'",
")",
";",
"$",
"outcomeDeclarations",
"=",
"new",
"OutcomeDeclarationCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"outcomeDeclarationElts",
"as",
"$",
"outcomeDeclarationElt",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"outcomeDeclarationElt",
")",
";",
"$",
"outcomeDeclarations",
"[",
"]",
"=",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"outcomeDeclarationElt",
")",
";",
"}",
"$",
"compactAssessmentItemRef",
"->",
"setOutcomeDeclarations",
"(",
"$",
"outcomeDeclarations",
")",
";",
"// TemplateDeclarations.",
"$",
"templateDeclarationElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'templateDeclaration'",
")",
";",
"$",
"templateDeclarations",
"=",
"new",
"TemplateDeclarationCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"templateDeclarationElts",
"as",
"$",
"templateDeclarationElt",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"templateDeclarationElt",
")",
";",
"$",
"templateDeclarations",
"[",
"]",
"=",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"templateDeclarationElt",
")",
";",
"}",
"$",
"compactAssessmentItemRef",
"->",
"setTemplateDeclarations",
"(",
"$",
"templateDeclarations",
")",
";",
"// TemplateProcessing.",
"$",
"templateProcessingElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'templateProcessing'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"templateProcessingElts",
")",
"===",
"1",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"templateProcessingElts",
"[",
"0",
"]",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setTemplateProcessing",
"(",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"templateProcessingElts",
"[",
"0",
"]",
")",
")",
";",
"}",
"// ResponseProcessing.",
"$",
"responseProcessingElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'responseProcessing'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"responseProcessingElts",
")",
"===",
"1",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"responseProcessingElts",
"[",
"0",
"]",
")",
";",
"$",
"compactAssessmentItemRef",
"->",
"setResponseProcessing",
"(",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"responseProcessingElts",
"[",
"0",
"]",
")",
")",
";",
"}",
"// ModalFeedbacks (transformed in ModalFeedbackRules).",
"$",
"modalFeedbackElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'modalFeedbackRule'",
")",
";",
"$",
"modalFeedbackRules",
"=",
"new",
"ModalFeedbackRuleCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"modalFeedbackElts",
"as",
"$",
"modalFeedbackElt",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"modalFeedbackElt",
")",
";",
"$",
"modalFeedbackRules",
"[",
"]",
"=",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"modalFeedbackElt",
")",
";",
"}",
"$",
"compactAssessmentItemRef",
"->",
"setModalFeedbackRules",
"(",
"$",
"modalFeedbackRules",
")",
";",
"// Shufflings.",
"$",
"shufflingElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'shuffling'",
")",
";",
"$",
"shufflings",
"=",
"new",
"ShufflingCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"shufflingElts",
"as",
"$",
"shufflingElt",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"shufflingElt",
")",
";",
"$",
"shufflings",
"[",
"]",
"=",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"shufflingElt",
")",
";",
"}",
"$",
"compactAssessmentItemRef",
"->",
"setShufflings",
"(",
"$",
"shufflings",
")",
";",
"// ResponseValidityConstraints.",
"$",
"responseValidityConstraintElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'responseValidityConstraint'",
")",
";",
"$",
"responseValidityConstraints",
"=",
"new",
"ResponseValidityConstraintCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"responseValidityConstraintElts",
"as",
"$",
"responseValidityConstraintElt",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"responseValidityConstraintElt",
")",
";",
"$",
"responseValidityConstraints",
"[",
"]",
"=",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"responseValidityConstraintElt",
")",
";",
"}",
"$",
"compactAssessmentItemRef",
"->",
"setResponseValidityConstraints",
"(",
"$",
"responseValidityConstraints",
")",
";",
"if",
"(",
"(",
"$",
"adaptive",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'adaptive'",
",",
"'boolean'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"compactAssessmentItemRef",
"->",
"setAdaptive",
"(",
"$",
"adaptive",
")",
";",
"}",
"if",
"(",
"(",
"$",
"timeDependent",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'timeDependent'",
",",
"'boolean'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"compactAssessmentItemRef",
"->",
"setTimeDependent",
"(",
"$",
"timeDependent",
")",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The mandatory attribute 'timeDependent' is missing from element '\"",
".",
"$",
"element",
"->",
"localName",
".",
"\"'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"if",
"(",
"(",
"$",
"endAttemptIdentifiers",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'endAttemptIdentifiers'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"identifiersArray",
"=",
"explode",
"(",
"\"\\x20\"",
",",
"$",
"endAttemptIdentifiers",
")",
";",
"if",
"(",
"count",
"(",
"$",
"identifiersArray",
")",
">",
"0",
")",
"{",
"$",
"compactAssessmentItemRef",
"->",
"setEndAttemptIdentifiers",
"(",
"new",
"IdentifierCollection",
"(",
"$",
"identifiersArray",
")",
")",
";",
"}",
"}",
"return",
"$",
"compactAssessmentItemRef",
";",
"}"
] | Unmarshall an extended version of an assessmentItemRef DOMElement into
a ExtendedAssessmentItemRef object.
@param \DOMElement $element
@return \qtism\data\ExtendedAssessmentItemRef A ExtendedAssessmentItemRef object. | [
"Unmarshall",
"an",
"extended",
"version",
"of",
"an",
"assessmentItemRef",
"DOMElement",
"into",
"a",
"ExtendedAssessmentItemRef",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php#L114-L219 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/BrMarshaller.php | BrMarshaller.marshall | protected function marshall(QtiComponent $component)
{
$element = self::getDOMCradle()->createElement('br');
if ($component->hasXmlBase() === true) {
self::setXmlBase($element, $component->setXmlBase());
}
$this->fillElement($element, $component);
return $element;
} | php | protected function marshall(QtiComponent $component)
{
$element = self::getDOMCradle()->createElement('br');
if ($component->hasXmlBase() === true) {
self::setXmlBase($element, $component->setXmlBase());
}
$this->fillElement($element, $component);
return $element;
} | [
"protected",
"function",
"marshall",
"(",
"QtiComponent",
"$",
"component",
")",
"{",
"$",
"element",
"=",
"self",
"::",
"getDOMCradle",
"(",
")",
"->",
"createElement",
"(",
"'br'",
")",
";",
"if",
"(",
"$",
"component",
"->",
"hasXmlBase",
"(",
")",
"===",
"true",
")",
"{",
"self",
"::",
"setXmlBase",
"(",
"$",
"element",
",",
"$",
"component",
"->",
"setXmlBase",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"fillElement",
"(",
"$",
"element",
",",
"$",
"component",
")",
";",
"return",
"$",
"element",
";",
"}"
] | Marshall a Br object into a DOMElement object.
@param \qtism\data\QtiComponent $component A Br object.
@return \DOMElement The according DOMElement object.
@throws \qtism\data\storage\xml\marshalling\MarshallingException | [
"Marshall",
"a",
"Br",
"object",
"into",
"a",
"DOMElement",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/BrMarshaller.php#L44-L55 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/BrMarshaller.php | BrMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
$component = new Br();
if (($xmlBase = self::getXmlBase($element)) !== false) {
$component->setXmlBase($xmlBase);
}
$this->fillBodyElement($component, $element);
return $component;
} | php | protected function unmarshall(DOMElement $element)
{
$component = new Br();
if (($xmlBase = self::getXmlBase($element)) !== false) {
$component->setXmlBase($xmlBase);
}
$this->fillBodyElement($component, $element);
return $component;
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"component",
"=",
"new",
"Br",
"(",
")",
";",
"if",
"(",
"(",
"$",
"xmlBase",
"=",
"self",
"::",
"getXmlBase",
"(",
"$",
"element",
")",
")",
"!==",
"false",
")",
"{",
"$",
"component",
"->",
"setXmlBase",
"(",
"$",
"xmlBase",
")",
";",
"}",
"$",
"this",
"->",
"fillBodyElement",
"(",
"$",
"component",
",",
"$",
"element",
")",
";",
"return",
"$",
"component",
";",
"}"
] | Unmarshall a DOMElement object corresponding to an XHTML br element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent A Br object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"an",
"XHTML",
"br",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/BrMarshaller.php#L64-L75 |
oat-sa/qti-sdk | src/qtism/data/expressions/operators/PatternMatch.php | PatternMatch.setPattern | public function setPattern($pattern)
{
if (gettype($pattern) === 'string') {
$this->pattern = $pattern;
} else {
$msg = "The pattern argument must be a string or a variable reference, '" . $pattern . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setPattern($pattern)
{
if (gettype($pattern) === 'string') {
$this->pattern = $pattern;
} else {
$msg = "The pattern argument must be a string or a variable reference, '" . $pattern . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setPattern",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"gettype",
"(",
"$",
"pattern",
")",
"===",
"'string'",
")",
"{",
"$",
"this",
"->",
"pattern",
"=",
"$",
"pattern",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The pattern argument must be a string or a variable reference, '\"",
".",
"$",
"pattern",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the pattern to match.
@param string $pattern A pattern or a variable reference.
@throws \InvalidArgumentException If $pattern is not a string value. | [
"Set",
"the",
"pattern",
"to",
"match",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/expressions/operators/PatternMatch.php#L72-L80 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php | PositionObjectInteractionMarshaller.marshall | protected function marshall(QtiComponent $component)
{
$version = $this->getVersion();
$element = $this->createElement($component);
$element->appendChild($this->getMarshallerFactory()->createMarshaller($component->getObject())->marshall($component->getObject()));
$this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
if ($component->getMaxChoices() > 0) {
$this->setDOMElementAttribute($element, 'maxChoices', $component->getMaxChoices());
}
if (Version::compare($version, '2.1.0', '>=') === true && $component->hasMinChoices() === true) {
$this->setDOMElementAttribute($element, 'minChoices', $component->getMinChoices());
}
if ($component->hasCenterPoint() === true) {
$centerPoint = $component->getCenterPoint();
$this->setDOMElementAttribute($element, 'centerPoint', $centerPoint->getX() . " " . $centerPoint->getY());
}
$this->fillElement($element, $component);
return $element;
} | php | protected function marshall(QtiComponent $component)
{
$version = $this->getVersion();
$element = $this->createElement($component);
$element->appendChild($this->getMarshallerFactory()->createMarshaller($component->getObject())->marshall($component->getObject()));
$this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
if ($component->getMaxChoices() > 0) {
$this->setDOMElementAttribute($element, 'maxChoices', $component->getMaxChoices());
}
if (Version::compare($version, '2.1.0', '>=') === true && $component->hasMinChoices() === true) {
$this->setDOMElementAttribute($element, 'minChoices', $component->getMinChoices());
}
if ($component->hasCenterPoint() === true) {
$centerPoint = $component->getCenterPoint();
$this->setDOMElementAttribute($element, 'centerPoint', $centerPoint->getX() . " " . $centerPoint->getY());
}
$this->fillElement($element, $component);
return $element;
} | [
"protected",
"function",
"marshall",
"(",
"QtiComponent",
"$",
"component",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"$",
"element",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"component",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"component",
"->",
"getObject",
"(",
")",
")",
"->",
"marshall",
"(",
"$",
"component",
"->",
"getObject",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'responseIdentifier'",
",",
"$",
"component",
"->",
"getResponseIdentifier",
"(",
")",
")",
";",
"if",
"(",
"$",
"component",
"->",
"getMaxChoices",
"(",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'maxChoices'",
",",
"$",
"component",
"->",
"getMaxChoices",
"(",
")",
")",
";",
"}",
"if",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.1.0'",
",",
"'>='",
")",
"===",
"true",
"&&",
"$",
"component",
"->",
"hasMinChoices",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'minChoices'",
",",
"$",
"component",
"->",
"getMinChoices",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"component",
"->",
"hasCenterPoint",
"(",
")",
"===",
"true",
")",
"{",
"$",
"centerPoint",
"=",
"$",
"component",
"->",
"getCenterPoint",
"(",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'centerPoint'",
",",
"$",
"centerPoint",
"->",
"getX",
"(",
")",
".",
"\" \"",
".",
"$",
"centerPoint",
"->",
"getY",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"fillElement",
"(",
"$",
"element",
",",
"$",
"component",
")",
";",
"return",
"$",
"element",
";",
"}"
] | Marshall an PositionObjectInteraction object into a DOMElement object.
@param \qtism\data\QtiComponent $component A PositionObjectInteraction object.
@return \DOMElement The according DOMElement object.
@throws \qtism\data\storage\xml\marshalling\MarshallingException | [
"Marshall",
"an",
"PositionObjectInteraction",
"object",
"into",
"a",
"DOMElement",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php#L47-L70 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php | PositionObjectInteractionMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
$version = $this->getVersion();
if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {
$objectElts = $this->getChildElementsByTagName($element, 'object');
if (count($objectElts) > 0) {
$object = $this->getMarshallerFactory()->createMarshaller($objectElts[0])->unmarshall($objectElts[0]);
$component = new PositionObjectInteraction($responseIdentifier, $object);
if (($maxChoices = $this->getDOMElementAttributeAs($element, 'maxChoices', 'integer')) !== null) {
$component->setMaxChoices($maxChoices);
}
if (Version::compare($version, '2.1.0', '>=') === true && ($minChoices = $this->getDOMElementAttributeAs($element, 'minChoices', 'integer')) !== null) {
$component->setMinChoices($minChoices);
}
if (($centerPoint = $this->getDOMElementAttributeAs($element, 'centerPoint')) !== null) {
$points = explode("\x20", $centerPoint);
$pointsCount = count($points);
if ($pointsCount === 2) {
if (Format::isInteger($points[0]) === true) {
if (Format::isInteger($points[1]) === true) {
$component->setCenterPoint(new QtiPoint(intval($points[0]), intval($points[1])));
} else {
$msg = "The 2nd integer of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.";
throw new UnmarshallingException($msg, $element);
}
} else {
$msg = "The 1st value of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.";
throw new UnmarshallingException($msg, $element);
}
} else {
$msg = "The value of the 'centePoint' attribute of a 'positionObjectInteraction' element must be composed of exactly 2 integer values, ${pointsCount} given.";
throw new UnmarshallingException($msg, $element);
}
}
$this->fillBodyElement($component, $element);
return $component;
} else {
$msg = "A 'positionObjectInteraction' element must contain exactly one 'object' element, none given.";
throw new UnmarshallingException($msg, $element);
}
} else {
$msg = "The mandatory 'responseIdentifier' attribute is missing from the 'positionObjectInteraction' object.";
throw new UnmarshallingException($msg, $element);
}
} | php | protected function unmarshall(DOMElement $element)
{
$version = $this->getVersion();
if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {
$objectElts = $this->getChildElementsByTagName($element, 'object');
if (count($objectElts) > 0) {
$object = $this->getMarshallerFactory()->createMarshaller($objectElts[0])->unmarshall($objectElts[0]);
$component = new PositionObjectInteraction($responseIdentifier, $object);
if (($maxChoices = $this->getDOMElementAttributeAs($element, 'maxChoices', 'integer')) !== null) {
$component->setMaxChoices($maxChoices);
}
if (Version::compare($version, '2.1.0', '>=') === true && ($minChoices = $this->getDOMElementAttributeAs($element, 'minChoices', 'integer')) !== null) {
$component->setMinChoices($minChoices);
}
if (($centerPoint = $this->getDOMElementAttributeAs($element, 'centerPoint')) !== null) {
$points = explode("\x20", $centerPoint);
$pointsCount = count($points);
if ($pointsCount === 2) {
if (Format::isInteger($points[0]) === true) {
if (Format::isInteger($points[1]) === true) {
$component->setCenterPoint(new QtiPoint(intval($points[0]), intval($points[1])));
} else {
$msg = "The 2nd integer of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.";
throw new UnmarshallingException($msg, $element);
}
} else {
$msg = "The 1st value of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.";
throw new UnmarshallingException($msg, $element);
}
} else {
$msg = "The value of the 'centePoint' attribute of a 'positionObjectInteraction' element must be composed of exactly 2 integer values, ${pointsCount} given.";
throw new UnmarshallingException($msg, $element);
}
}
$this->fillBodyElement($component, $element);
return $component;
} else {
$msg = "A 'positionObjectInteraction' element must contain exactly one 'object' element, none given.";
throw new UnmarshallingException($msg, $element);
}
} else {
$msg = "The mandatory 'responseIdentifier' attribute is missing from the 'positionObjectInteraction' object.";
throw new UnmarshallingException($msg, $element);
}
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"(",
"$",
"responseIdentifier",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'responseIdentifier'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"objectElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'object'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"objectElts",
")",
">",
"0",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"objectElts",
"[",
"0",
"]",
")",
"->",
"unmarshall",
"(",
"$",
"objectElts",
"[",
"0",
"]",
")",
";",
"$",
"component",
"=",
"new",
"PositionObjectInteraction",
"(",
"$",
"responseIdentifier",
",",
"$",
"object",
")",
";",
"if",
"(",
"(",
"$",
"maxChoices",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'maxChoices'",
",",
"'integer'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"component",
"->",
"setMaxChoices",
"(",
"$",
"maxChoices",
")",
";",
"}",
"if",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.1.0'",
",",
"'>='",
")",
"===",
"true",
"&&",
"(",
"$",
"minChoices",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'minChoices'",
",",
"'integer'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"component",
"->",
"setMinChoices",
"(",
"$",
"minChoices",
")",
";",
"}",
"if",
"(",
"(",
"$",
"centerPoint",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'centerPoint'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"points",
"=",
"explode",
"(",
"\"\\x20\"",
",",
"$",
"centerPoint",
")",
";",
"$",
"pointsCount",
"=",
"count",
"(",
"$",
"points",
")",
";",
"if",
"(",
"$",
"pointsCount",
"===",
"2",
")",
"{",
"if",
"(",
"Format",
"::",
"isInteger",
"(",
"$",
"points",
"[",
"0",
"]",
")",
"===",
"true",
")",
"{",
"if",
"(",
"Format",
"::",
"isInteger",
"(",
"$",
"points",
"[",
"1",
"]",
")",
"===",
"true",
")",
"{",
"$",
"component",
"->",
"setCenterPoint",
"(",
"new",
"QtiPoint",
"(",
"intval",
"(",
"$",
"points",
"[",
"0",
"]",
")",
",",
"intval",
"(",
"$",
"points",
"[",
"1",
"]",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 2nd integer of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 1st value of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The value of the 'centePoint' attribute of a 'positionObjectInteraction' element must be composed of exactly 2 integer values, ${pointsCount} given.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}",
"$",
"this",
"->",
"fillBodyElement",
"(",
"$",
"component",
",",
"$",
"element",
")",
";",
"return",
"$",
"component",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"A 'positionObjectInteraction' element must contain exactly one 'object' element, none given.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The mandatory 'responseIdentifier' attribute is missing from the 'positionObjectInteraction' object.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}"
] | Unmarshall a DOMElement object corresponding to an positionObjectInteraction element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent A PositionObjectInteraction object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"an",
"positionObjectInteraction",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php#L79-L134 |
oat-sa/qti-sdk | src/qtism/runtime/rules/TemplateConstraintProcessor.php | TemplateConstraintProcessor.process | public function process()
{
$state = $this->getState();
$rule = $this->getRule();
$expr = $rule->getExpression();
$expressionEngine = new ExpressionEngine($expr, $state);
$val = $expressionEngine->process();
if (Utils::isNull($val) || $val->getValue() === false) {
$msg = "Unsatisfied Template Constraint.";
throw new RuleProcessingException($msg, $this, RuleProcessingException::TEMPLATE_CONSTRAINT_UNSATISFIED);
}
} | php | public function process()
{
$state = $this->getState();
$rule = $this->getRule();
$expr = $rule->getExpression();
$expressionEngine = new ExpressionEngine($expr, $state);
$val = $expressionEngine->process();
if (Utils::isNull($val) || $val->getValue() === false) {
$msg = "Unsatisfied Template Constraint.";
throw new RuleProcessingException($msg, $this, RuleProcessingException::TEMPLATE_CONSTRAINT_UNSATISFIED);
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"state",
"=",
"$",
"this",
"->",
"getState",
"(",
")",
";",
"$",
"rule",
"=",
"$",
"this",
"->",
"getRule",
"(",
")",
";",
"$",
"expr",
"=",
"$",
"rule",
"->",
"getExpression",
"(",
")",
";",
"$",
"expressionEngine",
"=",
"new",
"ExpressionEngine",
"(",
"$",
"expr",
",",
"$",
"state",
")",
";",
"$",
"val",
"=",
"$",
"expressionEngine",
"->",
"process",
"(",
")",
";",
"if",
"(",
"Utils",
"::",
"isNull",
"(",
"$",
"val",
")",
"||",
"$",
"val",
"->",
"getValue",
"(",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"Unsatisfied Template Constraint.\"",
";",
"throw",
"new",
"RuleProcessingException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"RuleProcessingException",
"::",
"TEMPLATE_CONSTRAINT_UNSATISFIED",
")",
";",
"}",
"}"
] | Process the TemplateConstraint rule. It simply throws a RuleProcessingException with
the special code RuleProcessingException::TEMPLATE_CONSTRAINT_UNSATISFIED to warn client
code that the expression related to the constraint returned false or null.
@throws \qtism\runtime\rules\RuleProcessingException with code = RuleProcessingException::TEMPLATE_CONSTRAINT_UNSATISFIED. | [
"Process",
"the",
"TemplateConstraint",
"rule",
".",
"It",
"simply",
"throws",
"a",
"RuleProcessingException",
"with",
"the",
"special",
"code",
"RuleProcessingException",
"::",
"TEMPLATE_CONSTRAINT_UNSATISFIED",
"to",
"warn",
"client",
"code",
"that",
"the",
"expression",
"related",
"to",
"the",
"constraint",
"returned",
"false",
"or",
"null",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/rules/TemplateConstraintProcessor.php#L67-L80 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/AreaMappingMarshaller.php | AreaMappingMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
$areaMapEntries = new AreaMapEntryCollection();
$areaMapEntryElts = $this->getChildElementsByTagName($element, 'areaMapEntry');
foreach ($areaMapEntryElts as $areaMapEntryElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($areaMapEntryElt);
$areaMapEntries[] = $marshaller->unmarshall($areaMapEntryElt);
}
$object = new AreaMapping($areaMapEntries);
if (($defaultValue = $this->getDOMElementAttributeAs($element, 'defaultValue', 'float')) !== null) {
$object->setDefaultValue($defaultValue);
}
if (($lowerBound = $this->getDOMElementAttributeAs($element, 'lowerBound', 'float')) !== null) {
$object->setLowerBound($lowerBound);
}
if (($upperBound = $this->getDOMElementAttributeAs($element, 'upperBound', 'float')) !== null) {
$object->setUpperBound($upperBound);
}
return $object;
} | php | protected function unmarshall(DOMElement $element)
{
$areaMapEntries = new AreaMapEntryCollection();
$areaMapEntryElts = $this->getChildElementsByTagName($element, 'areaMapEntry');
foreach ($areaMapEntryElts as $areaMapEntryElt) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($areaMapEntryElt);
$areaMapEntries[] = $marshaller->unmarshall($areaMapEntryElt);
}
$object = new AreaMapping($areaMapEntries);
if (($defaultValue = $this->getDOMElementAttributeAs($element, 'defaultValue', 'float')) !== null) {
$object->setDefaultValue($defaultValue);
}
if (($lowerBound = $this->getDOMElementAttributeAs($element, 'lowerBound', 'float')) !== null) {
$object->setLowerBound($lowerBound);
}
if (($upperBound = $this->getDOMElementAttributeAs($element, 'upperBound', 'float')) !== null) {
$object->setUpperBound($upperBound);
}
return $object;
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"areaMapEntries",
"=",
"new",
"AreaMapEntryCollection",
"(",
")",
";",
"$",
"areaMapEntryElts",
"=",
"$",
"this",
"->",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"'areaMapEntry'",
")",
";",
"foreach",
"(",
"$",
"areaMapEntryElts",
"as",
"$",
"areaMapEntryElt",
")",
"{",
"$",
"marshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"areaMapEntryElt",
")",
";",
"$",
"areaMapEntries",
"[",
"]",
"=",
"$",
"marshaller",
"->",
"unmarshall",
"(",
"$",
"areaMapEntryElt",
")",
";",
"}",
"$",
"object",
"=",
"new",
"AreaMapping",
"(",
"$",
"areaMapEntries",
")",
";",
"if",
"(",
"(",
"$",
"defaultValue",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'defaultValue'",
",",
"'float'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"object",
"->",
"setDefaultValue",
"(",
"$",
"defaultValue",
")",
";",
"}",
"if",
"(",
"(",
"$",
"lowerBound",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'lowerBound'",
",",
"'float'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"object",
"->",
"setLowerBound",
"(",
"$",
"lowerBound",
")",
";",
"}",
"if",
"(",
"(",
"$",
"upperBound",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'upperBound'",
",",
"'float'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"object",
"->",
"setUpperBound",
"(",
"$",
"upperBound",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] | Unmarshall a DOMElement object corresponding to a QTI areaMapping element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent An AreaMapping object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"a",
"QTI",
"areaMapping",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/AreaMappingMarshaller.php#L75-L100 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php | EndAttemptInteractionMarshaller.marshall | protected function marshall(QtiComponent $component)
{
$element = $this->createElement($component);
$this->fillElement($element, $component);
$this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
$this->setDOMElementAttribute($element, 'title', $component->getTitle());
if ($component->hasXmlBase() === true) {
self::setXmlBase($element, $component->getXmlBase());
}
return $element;
} | php | protected function marshall(QtiComponent $component)
{
$element = $this->createElement($component);
$this->fillElement($element, $component);
$this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
$this->setDOMElementAttribute($element, 'title', $component->getTitle());
if ($component->hasXmlBase() === true) {
self::setXmlBase($element, $component->getXmlBase());
}
return $element;
} | [
"protected",
"function",
"marshall",
"(",
"QtiComponent",
"$",
"component",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"createElement",
"(",
"$",
"component",
")",
";",
"$",
"this",
"->",
"fillElement",
"(",
"$",
"element",
",",
"$",
"component",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'responseIdentifier'",
",",
"$",
"component",
"->",
"getResponseIdentifier",
"(",
")",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'title'",
",",
"$",
"component",
"->",
"getTitle",
"(",
")",
")",
";",
"if",
"(",
"$",
"component",
"->",
"hasXmlBase",
"(",
")",
"===",
"true",
")",
"{",
"self",
"::",
"setXmlBase",
"(",
"$",
"element",
",",
"$",
"component",
"->",
"getXmlBase",
"(",
")",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] | Marshall an EndAttemptInteraction object into a DOMElement object.
@param \qtism\data\QtiComponent $component An EndAttemptInteraction object.
@return \DOMElement The according DOMElement object.
@throws \qtism\data\storage\xml\marshalling\MarshallingException | [
"Marshall",
"an",
"EndAttemptInteraction",
"object",
"into",
"a",
"DOMElement",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php#L44-L56 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php | EndAttemptInteractionMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {
if (($title = $this->getDOMElementAttributeAs($element, 'title')) === null) {
// The XSD does not restrict to an empty string, we then consider
// the title as an empty string ('').
$title = '';
}
$component = new EndAttemptInteraction($responseIdentifier, $title);
if (($xmlBase = self::getXmlBase($element)) !== false) {
$component->setXmlBase($xmlBase);
}
$this->fillBodyElement($component, $element);
return $component;
} else {
$msg = "The mandatory 'responseIdentifier' attribute is missing from the 'endAttemptInteraction' element.";
throw new UnmarshallingException($msg, $element);
}
} | php | protected function unmarshall(DOMElement $element)
{
if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {
if (($title = $this->getDOMElementAttributeAs($element, 'title')) === null) {
// The XSD does not restrict to an empty string, we then consider
// the title as an empty string ('').
$title = '';
}
$component = new EndAttemptInteraction($responseIdentifier, $title);
if (($xmlBase = self::getXmlBase($element)) !== false) {
$component->setXmlBase($xmlBase);
}
$this->fillBodyElement($component, $element);
return $component;
} else {
$msg = "The mandatory 'responseIdentifier' attribute is missing from the 'endAttemptInteraction' element.";
throw new UnmarshallingException($msg, $element);
}
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"if",
"(",
"(",
"$",
"responseIdentifier",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'responseIdentifier'",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"title",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'title'",
")",
")",
"===",
"null",
")",
"{",
"// The XSD does not restrict to an empty string, we then consider",
"// the title as an empty string ('').",
"$",
"title",
"=",
"''",
";",
"}",
"$",
"component",
"=",
"new",
"EndAttemptInteraction",
"(",
"$",
"responseIdentifier",
",",
"$",
"title",
")",
";",
"if",
"(",
"(",
"$",
"xmlBase",
"=",
"self",
"::",
"getXmlBase",
"(",
"$",
"element",
")",
")",
"!==",
"false",
")",
"{",
"$",
"component",
"->",
"setXmlBase",
"(",
"$",
"xmlBase",
")",
";",
"}",
"$",
"this",
"->",
"fillBodyElement",
"(",
"$",
"component",
",",
"$",
"element",
")",
";",
"return",
"$",
"component",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The mandatory 'responseIdentifier' attribute is missing from the 'endAttemptInteraction' element.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}"
] | Unmarshall a DOMElement object corresponding to an endAttemptInteraction element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent An EndAttemptInteraction object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"an",
"endAttemptInteraction",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php#L65-L88 |
oat-sa/qti-sdk | src/qtism/data/ExternalQtiComponent.php | ExternalQtiComponent.getXml | public function getXml()
{
// Build the DOMDocument object only on demand.
if ($this->xml === null) {
$xml = new SerializableDomDocument('1.0', 'UTF-8');
if (@$xml->loadXML($this->getXmlString()) === false) {
$msg = "The XML content '" . $this->getXmlString() . "' of the '" . $this->getQtiClassName() . "' external component could not be parsed correctly.";
throw new RuntimeException($msg);
}
if (($targetNamespace = $this->getTargetNamespace()) !== '' && $xml->documentElement->namespaceURI !== $this->getTargetNamespace()) {
$msg = "The XML content' " . $this->getXmlString() . "' of the '" . $this->getQtiClassName() . "' external component is not referenced into target namespace '" . $this->getTargetNamespace() . "'.";
throw new RuntimeException($msg);
}
$this->setXml($xml);
}
return $this->xml;
} | php | public function getXml()
{
// Build the DOMDocument object only on demand.
if ($this->xml === null) {
$xml = new SerializableDomDocument('1.0', 'UTF-8');
if (@$xml->loadXML($this->getXmlString()) === false) {
$msg = "The XML content '" . $this->getXmlString() . "' of the '" . $this->getQtiClassName() . "' external component could not be parsed correctly.";
throw new RuntimeException($msg);
}
if (($targetNamespace = $this->getTargetNamespace()) !== '' && $xml->documentElement->namespaceURI !== $this->getTargetNamespace()) {
$msg = "The XML content' " . $this->getXmlString() . "' of the '" . $this->getQtiClassName() . "' external component is not referenced into target namespace '" . $this->getTargetNamespace() . "'.";
throw new RuntimeException($msg);
}
$this->setXml($xml);
}
return $this->xml;
} | [
"public",
"function",
"getXml",
"(",
")",
"{",
"// Build the DOMDocument object only on demand.",
"if",
"(",
"$",
"this",
"->",
"xml",
"===",
"null",
")",
"{",
"$",
"xml",
"=",
"new",
"SerializableDomDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"if",
"(",
"@",
"$",
"xml",
"->",
"loadXML",
"(",
"$",
"this",
"->",
"getXmlString",
"(",
")",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"The XML content '\"",
".",
"$",
"this",
"->",
"getXmlString",
"(",
")",
".",
"\"' of the '\"",
".",
"$",
"this",
"->",
"getQtiClassName",
"(",
")",
".",
"\"' external component could not be parsed correctly.\"",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"msg",
")",
";",
"}",
"if",
"(",
"(",
"$",
"targetNamespace",
"=",
"$",
"this",
"->",
"getTargetNamespace",
"(",
")",
")",
"!==",
"''",
"&&",
"$",
"xml",
"->",
"documentElement",
"->",
"namespaceURI",
"!==",
"$",
"this",
"->",
"getTargetNamespace",
"(",
")",
")",
"{",
"$",
"msg",
"=",
"\"The XML content' \"",
".",
"$",
"this",
"->",
"getXmlString",
"(",
")",
".",
"\"' of the '\"",
".",
"$",
"this",
"->",
"getQtiClassName",
"(",
")",
".",
"\"' external component is not referenced into target namespace '\"",
".",
"$",
"this",
"->",
"getTargetNamespace",
"(",
")",
".",
"\"'.\"",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"this",
"->",
"setXml",
"(",
"$",
"xml",
")",
";",
"}",
"return",
"$",
"this",
"->",
"xml",
";",
"}"
] | Returns the XML representation of the external component as
a DOMDocument object.
@return \qtism\common\dom\SerializableDomDocument A DOMDocument (serializable) object representing the content of the external component.
@throws \RuntimeException If the root element of the XML representation is not from the target namespace or the XML could not be parsed. | [
"Returns",
"the",
"XML",
"representation",
"of",
"the",
"external",
"component",
"as",
"a",
"DOMDocument",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/ExternalQtiComponent.php#L71-L91 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/HotspotChoice.php | HotspotChoice.setShape | public function setShape($shape)
{
if (in_array($shape, QtiShape::asArray()) === true) {
$this->shape = $shape;
} else {
$msg = "The 'shape' argument must be a value from the Shape enumeration, '" . $shape . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setShape($shape)
{
if (in_array($shape, QtiShape::asArray()) === true) {
$this->shape = $shape;
} else {
$msg = "The 'shape' argument must be a value from the Shape enumeration, '" . $shape . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setShape",
"(",
"$",
"shape",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"shape",
",",
"QtiShape",
"::",
"asArray",
"(",
")",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"shape",
"=",
"$",
"shape",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'shape' argument must be a value from the Shape enumeration, '\"",
".",
"$",
"shape",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the shape of the associableHotspot.
@param integer $shape A value from the Shape enumeration. | [
"Set",
"the",
"shape",
"of",
"the",
"associableHotspot",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/HotspotChoice.php#L95-L103 |
oat-sa/qti-sdk | src/qtism/data/expressions/operators/Index.php | Index.setN | public function setN($n)
{
if (is_int($n) || (gettype($n) === 'string' && Format::isVariableRef($n))) {
$this->n = $n;
} else {
$msg = "The n attribute must be an integer or a variable reference, '" . gettype($n) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setN($n)
{
if (is_int($n) || (gettype($n) === 'string' && Format::isVariableRef($n))) {
$this->n = $n;
} else {
$msg = "The n attribute must be an integer or a variable reference, '" . gettype($n) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setN",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"n",
")",
"||",
"(",
"gettype",
"(",
"$",
"n",
")",
"===",
"'string'",
"&&",
"Format",
"::",
"isVariableRef",
"(",
"$",
"n",
")",
")",
")",
"{",
"$",
"this",
"->",
"n",
"=",
"$",
"n",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The n attribute must be an integer or a variable reference, '\"",
".",
"gettype",
"(",
"$",
"n",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the n attribute.
@param integer|string $n The index to lookup. It must be an integer or a variable reference.
@throws \InvalidArgumentException If $n is not an integer nor a variable reference. | [
"Set",
"the",
"n",
"attribute",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/expressions/operators/Index.php#L73-L81 |
oat-sa/qti-sdk | src/qtism/data/storage/php/marshalling/Utils.php | Utils.variableName | public static function variableName($value, $occurence = 0)
{
if (is_int($occurence) === false || $occurence < 0) {
$msg = "The 'occurence' argument must be a positive integer (>= 0).";
throw new InvalidArgumentException($msg);
}
if (is_object($value) === true) {
$object = new ReflectionObject($value);
$className = mb_strtolower($object->getShortName(), 'UTF-8');
return "${className}_${occurence}";
} else {
// Is it a PHP scalar value?
if (is_scalar($value) === true) {
return gettype($value) . '_' . $occurence;
} elseif (is_array($value) === true) {
return 'array_' . $occurence;
}
// null value?
elseif (is_null($value) === true) {
// To avoid conflict with NullValue QTI expression object!!!
return 'scalarnullvalue_' . $occurence;
} else {
$msg = "Cannot handle the given value.";
throw new InvalidArgumentException($msg);
}
}
} | php | public static function variableName($value, $occurence = 0)
{
if (is_int($occurence) === false || $occurence < 0) {
$msg = "The 'occurence' argument must be a positive integer (>= 0).";
throw new InvalidArgumentException($msg);
}
if (is_object($value) === true) {
$object = new ReflectionObject($value);
$className = mb_strtolower($object->getShortName(), 'UTF-8');
return "${className}_${occurence}";
} else {
// Is it a PHP scalar value?
if (is_scalar($value) === true) {
return gettype($value) . '_' . $occurence;
} elseif (is_array($value) === true) {
return 'array_' . $occurence;
}
// null value?
elseif (is_null($value) === true) {
// To avoid conflict with NullValue QTI expression object!!!
return 'scalarnullvalue_' . $occurence;
} else {
$msg = "Cannot handle the given value.";
throw new InvalidArgumentException($msg);
}
}
} | [
"public",
"static",
"function",
"variableName",
"(",
"$",
"value",
",",
"$",
"occurence",
"=",
"0",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"occurence",
")",
"===",
"false",
"||",
"$",
"occurence",
"<",
"0",
")",
"{",
"$",
"msg",
"=",
"\"The 'occurence' argument must be a positive integer (>= 0).\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"$",
"object",
"=",
"new",
"ReflectionObject",
"(",
"$",
"value",
")",
";",
"$",
"className",
"=",
"mb_strtolower",
"(",
"$",
"object",
"->",
"getShortName",
"(",
")",
",",
"'UTF-8'",
")",
";",
"return",
"\"${className}_${occurence}\"",
";",
"}",
"else",
"{",
"// Is it a PHP scalar value?",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"return",
"gettype",
"(",
"$",
"value",
")",
".",
"'_'",
".",
"$",
"occurence",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"return",
"'array_'",
".",
"$",
"occurence",
";",
"}",
"// null value?",
"elseif",
"(",
"is_null",
"(",
"$",
"value",
")",
"===",
"true",
")",
"{",
"// To avoid conflict with NullValue QTI expression object!!!",
"return",
"'scalarnullvalue_'",
".",
"$",
"occurence",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"Cannot handle the given value.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}",
"}"
] | Generate a variable name for a given object.
* If $value is an object, the generated variable name
will be [$object-class-short-name]_$occurence in lower case e.g. 'point_0',
'assessmenttest_3', ...
* If $value is a PHP scalar value (not including the null value), the generated
variable name will be [gettype($value)]_$occurence e.g. 'string_1', 'boolean_0', ...
* If $value is an array, the generated variable name will be array_$occurence such as
'array_0', 'array_2', ...
* If $value is the null value, the generated variable name will be nullvalue_$occurence
such as 'nullvalue_3'.
* Finally, if the $value cannot be handled by this method, an InvalidArgumentException
is thrown.
@param mixed $value A value.
@param integer $occurence An occurence number.
@return string A variable name.
@throws \InvalidArgumentException If $occurence is not a positive integer or if $value cannot be handled by this method. | [
"Generate",
"a",
"variable",
"name",
"for",
"a",
"given",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/marshalling/Utils.php#L62-L90 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.getAttributeName | protected function getAttributeName(DOMElement $element, $attribute)
{
if ($this->isWebComponentFriendly() === true && preg_match('/^qti-/', $element->localName) === 1) {
$qtiFriendlyClassName = XmlUtils::qtiFriendlyName($element->localName);
if (in_array($qtiFriendlyClassName, self::$webComponentFriendlyClasses) === true) {
return XmlUtils::webComponentFriendlyAttributeName($attribute);
}
}
return $attribute;
} | php | protected function getAttributeName(DOMElement $element, $attribute)
{
if ($this->isWebComponentFriendly() === true && preg_match('/^qti-/', $element->localName) === 1) {
$qtiFriendlyClassName = XmlUtils::qtiFriendlyName($element->localName);
if (in_array($qtiFriendlyClassName, self::$webComponentFriendlyClasses) === true) {
return XmlUtils::webComponentFriendlyAttributeName($attribute);
}
}
return $attribute;
} | [
"protected",
"function",
"getAttributeName",
"(",
"DOMElement",
"$",
"element",
",",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isWebComponentFriendly",
"(",
")",
"===",
"true",
"&&",
"preg_match",
"(",
"'/^qti-/'",
",",
"$",
"element",
"->",
"localName",
")",
"===",
"1",
")",
"{",
"$",
"qtiFriendlyClassName",
"=",
"XmlUtils",
"::",
"qtiFriendlyName",
"(",
"$",
"element",
"->",
"localName",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"qtiFriendlyClassName",
",",
"self",
"::",
"$",
"webComponentFriendlyClasses",
")",
"===",
"true",
")",
"{",
"return",
"XmlUtils",
"::",
"webComponentFriendlyAttributeName",
"(",
"$",
"attribute",
")",
";",
"}",
"}",
"return",
"$",
"attribute",
";",
"}"
] | Get Attribute Name to Use for Marshalling
This method provides the attribute name to be used to retrieve an element attribute value
by considering whether or not the Marshaller implementation is running in Web Component
Friendly mode.
Examples:
In case of the Marshaller implementation IS NOT running in Web Component Friendly mode,
calling this method on an $element "choiceInteraction" and a "responseIdentifier" $attribute, the
"responseIdentifier" value is returned.
On the other hand, in case of the Marshaller implementation IS running in Web Component Friendly mode,
calling this method on an $element "choiceInteraction" and a "responseIdentifier" $attribute, the
"response-identifier" value is returned.
@param \DOMElement $element
@param $attribute
@return string | [
"Get",
"Attribute",
"Name",
"to",
"Use",
"for",
"Marshalling"
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L323-L334 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.getDOMElementAttributeAs | public function getDOMElementAttributeAs(DOMElement $element, $attribute, $datatype = 'string')
{
return XmlUtils::getDOMElementAttributeAs($element, $this->getAttributeName($element, $attribute), $datatype);
} | php | public function getDOMElementAttributeAs(DOMElement $element, $attribute, $datatype = 'string')
{
return XmlUtils::getDOMElementAttributeAs($element, $this->getAttributeName($element, $attribute), $datatype);
} | [
"public",
"function",
"getDOMElementAttributeAs",
"(",
"DOMElement",
"$",
"element",
",",
"$",
"attribute",
",",
"$",
"datatype",
"=",
"'string'",
")",
"{",
"return",
"XmlUtils",
"::",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"getAttributeName",
"(",
"$",
"element",
",",
"$",
"attribute",
")",
",",
"$",
"datatype",
")",
";",
"}"
] | Get the attribute value of a given DOMElement object, cast in a given datatype.
@param DOMElement $element The element the attribute you want to retrieve the value is bound to.
@param string $attribute The attribute name.
@param string $datatype The returned datatype. Accepted values are 'string', 'integer', 'float', 'double' and 'boolean'.
@throws InvalidArgumentException If $datatype is not in the range of possible values.
@return mixed The attribute value with the provided $datatype, or null if the attribute does not exist in $element. | [
"Get",
"the",
"attribute",
"value",
"of",
"a",
"given",
"DOMElement",
"object",
"cast",
"in",
"a",
"given",
"datatype",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L345-L348 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.setDOMElementAttribute | public function setDOMElementAttribute(DOMElement $element, $attribute, $value)
{
XmlUtils::setDOMElementAttribute($element, $this->getAttributeName($element, $attribute), $value);
} | php | public function setDOMElementAttribute(DOMElement $element, $attribute, $value)
{
XmlUtils::setDOMElementAttribute($element, $this->getAttributeName($element, $attribute), $value);
} | [
"public",
"function",
"setDOMElementAttribute",
"(",
"DOMElement",
"$",
"element",
",",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"XmlUtils",
"::",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"getAttributeName",
"(",
"$",
"element",
",",
"$",
"attribute",
")",
",",
"$",
"value",
")",
";",
"}"
] | Set the attribute value of a given DOMElement object. Boolean values will be transformed
@param DOMElement $element A DOMElement object.
@param string $attribute An XML attribute name.
@param mixed $value A given value. | [
"Set",
"the",
"attribute",
"value",
"of",
"a",
"given",
"DOMElement",
"object",
".",
"Boolean",
"values",
"will",
"be",
"transformed"
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L357-L360 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.setDOMElementValue | public static function setDOMElementValue(DOMElement $element, $value)
{
switch (gettype($value)) {
case 'boolean':
$element->nodeValue = ($value === true) ? 'true' : 'false';
break;
default:
$element->nodeValue = $value;
break;
}
} | php | public static function setDOMElementValue(DOMElement $element, $value)
{
switch (gettype($value)) {
case 'boolean':
$element->nodeValue = ($value === true) ? 'true' : 'false';
break;
default:
$element->nodeValue = $value;
break;
}
} | [
"public",
"static",
"function",
"setDOMElementValue",
"(",
"DOMElement",
"$",
"element",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"value",
")",
")",
"{",
"case",
"'boolean'",
":",
"$",
"element",
"->",
"nodeValue",
"=",
"(",
"$",
"value",
"===",
"true",
")",
"?",
"'true'",
":",
"'false'",
";",
"break",
";",
"default",
":",
"$",
"element",
"->",
"nodeValue",
"=",
"$",
"value",
";",
"break",
";",
"}",
"}"
] | Set the node value of a given DOMElement object. Boolean values will be transformed as 'true'|'false'.
@param DOMElement $element A DOMElement object.
@param mixed $value A given value. | [
"Set",
"the",
"node",
"value",
"of",
"a",
"given",
"DOMElement",
"object",
".",
"Boolean",
"values",
"will",
"be",
"transformed",
"as",
"true",
"|",
"false",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L368-L379 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.getFirstChildElement | public static function getFirstChildElement($element)
{
$children = $element->childNodes;
for ($i = 0; $i < $children->length; $i++) {
$child = $children->item($i);
if ($child->nodeType === XML_ELEMENT_NODE) {
return $child;
}
}
return false;
} | php | public static function getFirstChildElement($element)
{
$children = $element->childNodes;
for ($i = 0; $i < $children->length; $i++) {
$child = $children->item($i);
if ($child->nodeType === XML_ELEMENT_NODE) {
return $child;
}
}
return false;
} | [
"public",
"static",
"function",
"getFirstChildElement",
"(",
"$",
"element",
")",
"{",
"$",
"children",
"=",
"$",
"element",
"->",
"childNodes",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"children",
"->",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"child",
"=",
"$",
"children",
"->",
"item",
"(",
"$",
"i",
")",
";",
"if",
"(",
"$",
"child",
"->",
"nodeType",
"===",
"XML_ELEMENT_NODE",
")",
"{",
"return",
"$",
"child",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Get the first child DOM Node with nodeType attribute equals to XML_ELEMENT_NODE.
This is very useful to get a sub-node without having to exclude text nodes, cdata,
... manually.
@param DOMElement $element A DOMElement object
@return DOMElement|boolean A DOMElement If a child node with nodeType = XML_ELEMENT_NODE or false if nothing found. | [
"Get",
"the",
"first",
"child",
"DOM",
"Node",
"with",
"nodeType",
"attribute",
"equals",
"to",
"XML_ELEMENT_NODE",
".",
"This",
"is",
"very",
"useful",
"to",
"get",
"a",
"sub",
"-",
"node",
"without",
"having",
"to",
"exclude",
"text",
"nodes",
"cdata",
"...",
"manually",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L389-L400 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.getChildElementsByTagName | public function getChildElementsByTagName($element, $tagName, $exclude = false, $withText = false)
{
if (is_array($tagName) === false) {
$tagName = [$tagName];
}
if ($this->isWebComponentFriendly() === true) {
foreach ($tagName as $key => $name) {
if (in_array($name, self::$webComponentFriendlyClasses) === true) {
$tagName[$key] = XmlUtils::webComponentFriendlyClassName($name);
}
}
}
return XmlUtils::getChildElementsByTagName($element, $tagName, $exclude, $withText);
} | php | public function getChildElementsByTagName($element, $tagName, $exclude = false, $withText = false)
{
if (is_array($tagName) === false) {
$tagName = [$tagName];
}
if ($this->isWebComponentFriendly() === true) {
foreach ($tagName as $key => $name) {
if (in_array($name, self::$webComponentFriendlyClasses) === true) {
$tagName[$key] = XmlUtils::webComponentFriendlyClassName($name);
}
}
}
return XmlUtils::getChildElementsByTagName($element, $tagName, $exclude, $withText);
} | [
"public",
"function",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"$",
"tagName",
",",
"$",
"exclude",
"=",
"false",
",",
"$",
"withText",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"tagName",
")",
"===",
"false",
")",
"{",
"$",
"tagName",
"=",
"[",
"$",
"tagName",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isWebComponentFriendly",
"(",
")",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"tagName",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"webComponentFriendlyClasses",
")",
"===",
"true",
")",
"{",
"$",
"tagName",
"[",
"$",
"key",
"]",
"=",
"XmlUtils",
"::",
"webComponentFriendlyClassName",
"(",
"$",
"name",
")",
";",
"}",
"}",
"}",
"return",
"XmlUtils",
"::",
"getChildElementsByTagName",
"(",
"$",
"element",
",",
"$",
"tagName",
",",
"$",
"exclude",
",",
"$",
"withText",
")",
";",
"}"
] | Get the child elements of a given element by tag name. This method does
not behave like DOMElement::getElementsByTagName. It only returns the direct
child elements that matches $tagName but does not go recursive.
@param DOMElement $element A DOMElement object.
@param mixed $tagName The name of the tags you would like to retrieve or an array of tags to match.
@param boolean $exclude (optional) Wether the $tagName parameter must be considered as a blacklist.
@param boolean $withText (optional) Wether text nodes must be returned or not.
@return array An array of DOMElement objects. | [
"Get",
"the",
"child",
"elements",
"of",
"a",
"given",
"element",
"by",
"tag",
"name",
".",
"This",
"method",
"does",
"not",
"behave",
"like",
"DOMElement",
"::",
"getElementsByTagName",
".",
"It",
"only",
"returns",
"the",
"direct",
"child",
"elements",
"that",
"matches",
"$tagName",
"but",
"does",
"not",
"go",
"recursive",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L425-L440 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.getXmlBase | public static function getXmlBase(DOMElement $element)
{
$returnValue = false;
if (($xmlBase = $element->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'base')) !== '') {
$returnValue = $xmlBase;
}
return $returnValue;
} | php | public static function getXmlBase(DOMElement $element)
{
$returnValue = false;
if (($xmlBase = $element->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'base')) !== '') {
$returnValue = $xmlBase;
}
return $returnValue;
} | [
"public",
"static",
"function",
"getXmlBase",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"(",
"$",
"xmlBase",
"=",
"$",
"element",
"->",
"getAttributeNS",
"(",
"'http://www.w3.org/XML/1998/namespace'",
",",
"'base'",
")",
")",
"!==",
"''",
")",
"{",
"$",
"returnValue",
"=",
"$",
"xmlBase",
";",
"}",
"return",
"$",
"returnValue",
";",
"}"
] | Get the string value of the xml:base attribute of a given $element. The method
will return false if no xml:base attribute is defined for the $element or its value
is empty.
@param DOMElement $element A DOMElement object you want to get the xml:base attribute value.
@return false|string The value of the xml:base attribute or false if it could not be retrieved. | [
"Get",
"the",
"string",
"value",
"of",
"the",
"xml",
":",
"base",
"attribute",
"of",
"a",
"given",
"$element",
".",
"The",
"method",
"will",
"return",
"false",
"if",
"no",
"xml",
":",
"base",
"attribute",
"is",
"defined",
"for",
"the",
"$element",
"or",
"its",
"value",
"is",
"empty",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L450-L458 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.fillBodyElement | protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element)
{
try {
$bodyElement->setId($element->getAttribute('id'));
$bodyElement->setClass($element->getAttribute('class'));
$bodyElement->setLang($element->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang'));
$bodyElement->setLabel($element->getAttribute('label'));
$version = $this->getVersion();
if (Version::compare($version, '2.2.0', '>=') === true && ($dir = $this->getDOMElementAttributeAs($element, 'dir')) !== null && in_array($element->localName, self::$dirClasses) === true) {
$bodyElement->setDir(Direction::getConstantByName($dir));
}
} catch (InvalidArgumentException $e) {
$msg = "An error occured while filling the bodyElement attributes (id, class, lang, label, dir).";
throw new UnmarshallingException($msg, $element, $e);
}
} | php | protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element)
{
try {
$bodyElement->setId($element->getAttribute('id'));
$bodyElement->setClass($element->getAttribute('class'));
$bodyElement->setLang($element->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang'));
$bodyElement->setLabel($element->getAttribute('label'));
$version = $this->getVersion();
if (Version::compare($version, '2.2.0', '>=') === true && ($dir = $this->getDOMElementAttributeAs($element, 'dir')) !== null && in_array($element->localName, self::$dirClasses) === true) {
$bodyElement->setDir(Direction::getConstantByName($dir));
}
} catch (InvalidArgumentException $e) {
$msg = "An error occured while filling the bodyElement attributes (id, class, lang, label, dir).";
throw new UnmarshallingException($msg, $element, $e);
}
} | [
"protected",
"function",
"fillBodyElement",
"(",
"BodyElement",
"$",
"bodyElement",
",",
"DOMElement",
"$",
"element",
")",
"{",
"try",
"{",
"$",
"bodyElement",
"->",
"setId",
"(",
"$",
"element",
"->",
"getAttribute",
"(",
"'id'",
")",
")",
";",
"$",
"bodyElement",
"->",
"setClass",
"(",
"$",
"element",
"->",
"getAttribute",
"(",
"'class'",
")",
")",
";",
"$",
"bodyElement",
"->",
"setLang",
"(",
"$",
"element",
"->",
"getAttributeNS",
"(",
"'http://www.w3.org/XML/1998/namespace'",
",",
"'lang'",
")",
")",
";",
"$",
"bodyElement",
"->",
"setLabel",
"(",
"$",
"element",
"->",
"getAttribute",
"(",
"'label'",
")",
")",
";",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.2.0'",
",",
"'>='",
")",
"===",
"true",
"&&",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'dir'",
")",
")",
"!==",
"null",
"&&",
"in_array",
"(",
"$",
"element",
"->",
"localName",
",",
"self",
"::",
"$",
"dirClasses",
")",
"===",
"true",
")",
"{",
"$",
"bodyElement",
"->",
"setDir",
"(",
"Direction",
"::",
"getConstantByName",
"(",
"$",
"dir",
")",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An error occured while filling the bodyElement attributes (id, class, lang, label, dir).\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Fill $bodyElement with the following bodyElement attributes:
* id
* class
* lang
* label
* dir (QTI 2.2)
@param BodyElement $bodyElement The bodyElement to fill.
@param DOMElement $element The DOMElement object from where the attribute values must be retrieved.
@throws UnmarshallingException If one of the attributes of $element is not valid. | [
"Fill",
"$bodyElement",
"with",
"the",
"following",
"bodyElement",
"attributes",
":"
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L486-L502 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/Marshaller.php | Marshaller.fillElement | protected function fillElement(DOMElement $element, BodyElement $bodyElement)
{
if (($id = $bodyElement->getId()) !== '') {
$element->setAttribute('id', $id);
}
if (($class = $bodyElement->getClass()) !== '') {
$element->setAttribute('class', $class);
}
if (($lang = $bodyElement->getLang()) !== '') {
$element->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', $lang);
}
if (($label = $bodyElement->getLabel()) != '') {
$element->setAttribute('label', $label);
}
$version = $this->getVersion();
if (Version::compare($version, '2.2.0', '>=') === true && ($dir = $bodyElement->getDir()) !== Direction::AUTO && in_array($bodyElement->getQtiClassName(), self::$dirClasses) === true) {
$element->setAttribute('dir', Direction::getNameByConstant($dir));
}
} | php | protected function fillElement(DOMElement $element, BodyElement $bodyElement)
{
if (($id = $bodyElement->getId()) !== '') {
$element->setAttribute('id', $id);
}
if (($class = $bodyElement->getClass()) !== '') {
$element->setAttribute('class', $class);
}
if (($lang = $bodyElement->getLang()) !== '') {
$element->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', $lang);
}
if (($label = $bodyElement->getLabel()) != '') {
$element->setAttribute('label', $label);
}
$version = $this->getVersion();
if (Version::compare($version, '2.2.0', '>=') === true && ($dir = $bodyElement->getDir()) !== Direction::AUTO && in_array($bodyElement->getQtiClassName(), self::$dirClasses) === true) {
$element->setAttribute('dir', Direction::getNameByConstant($dir));
}
} | [
"protected",
"function",
"fillElement",
"(",
"DOMElement",
"$",
"element",
",",
"BodyElement",
"$",
"bodyElement",
")",
"{",
"if",
"(",
"(",
"$",
"id",
"=",
"$",
"bodyElement",
"->",
"getId",
"(",
")",
")",
"!==",
"''",
")",
"{",
"$",
"element",
"->",
"setAttribute",
"(",
"'id'",
",",
"$",
"id",
")",
";",
"}",
"if",
"(",
"(",
"$",
"class",
"=",
"$",
"bodyElement",
"->",
"getClass",
"(",
")",
")",
"!==",
"''",
")",
"{",
"$",
"element",
"->",
"setAttribute",
"(",
"'class'",
",",
"$",
"class",
")",
";",
"}",
"if",
"(",
"(",
"$",
"lang",
"=",
"$",
"bodyElement",
"->",
"getLang",
"(",
")",
")",
"!==",
"''",
")",
"{",
"$",
"element",
"->",
"setAttributeNS",
"(",
"'http://www.w3.org/XML/1998/namespace'",
",",
"'xml:lang'",
",",
"$",
"lang",
")",
";",
"}",
"if",
"(",
"(",
"$",
"label",
"=",
"$",
"bodyElement",
"->",
"getLabel",
"(",
")",
")",
"!=",
"''",
")",
"{",
"$",
"element",
"->",
"setAttribute",
"(",
"'label'",
",",
"$",
"label",
")",
";",
"}",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.2.0'",
",",
"'>='",
")",
"===",
"true",
"&&",
"(",
"$",
"dir",
"=",
"$",
"bodyElement",
"->",
"getDir",
"(",
")",
")",
"!==",
"Direction",
"::",
"AUTO",
"&&",
"in_array",
"(",
"$",
"bodyElement",
"->",
"getQtiClassName",
"(",
")",
",",
"self",
"::",
"$",
"dirClasses",
")",
"===",
"true",
")",
"{",
"$",
"element",
"->",
"setAttribute",
"(",
"'dir'",
",",
"Direction",
"::",
"getNameByConstant",
"(",
"$",
"dir",
")",
")",
";",
"}",
"}"
] | Fill $element with the attributes of $bodyElement.
@param DOMElement $element The element from where the atribute values will be
@param BodyElement $bodyElement The bodyElement to be fill. | [
"Fill",
"$element",
"with",
"the",
"attributes",
"of",
"$bodyElement",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/Marshaller.php#L510-L532 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/DefaultValueMarshaller.php | DefaultValueMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
$interpretation = $this->getDOMElementAttributeAs($element, 'interpretation', 'string');
$interpretation = (empty($interpretation)) ? '' : $interpretation;
// Retrieve the values ...
$values = new ValueCollection();
$valueElements = $element->getElementsByTagName('value');
if ($valueElements->length > 0) {
for ($i = 0; $i < $valueElements->length; $i++) {
$valueMarshaller = $this->getMarshallerFactory()->createMarshaller($valueElements->item($i), array($this->getBaseType()));
$values[] = $valueMarshaller->unmarshall($valueElements->item($i));
}
$object = new DefaultValue($values, $interpretation);
return $object;
} else {
$msg = "A 'defaultValue' QTI element must contain at least one 'value' QTI element.";
throw new UnmarshallingException($msg, $element);
}
} | php | protected function unmarshall(DOMElement $element)
{
$interpretation = $this->getDOMElementAttributeAs($element, 'interpretation', 'string');
$interpretation = (empty($interpretation)) ? '' : $interpretation;
// Retrieve the values ...
$values = new ValueCollection();
$valueElements = $element->getElementsByTagName('value');
if ($valueElements->length > 0) {
for ($i = 0; $i < $valueElements->length; $i++) {
$valueMarshaller = $this->getMarshallerFactory()->createMarshaller($valueElements->item($i), array($this->getBaseType()));
$values[] = $valueMarshaller->unmarshall($valueElements->item($i));
}
$object = new DefaultValue($values, $interpretation);
return $object;
} else {
$msg = "A 'defaultValue' QTI element must contain at least one 'value' QTI element.";
throw new UnmarshallingException($msg, $element);
}
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"interpretation",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'interpretation'",
",",
"'string'",
")",
";",
"$",
"interpretation",
"=",
"(",
"empty",
"(",
"$",
"interpretation",
")",
")",
"?",
"''",
":",
"$",
"interpretation",
";",
"// Retrieve the values ...",
"$",
"values",
"=",
"new",
"ValueCollection",
"(",
")",
";",
"$",
"valueElements",
"=",
"$",
"element",
"->",
"getElementsByTagName",
"(",
"'value'",
")",
";",
"if",
"(",
"$",
"valueElements",
"->",
"length",
">",
"0",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"valueElements",
"->",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"valueMarshaller",
"=",
"$",
"this",
"->",
"getMarshallerFactory",
"(",
")",
"->",
"createMarshaller",
"(",
"$",
"valueElements",
"->",
"item",
"(",
"$",
"i",
")",
",",
"array",
"(",
"$",
"this",
"->",
"getBaseType",
"(",
")",
")",
")",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"valueMarshaller",
"->",
"unmarshall",
"(",
"$",
"valueElements",
"->",
"item",
"(",
"$",
"i",
")",
")",
";",
"}",
"$",
"object",
"=",
"new",
"DefaultValue",
"(",
"$",
"values",
",",
"$",
"interpretation",
")",
";",
"return",
"$",
"object",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"A 'defaultValue' QTI element must contain at least one 'value' QTI element.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}"
] | Unmarshall a DOMElement object corresponding to a QTI defaultValue element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent A DefaultValue object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException If the DOMElement object cannot be unmarshalled in a valid DefaultValue object. | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"a",
"QTI",
"defaultValue",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/DefaultValueMarshaller.php#L102-L126 |
oat-sa/qti-sdk | src/qtism/runtime/rendering/qtipl/rules/TemplateElseQtiPLRenderer.php | TemplateElseQtiPLRenderer.render | public function render($something)
{
$renderer = new QtiPLRenderer($this->getCRO());
$qtipl = " else {\n";
foreach ($something->getTemplateRules() as $rules) {
$qtipl .= str_repeat(" ", $this->getCRO()->getIndentation()) . $renderer->render($rules) . ";\n";
}
return $qtipl . "}";
} | php | public function render($something)
{
$renderer = new QtiPLRenderer($this->getCRO());
$qtipl = " else {\n";
foreach ($something->getTemplateRules() as $rules) {
$qtipl .= str_repeat(" ", $this->getCRO()->getIndentation()) . $renderer->render($rules) . ";\n";
}
return $qtipl . "}";
} | [
"public",
"function",
"render",
"(",
"$",
"something",
")",
"{",
"$",
"renderer",
"=",
"new",
"QtiPLRenderer",
"(",
"$",
"this",
"->",
"getCRO",
"(",
")",
")",
";",
"$",
"qtipl",
"=",
"\" else {\\n\"",
";",
"foreach",
"(",
"$",
"something",
"->",
"getTemplateRules",
"(",
")",
"as",
"$",
"rules",
")",
"{",
"$",
"qtipl",
".=",
"str_repeat",
"(",
"\" \"",
",",
"$",
"this",
"->",
"getCRO",
"(",
")",
"->",
"getIndentation",
"(",
")",
")",
".",
"$",
"renderer",
"->",
"render",
"(",
"$",
"rules",
")",
".",
"\";\\n\"",
";",
"}",
"return",
"$",
"qtipl",
".",
"\"}\"",
";",
"}"
] | Render a QtiComponent object into another constitution.
@param mixed $something Something to render into another consitution.
@return mixed The rendered component into another constitution.
@throws \qtism\runtime\rendering\RenderingException If something goes wrong while rendering the component. | [
"Render",
"a",
"QtiComponent",
"object",
"into",
"another",
"constitution",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/rendering/qtipl/rules/TemplateElseQtiPLRenderer.php#L45-L55 |
oat-sa/qti-sdk | src/qtism/common/utils/Time.php | Time.timeDiffSeconds | public static function timeDiffSeconds(DateTime $time1, DateTime $time2)
{
$interval = $time1->diff($time2);
return self::totalSeconds($interval);
} | php | public static function timeDiffSeconds(DateTime $time1, DateTime $time2)
{
$interval = $time1->diff($time2);
return self::totalSeconds($interval);
} | [
"public",
"static",
"function",
"timeDiffSeconds",
"(",
"DateTime",
"$",
"time1",
",",
"DateTime",
"$",
"time2",
")",
"{",
"$",
"interval",
"=",
"$",
"time1",
"->",
"diff",
"(",
"$",
"time2",
")",
";",
"return",
"self",
"::",
"totalSeconds",
"(",
"$",
"interval",
")",
";",
"}"
] | Get the time difference between two DateTime object in seconds.
@param \DateTime $time1
@param \DateTime $time2
@return integer a number of seconds. | [
"Get",
"the",
"time",
"difference",
"between",
"two",
"DateTime",
"object",
"in",
"seconds",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/utils/Time.php#L44-L49 |
oat-sa/qti-sdk | src/qtism/common/utils/Time.php | Time.totalSeconds | public static function totalSeconds(DateInterval $interval)
{
$sYears = 31536000 * $interval->y;
$sMonths = 30 * 24 * 3600 * $interval->m;
$sDays = 24 * 3600 * $interval->d;
$sHours = 3600 * $interval->h;
$sMinutes = 60 * $interval->i;
$sSeconds = $interval->s;
$total = $sYears + $sMonths + $sDays + $sHours + $sMinutes + $sSeconds;
return ($interval->invert === 1) ? $total * -1 : $total;
} | php | public static function totalSeconds(DateInterval $interval)
{
$sYears = 31536000 * $interval->y;
$sMonths = 30 * 24 * 3600 * $interval->m;
$sDays = 24 * 3600 * $interval->d;
$sHours = 3600 * $interval->h;
$sMinutes = 60 * $interval->i;
$sSeconds = $interval->s;
$total = $sYears + $sMonths + $sDays + $sHours + $sMinutes + $sSeconds;
return ($interval->invert === 1) ? $total * -1 : $total;
} | [
"public",
"static",
"function",
"totalSeconds",
"(",
"DateInterval",
"$",
"interval",
")",
"{",
"$",
"sYears",
"=",
"31536000",
"*",
"$",
"interval",
"->",
"y",
";",
"$",
"sMonths",
"=",
"30",
"*",
"24",
"*",
"3600",
"*",
"$",
"interval",
"->",
"m",
";",
"$",
"sDays",
"=",
"24",
"*",
"3600",
"*",
"$",
"interval",
"->",
"d",
";",
"$",
"sHours",
"=",
"3600",
"*",
"$",
"interval",
"->",
"h",
";",
"$",
"sMinutes",
"=",
"60",
"*",
"$",
"interval",
"->",
"i",
";",
"$",
"sSeconds",
"=",
"$",
"interval",
"->",
"s",
";",
"$",
"total",
"=",
"$",
"sYears",
"+",
"$",
"sMonths",
"+",
"$",
"sDays",
"+",
"$",
"sHours",
"+",
"$",
"sMinutes",
"+",
"$",
"sSeconds",
";",
"return",
"(",
"$",
"interval",
"->",
"invert",
"===",
"1",
")",
"?",
"$",
"total",
"*",
"-",
"1",
":",
"$",
"total",
";",
"}"
] | Get the total number of seconds a given date $interval represents.
@param \DateInterval $interval
@return integer | [
"Get",
"the",
"total",
"number",
"of",
"seconds",
"a",
"given",
"date",
"$interval",
"represents",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/utils/Time.php#L57-L69 |
oat-sa/qti-sdk | src/qtism/runtime/common/StackTrace.php | StackTrace.push | public function push($value)
{
$this->checkType($value);
$data = &$this->getDataPlaceHolder();
array_push($data, $value);
} | php | public function push($value)
{
$this->checkType($value);
$data = &$this->getDataPlaceHolder();
array_push($data, $value);
} | [
"public",
"function",
"push",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"checkType",
"(",
"$",
"value",
")",
";",
"$",
"data",
"=",
"&",
"$",
"this",
"->",
"getDataPlaceHolder",
"(",
")",
";",
"array_push",
"(",
"$",
"data",
",",
"$",
"value",
")",
";",
"}"
] | Push a given StackTraceItem object on the StackTrace.
@param \qtism\runtime\common\StackTraceItem $value A StackTraceItem object.
@throws \InvalidArgumentException If $value is not a StackTraceItem object. | [
"Push",
"a",
"given",
"StackTraceItem",
"object",
"on",
"the",
"StackTrace",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/StackTrace.php#L56-L61 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpArgument.php | PhpArgument.setValue | public function setValue($value)
{
if ($value instanceof PhpVariable || Utils::isScalar($value)) {
$this->value = $value;
} else {
$msg = "The 'value' argument must be a PHP scalar value, a PhpVariable object or null, '" . gettype($value) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setValue($value)
{
if ($value instanceof PhpVariable || Utils::isScalar($value)) {
$this->value = $value;
} else {
$msg = "The 'value' argument must be a PHP scalar value, a PhpVariable object or null, '" . gettype($value) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"PhpVariable",
"||",
"Utils",
"::",
"isScalar",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'value' argument must be a PHP scalar value, a PhpVariable object or null, '\"",
".",
"gettype",
"(",
"$",
"value",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the value of the argument. It can be a PhpVariable object or PHP scalar value or null.
@param mixed $value A PHP scalar value or a PhpVariable object or null or a PhpVariable object.
@throws InvalidArgumentException If $value is not a PHP scalar value nor a PhpVariable object nor null. | [
"Set",
"the",
"value",
"of",
"the",
"argument",
".",
"It",
"can",
"be",
"a",
"PhpVariable",
"object",
"or",
"PHP",
"scalar",
"value",
"or",
"null",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpArgument.php#L66-L74 |
oat-sa/qti-sdk | src/qtism/common/datatypes/QtiIntOrIdentifier.php | QtiIntOrIdentifier.checkType | protected function checkType($value)
{
if (is_int($value) !== true && is_string($value) !== true) {
$msg = "The IntOrIdentifier Datatype only accepts to store identifier and integer values.";
throw new InvalidArgumentException($msg);
}
} | php | protected function checkType($value)
{
if (is_int($value) !== true && is_string($value) !== true) {
$msg = "The IntOrIdentifier Datatype only accepts to store identifier and integer values.";
throw new InvalidArgumentException($msg);
}
} | [
"protected",
"function",
"checkType",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
"!==",
"true",
"&&",
"is_string",
"(",
"$",
"value",
")",
"!==",
"true",
")",
"{",
"$",
"msg",
"=",
"\"The IntOrIdentifier Datatype only accepts to store identifier and integer values.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Checks whether or not $value is a valid integer or string to be
used as the intrinsic value of this object.
@throws \InvalidArgumentException If $value is not compliant with the QTI IntOrIdentifier datatype. | [
"Checks",
"whether",
"or",
"not",
"$value",
"is",
"a",
"valid",
"integer",
"or",
"string",
"to",
"be",
"used",
"as",
"the",
"intrinsic",
"value",
"of",
"this",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/datatypes/QtiIntOrIdentifier.php#L43-L49 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php | MapResponsePointMarshaller.marshall | protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
$this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
return $element;
} | php | protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
$this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
return $element;
} | [
"protected",
"function",
"marshall",
"(",
"QtiComponent",
"$",
"component",
")",
"{",
"$",
"element",
"=",
"static",
"::",
"getDOMCradle",
"(",
")",
"->",
"createElement",
"(",
"$",
"component",
"->",
"getQtiClassName",
"(",
")",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'identifier'",
",",
"$",
"component",
"->",
"getIdentifier",
"(",
")",
")",
";",
"return",
"$",
"element",
";",
"}"
] | Marshall a MapResponsePoint object into a DOMElement object.
@param \qtism\data\QtiComponent $component A MapResponsePoint object.
@return \DOMElement The according DOMElement object. | [
"Marshall",
"a",
"MapResponsePoint",
"object",
"into",
"a",
"DOMElement",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php#L43-L50 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php | MapResponsePointMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) {
$object = new MapResponsePoint($identifier);
return $object;
} else {
$msg = "The mandatory attribute 'identifier' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
} | php | protected function unmarshall(DOMElement $element)
{
if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) {
$object = new MapResponsePoint($identifier);
return $object;
} else {
$msg = "The mandatory attribute 'identifier' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"if",
"(",
"(",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'identifier'",
",",
"'string'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"MapResponsePoint",
"(",
"$",
"identifier",
")",
";",
"return",
"$",
"object",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The mandatory attribute 'identifier' is missing from element '\"",
".",
"$",
"element",
"->",
"localName",
".",
"\"'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}"
] | Unmarshall a DOMElement object corresponding to a QTI mapResponsePoint element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent A MapResponsePoint object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException If the mandatory attributes 'identifier' is missing. | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"a",
"QTI",
"mapResponsePoint",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php#L59-L69 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php | StatsOperatorMarshaller.marshallChildrenKnown | protected function marshallChildrenKnown(QtiComponent $component, array $elements)
{
$element = self::getDOMCradle()->createElement($component->getQtiClassName());
$this->setDOMElementAttribute($element, 'name', Statistics::getNameByConstant($component->getName()));
foreach ($elements as $elt) {
$element->appendChild($elt);
}
return $element;
} | php | protected function marshallChildrenKnown(QtiComponent $component, array $elements)
{
$element = self::getDOMCradle()->createElement($component->getQtiClassName());
$this->setDOMElementAttribute($element, 'name', Statistics::getNameByConstant($component->getName()));
foreach ($elements as $elt) {
$element->appendChild($elt);
}
return $element;
} | [
"protected",
"function",
"marshallChildrenKnown",
"(",
"QtiComponent",
"$",
"component",
",",
"array",
"$",
"elements",
")",
"{",
"$",
"element",
"=",
"self",
"::",
"getDOMCradle",
"(",
")",
"->",
"createElement",
"(",
"$",
"component",
"->",
"getQtiClassName",
"(",
")",
")",
";",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'name'",
",",
"Statistics",
"::",
"getNameByConstant",
"(",
"$",
"component",
"->",
"getName",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"elt",
")",
"{",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"elt",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] | Unmarshall a StatsOperator object into a QTI statsOperator element.
@param \qtism\data\QtiComponent $component The StatsOperator object to marshall.
@param array $elements An array of child DOMEelement objects.
@return \DOMElement The marshalled QTI statsOperator element. | [
"Unmarshall",
"a",
"StatsOperator",
"object",
"into",
"a",
"QTI",
"statsOperator",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php#L47-L58 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php | StatsOperatorMarshaller.unmarshallChildrenKnown | protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children)
{
if (($name = $this->getDOMElementAttributeAs($element, 'name')) !== null) {
$object = new StatsOperator($children, Statistics::getConstantByName($name));
return $object;
} else {
$msg = "The mandatory attribute 'name' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
} | php | protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children)
{
if (($name = $this->getDOMElementAttributeAs($element, 'name')) !== null) {
$object = new StatsOperator($children, Statistics::getConstantByName($name));
return $object;
} else {
$msg = "The mandatory attribute 'name' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
} | [
"protected",
"function",
"unmarshallChildrenKnown",
"(",
"DOMElement",
"$",
"element",
",",
"QtiComponentCollection",
"$",
"children",
")",
"{",
"if",
"(",
"(",
"$",
"name",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'name'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"StatsOperator",
"(",
"$",
"children",
",",
"Statistics",
"::",
"getConstantByName",
"(",
"$",
"name",
")",
")",
";",
"return",
"$",
"object",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The mandatory attribute 'name' is missing from element '\"",
".",
"$",
"element",
"->",
"localName",
".",
"\"'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"}"
] | Unmarshall a QTI statsOperator operator element into a StatsOperator object.
@param \DOMElement The statsOperator element to unmarshall.
@param \qtism\data\QtiComponentCollection A collection containing the child Expression objects composing the Operator.
@return \qtism\data\QtiComponent A StatsOperator object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException | [
"Unmarshall",
"a",
"QTI",
"statsOperator",
"operator",
"element",
"into",
"a",
"StatsOperator",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php#L68-L79 |
oat-sa/qti-sdk | src/qtism/runtime/common/VariableIdentifier.php | VariableIdentifier.setIdentifier | protected function setIdentifier($identifier)
{
if (Utils::isValidVariableIdentifier($identifier)) {
$this->identifier = $identifier;
} else {
$msg = "The identifier '${identifier}' is not a valid QTI Variable Name Identifier.";
throw new InvalidArgumentException($msg);
}
} | php | protected function setIdentifier($identifier)
{
if (Utils::isValidVariableIdentifier($identifier)) {
$this->identifier = $identifier;
} else {
$msg = "The identifier '${identifier}' is not a valid QTI Variable Name Identifier.";
throw new InvalidArgumentException($msg);
}
} | [
"protected",
"function",
"setIdentifier",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"Utils",
"::",
"isValidVariableIdentifier",
"(",
"$",
"identifier",
")",
")",
"{",
"$",
"this",
"->",
"identifier",
"=",
"$",
"identifier",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The identifier '${identifier}' is not a valid QTI Variable Name Identifier.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the identifier string.
@param string $identifier A prefixed identifier.
@throws \InvalidArgumentException If $identifier is not a valid prefixed identifier. | [
"Set",
"the",
"identifier",
"string",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/common/VariableIdentifier.php#L122-L130 |
oat-sa/qti-sdk | src/qtism/common/datatypes/QtiDuration.php | QtiDuration.getDays | public function getDays($total = false)
{
return ($total == true) ? $this->getInterval()->days : $this->getInterval()->d;
} | php | public function getDays($total = false)
{
return ($total == true) ? $this->getInterval()->days : $this->getInterval()->d;
} | [
"public",
"function",
"getDays",
"(",
"$",
"total",
"=",
"false",
")",
"{",
"return",
"(",
"$",
"total",
"==",
"true",
")",
"?",
"$",
"this",
"->",
"getInterval",
"(",
")",
"->",
"days",
":",
"$",
"this",
"->",
"getInterval",
"(",
")",
"->",
"d",
";",
"}"
] | Get the number of days.
@param boolean $total Wether the number of days must be the total of days or simply an offset (default).
@return int | [
"Get",
"the",
"number",
"of",
"days",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/datatypes/QtiDuration.php#L167-L170 |
oat-sa/qti-sdk | src/qtism/common/datatypes/QtiDuration.php | QtiDuration.getSeconds | public function getSeconds($total = false)
{
if ($total === false) {
return $this->getInterval()->s;
}
$sYears = 31536000 * $this->getYears();
$sMonths = 30 * 24 * 3600 * $this->getMonths();
$sDays = 24 * 3600 * $this->getDays();
$sHours = 3600 * $this->getHours();
$sMinutes = 60 * $this->getMinutes();
$sSeconds = $this->getSeconds();
return $sYears + $sMonths + $sDays + $sHours + $sMinutes + $sSeconds;
} | php | public function getSeconds($total = false)
{
if ($total === false) {
return $this->getInterval()->s;
}
$sYears = 31536000 * $this->getYears();
$sMonths = 30 * 24 * 3600 * $this->getMonths();
$sDays = 24 * 3600 * $this->getDays();
$sHours = 3600 * $this->getHours();
$sMinutes = 60 * $this->getMinutes();
$sSeconds = $this->getSeconds();
return $sYears + $sMonths + $sDays + $sHours + $sMinutes + $sSeconds;
} | [
"public",
"function",
"getSeconds",
"(",
"$",
"total",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"total",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getInterval",
"(",
")",
"->",
"s",
";",
"}",
"$",
"sYears",
"=",
"31536000",
"*",
"$",
"this",
"->",
"getYears",
"(",
")",
";",
"$",
"sMonths",
"=",
"30",
"*",
"24",
"*",
"3600",
"*",
"$",
"this",
"->",
"getMonths",
"(",
")",
";",
"$",
"sDays",
"=",
"24",
"*",
"3600",
"*",
"$",
"this",
"->",
"getDays",
"(",
")",
";",
"$",
"sHours",
"=",
"3600",
"*",
"$",
"this",
"->",
"getHours",
"(",
")",
";",
"$",
"sMinutes",
"=",
"60",
"*",
"$",
"this",
"->",
"getMinutes",
"(",
")",
";",
"$",
"sSeconds",
"=",
"$",
"this",
"->",
"getSeconds",
"(",
")",
";",
"return",
"$",
"sYears",
"+",
"$",
"sMonths",
"+",
"$",
"sDays",
"+",
"$",
"sHours",
"+",
"$",
"sMinutes",
"+",
"$",
"sSeconds",
";",
"}"
] | Get the number of seconds.
@param int $total Whether to get the total amount of seconds, as a single integer, that represents the complete duration.
@return int The value of the total duration in seconds. | [
"Get",
"the",
"number",
"of",
"seconds",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/datatypes/QtiDuration.php#L198-L212 |
oat-sa/qti-sdk | src/qtism/common/datatypes/QtiDuration.php | QtiDuration.add | public function add($duration)
{
$d1 = $this->refDate;
$d2 = clone $d1;
if ($duration instanceof QtiDuration) {
$toAdd = $duration;
} elseif ($duration instanceof DateInterval) {
$toAdd = self::createFromDateInterval($duration);
} else {
return;
}
$d2->add(new DateInterval($this->__toString()));
$d2->add(new DateInterval($toAdd->__toString()));
$interval = $d2->diff($d1);
$this->interval = $interval;
} | php | public function add($duration)
{
$d1 = $this->refDate;
$d2 = clone $d1;
if ($duration instanceof QtiDuration) {
$toAdd = $duration;
} elseif ($duration instanceof DateInterval) {
$toAdd = self::createFromDateInterval($duration);
} else {
return;
}
$d2->add(new DateInterval($this->__toString()));
$d2->add(new DateInterval($toAdd->__toString()));
$interval = $d2->diff($d1);
$this->interval = $interval;
} | [
"public",
"function",
"add",
"(",
"$",
"duration",
")",
"{",
"$",
"d1",
"=",
"$",
"this",
"->",
"refDate",
";",
"$",
"d2",
"=",
"clone",
"$",
"d1",
";",
"if",
"(",
"$",
"duration",
"instanceof",
"QtiDuration",
")",
"{",
"$",
"toAdd",
"=",
"$",
"duration",
";",
"}",
"elseif",
"(",
"$",
"duration",
"instanceof",
"DateInterval",
")",
"{",
"$",
"toAdd",
"=",
"self",
"::",
"createFromDateInterval",
"(",
"$",
"duration",
")",
";",
"}",
"else",
"{",
"return",
";",
"}",
"$",
"d2",
"->",
"add",
"(",
"new",
"DateInterval",
"(",
"$",
"this",
"->",
"__toString",
"(",
")",
")",
")",
";",
"$",
"d2",
"->",
"add",
"(",
"new",
"DateInterval",
"(",
"$",
"toAdd",
"->",
"__toString",
"(",
")",
")",
")",
";",
"$",
"interval",
"=",
"$",
"d2",
"->",
"diff",
"(",
"$",
"d1",
")",
";",
"$",
"this",
"->",
"interval",
"=",
"$",
"interval",
";",
"}"
] | Add a duration to this one.
For instance, PT1S + PT1S = PT2S.
@param \qtism\common\datatypes\Duration|\DateInterval $duration A Duration or DateInterval object. | [
"Add",
"a",
"duration",
"to",
"this",
"one",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/datatypes/QtiDuration.php#L298-L316 |
oat-sa/qti-sdk | src/qtism/common/datatypes/QtiDuration.php | QtiDuration.sub | public function sub(QtiDuration $duration)
{
if ($duration->longerThanOrEquals($this) === true) {
$this->setInterval(new DateInterval('PT0S'));
} else {
$refStrDate = '@0';
$tz = new DateTimeZone(self::TIMEZONE);
$d1 = new DateTime($refStrDate, $tz);
$d2 = new DateTime($refStrDate, $tz);
$d1->add(new DateInterval($this->__toString()));
$d2->add(new DateInterval($duration->__toString()));
$interval = $d1->diff($d2);
$this->setInterval($interval);
}
} | php | public function sub(QtiDuration $duration)
{
if ($duration->longerThanOrEquals($this) === true) {
$this->setInterval(new DateInterval('PT0S'));
} else {
$refStrDate = '@0';
$tz = new DateTimeZone(self::TIMEZONE);
$d1 = new DateTime($refStrDate, $tz);
$d2 = new DateTime($refStrDate, $tz);
$d1->add(new DateInterval($this->__toString()));
$d2->add(new DateInterval($duration->__toString()));
$interval = $d1->diff($d2);
$this->setInterval($interval);
}
} | [
"public",
"function",
"sub",
"(",
"QtiDuration",
"$",
"duration",
")",
"{",
"if",
"(",
"$",
"duration",
"->",
"longerThanOrEquals",
"(",
"$",
"this",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setInterval",
"(",
"new",
"DateInterval",
"(",
"'PT0S'",
")",
")",
";",
"}",
"else",
"{",
"$",
"refStrDate",
"=",
"'@0'",
";",
"$",
"tz",
"=",
"new",
"DateTimeZone",
"(",
"self",
"::",
"TIMEZONE",
")",
";",
"$",
"d1",
"=",
"new",
"DateTime",
"(",
"$",
"refStrDate",
",",
"$",
"tz",
")",
";",
"$",
"d2",
"=",
"new",
"DateTime",
"(",
"$",
"refStrDate",
",",
"$",
"tz",
")",
";",
"$",
"d1",
"->",
"add",
"(",
"new",
"DateInterval",
"(",
"$",
"this",
"->",
"__toString",
"(",
")",
")",
")",
";",
"$",
"d2",
"->",
"add",
"(",
"new",
"DateInterval",
"(",
"$",
"duration",
"->",
"__toString",
"(",
")",
")",
")",
";",
"$",
"interval",
"=",
"$",
"d1",
"->",
"diff",
"(",
"$",
"d2",
")",
";",
"$",
"this",
"->",
"setInterval",
"(",
"$",
"interval",
")",
";",
"}",
"}"
] | Subtract a duration to this one. If $duration is greather than or equal to
the current duration, a duration of 0 seconds is returned.
For instance P2S - P1S = P1S | [
"Subtract",
"a",
"duration",
"to",
"this",
"one",
".",
"If",
"$duration",
"is",
"greather",
"than",
"or",
"equal",
"to",
"the",
"current",
"duration",
"a",
"duration",
"of",
"0",
"seconds",
"is",
"returned",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/common/datatypes/QtiDuration.php#L324-L340 |
oat-sa/qti-sdk | src/qtism/runtime/expressions/OutcomeMaximumProcessor.php | OutcomeMaximumProcessor.process | public function process()
{
$itemSubset = $this->getItemSubset();
if (count($itemSubset) === 0) {
return null;
}
$testSession = $this->getState();
$outcomeIdentifier = $this->getExpression()->getOutcomeIdentifier();
// If no weightIdentifier specified, its value is an empty string ('').
$weightIdentifier = $this->getExpression()->getWeightIdentifier();
$result = new MultipleContainer(BaseType::FLOAT);
foreach ($itemSubset as $item) {
$itemSessions = $testSession->getAssessmentItemSessions($item->getIdentifier());
foreach ($itemSessions as $itemSession) {
// Apply variable mapping on $outcomeIdentifier.
$id = self::getMappedVariableIdentifier($itemSession->getAssessmentItem(), $outcomeIdentifier);
if ($id === false) {
// Variable name conflict.
continue;
}
if (isset($itemSession[$id]) && $itemSession->getVariable($id) instanceof OutcomeVariable) {
$var = $itemSession->getVariable($id);
$itemRefIdentifier = $itemSession->getAssessmentItem()->getIdentifier();
$weight = (empty($weightIdentifier) === true) ? false : $testSession->getWeight("${itemRefIdentifier}.${weightIdentifier}");
// Does this OutcomeVariable contain a value for normalMaximum?
if (($normalMaximum = $var->getNormalMaximum()) !== false) {
if ($weight === false) {
// No weight to be applied.
$result[] = new QtiFloat($normalMaximum);
} else {
// A weight has to be applied.
$result[] = new QtiFloat(floatval($normalMaximum *= $weight->getValue()));
}
} else {
// If any of the items in the given subset have no declared maximum
// the result is NULL.
return null;
}
} else {
return null;
}
}
}
return $result;
} | php | public function process()
{
$itemSubset = $this->getItemSubset();
if (count($itemSubset) === 0) {
return null;
}
$testSession = $this->getState();
$outcomeIdentifier = $this->getExpression()->getOutcomeIdentifier();
// If no weightIdentifier specified, its value is an empty string ('').
$weightIdentifier = $this->getExpression()->getWeightIdentifier();
$result = new MultipleContainer(BaseType::FLOAT);
foreach ($itemSubset as $item) {
$itemSessions = $testSession->getAssessmentItemSessions($item->getIdentifier());
foreach ($itemSessions as $itemSession) {
// Apply variable mapping on $outcomeIdentifier.
$id = self::getMappedVariableIdentifier($itemSession->getAssessmentItem(), $outcomeIdentifier);
if ($id === false) {
// Variable name conflict.
continue;
}
if (isset($itemSession[$id]) && $itemSession->getVariable($id) instanceof OutcomeVariable) {
$var = $itemSession->getVariable($id);
$itemRefIdentifier = $itemSession->getAssessmentItem()->getIdentifier();
$weight = (empty($weightIdentifier) === true) ? false : $testSession->getWeight("${itemRefIdentifier}.${weightIdentifier}");
// Does this OutcomeVariable contain a value for normalMaximum?
if (($normalMaximum = $var->getNormalMaximum()) !== false) {
if ($weight === false) {
// No weight to be applied.
$result[] = new QtiFloat($normalMaximum);
} else {
// A weight has to be applied.
$result[] = new QtiFloat(floatval($normalMaximum *= $weight->getValue()));
}
} else {
// If any of the items in the given subset have no declared maximum
// the result is NULL.
return null;
}
} else {
return null;
}
}
}
return $result;
} | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"itemSubset",
"=",
"$",
"this",
"->",
"getItemSubset",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"itemSubset",
")",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"$",
"testSession",
"=",
"$",
"this",
"->",
"getState",
"(",
")",
";",
"$",
"outcomeIdentifier",
"=",
"$",
"this",
"->",
"getExpression",
"(",
")",
"->",
"getOutcomeIdentifier",
"(",
")",
";",
"// If no weightIdentifier specified, its value is an empty string ('').",
"$",
"weightIdentifier",
"=",
"$",
"this",
"->",
"getExpression",
"(",
")",
"->",
"getWeightIdentifier",
"(",
")",
";",
"$",
"result",
"=",
"new",
"MultipleContainer",
"(",
"BaseType",
"::",
"FLOAT",
")",
";",
"foreach",
"(",
"$",
"itemSubset",
"as",
"$",
"item",
")",
"{",
"$",
"itemSessions",
"=",
"$",
"testSession",
"->",
"getAssessmentItemSessions",
"(",
"$",
"item",
"->",
"getIdentifier",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"itemSessions",
"as",
"$",
"itemSession",
")",
"{",
"// Apply variable mapping on $outcomeIdentifier.",
"$",
"id",
"=",
"self",
"::",
"getMappedVariableIdentifier",
"(",
"$",
"itemSession",
"->",
"getAssessmentItem",
"(",
")",
",",
"$",
"outcomeIdentifier",
")",
";",
"if",
"(",
"$",
"id",
"===",
"false",
")",
"{",
"// Variable name conflict.",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"itemSession",
"[",
"$",
"id",
"]",
")",
"&&",
"$",
"itemSession",
"->",
"getVariable",
"(",
"$",
"id",
")",
"instanceof",
"OutcomeVariable",
")",
"{",
"$",
"var",
"=",
"$",
"itemSession",
"->",
"getVariable",
"(",
"$",
"id",
")",
";",
"$",
"itemRefIdentifier",
"=",
"$",
"itemSession",
"->",
"getAssessmentItem",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"weight",
"=",
"(",
"empty",
"(",
"$",
"weightIdentifier",
")",
"===",
"true",
")",
"?",
"false",
":",
"$",
"testSession",
"->",
"getWeight",
"(",
"\"${itemRefIdentifier}.${weightIdentifier}\"",
")",
";",
"// Does this OutcomeVariable contain a value for normalMaximum?",
"if",
"(",
"(",
"$",
"normalMaximum",
"=",
"$",
"var",
"->",
"getNormalMaximum",
"(",
")",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"weight",
"===",
"false",
")",
"{",
"// No weight to be applied.",
"$",
"result",
"[",
"]",
"=",
"new",
"QtiFloat",
"(",
"$",
"normalMaximum",
")",
";",
"}",
"else",
"{",
"// A weight has to be applied.",
"$",
"result",
"[",
"]",
"=",
"new",
"QtiFloat",
"(",
"floatval",
"(",
"$",
"normalMaximum",
"*=",
"$",
"weight",
"->",
"getValue",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"// If any of the items in the given subset have no declared maximum",
"// the result is NULL.",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Process the related OutcomeMaximum expression.
@return \qtism\runtime\common\MultipleContainer|null A MultipleContainer object with baseType float containing all the retrieved normalMaximum values or NULL if no declared maximum in the sub-set.
@throws \qtism\runtime\expressions\ExpressionProcessingException | [
"Process",
"the",
"related",
"OutcomeMaximum",
"expression",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php#L55-L109 |
oat-sa/qti-sdk | src/qtism/data/rules/Ordering.php | Ordering.setShuffle | public function setShuffle($shuffle)
{
if (is_bool($shuffle)) {
$this->shuffle = $shuffle;
} else {
$msg = "Shuffle must be a boolean, '" . gettype($shuffle) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setShuffle($shuffle)
{
if (is_bool($shuffle)) {
$this->shuffle = $shuffle;
} else {
$msg = "Shuffle must be a boolean, '" . gettype($shuffle) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setShuffle",
"(",
"$",
"shuffle",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"shuffle",
")",
")",
"{",
"$",
"this",
"->",
"shuffle",
"=",
"$",
"shuffle",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"Shuffle must be a boolean, '\"",
".",
"gettype",
"(",
"$",
"shuffle",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set if the child elements must be randomized.
@param boolean $shuffle true if they must be randomized, false otherwise.
@throws \InvalidArgumentException If $shuffle is not a boolean. | [
"Set",
"if",
"the",
"child",
"elements",
"must",
"be",
"randomized",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/rules/Ordering.php#L75-L83 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php | TemplateDeclarationMarshaller.marshall | protected function marshall(QtiComponent $component)
{
$element = parent::marshall($component);
$version = $this->getVersion();
if ($component->isParamVariable() === true) {
$this->setDOMElementAttribute($element, 'paramVariable', true);
} elseif (Version::compare($version, '2.0.0', '==') === true && $component->isParamVariable() === false) {
$this->setDOMElementAttribute($element, 'paramVariable', false);
}
if ($component->isMathVariable() === true) {
$this->setDOMElementAttribute($element, 'mathVariable', true);
} elseif (Version::compare($version, '2.0.0', '==') === true && $component->isMathVariable() === false) {
$this->setDOMElementAttribute($element, 'mathVariable', false);
}
return $element;
} | php | protected function marshall(QtiComponent $component)
{
$element = parent::marshall($component);
$version = $this->getVersion();
if ($component->isParamVariable() === true) {
$this->setDOMElementAttribute($element, 'paramVariable', true);
} elseif (Version::compare($version, '2.0.0', '==') === true && $component->isParamVariable() === false) {
$this->setDOMElementAttribute($element, 'paramVariable', false);
}
if ($component->isMathVariable() === true) {
$this->setDOMElementAttribute($element, 'mathVariable', true);
} elseif (Version::compare($version, '2.0.0', '==') === true && $component->isMathVariable() === false) {
$this->setDOMElementAttribute($element, 'mathVariable', false);
}
return $element;
} | [
"protected",
"function",
"marshall",
"(",
"QtiComponent",
"$",
"component",
")",
"{",
"$",
"element",
"=",
"parent",
"::",
"marshall",
"(",
"$",
"component",
")",
";",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"$",
"component",
"->",
"isParamVariable",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'paramVariable'",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.0.0'",
",",
"'=='",
")",
"===",
"true",
"&&",
"$",
"component",
"->",
"isParamVariable",
"(",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'paramVariable'",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"component",
"->",
"isMathVariable",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'mathVariable'",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.0.0'",
",",
"'=='",
")",
"===",
"true",
"&&",
"$",
"component",
"->",
"isMathVariable",
"(",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"setDOMElementAttribute",
"(",
"$",
"element",
",",
"'mathVariable'",
",",
"false",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] | Marshall a TemplateDeclaration object into a DOMElement object.
@param \qtism\data\QtiComponent $component A TemplateDeclaration object.
@return \DOMElement The according DOMElement object. | [
"Marshall",
"a",
"TemplateDeclaration",
"object",
"into",
"a",
"DOMElement",
"object",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php#L45-L63 |
oat-sa/qti-sdk | src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php | TemplateDeclarationMarshaller.unmarshall | protected function unmarshall(DOMElement $element)
{
try {
$baseComponent = parent::unmarshall($element);
$object = new TemplateDeclaration($baseComponent->getIdentifier());
$object->setBaseType($baseComponent->getBaseType());
$object->setCardinality($baseComponent->getCardinality());
$object->setDefaultValue($baseComponent->getDefaultValue());
$version = $this->getVersion();
if (($paramVariable = $this->getDOMElementAttributeAs($element, 'paramVariable', 'boolean')) !== null) {
$object->setParamVariable($paramVariable);
} elseif (Version::compare($version, '2.0.0', '==') === true) {
$msg = "The mandatory attribute 'paramVariable' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
if (($mathVariable = $this->getDOMElementAttributeAs($element, 'mathVariable', 'boolean')) !== null) {
$object->setMathVariable($mathVariable);
} elseif (Version::compare($version, '2.0.0', '==') === true) {
$msg = "The mandatory attribute 'mathVariable' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
return $object;
} catch (InvalidArgumentException $e) {
$msg = "An unexpected error occured while unmarshalling the templateDeclaration.";
throw new UnmarshallingException($msg, $element, $e);
}
} | php | protected function unmarshall(DOMElement $element)
{
try {
$baseComponent = parent::unmarshall($element);
$object = new TemplateDeclaration($baseComponent->getIdentifier());
$object->setBaseType($baseComponent->getBaseType());
$object->setCardinality($baseComponent->getCardinality());
$object->setDefaultValue($baseComponent->getDefaultValue());
$version = $this->getVersion();
if (($paramVariable = $this->getDOMElementAttributeAs($element, 'paramVariable', 'boolean')) !== null) {
$object->setParamVariable($paramVariable);
} elseif (Version::compare($version, '2.0.0', '==') === true) {
$msg = "The mandatory attribute 'paramVariable' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
if (($mathVariable = $this->getDOMElementAttributeAs($element, 'mathVariable', 'boolean')) !== null) {
$object->setMathVariable($mathVariable);
} elseif (Version::compare($version, '2.0.0', '==') === true) {
$msg = "The mandatory attribute 'mathVariable' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
return $object;
} catch (InvalidArgumentException $e) {
$msg = "An unexpected error occured while unmarshalling the templateDeclaration.";
throw new UnmarshallingException($msg, $element, $e);
}
} | [
"protected",
"function",
"unmarshall",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"try",
"{",
"$",
"baseComponent",
"=",
"parent",
"::",
"unmarshall",
"(",
"$",
"element",
")",
";",
"$",
"object",
"=",
"new",
"TemplateDeclaration",
"(",
"$",
"baseComponent",
"->",
"getIdentifier",
"(",
")",
")",
";",
"$",
"object",
"->",
"setBaseType",
"(",
"$",
"baseComponent",
"->",
"getBaseType",
"(",
")",
")",
";",
"$",
"object",
"->",
"setCardinality",
"(",
"$",
"baseComponent",
"->",
"getCardinality",
"(",
")",
")",
";",
"$",
"object",
"->",
"setDefaultValue",
"(",
"$",
"baseComponent",
"->",
"getDefaultValue",
"(",
")",
")",
";",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"if",
"(",
"(",
"$",
"paramVariable",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'paramVariable'",
",",
"'boolean'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"object",
"->",
"setParamVariable",
"(",
"$",
"paramVariable",
")",
";",
"}",
"elseif",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.0.0'",
",",
"'=='",
")",
"===",
"true",
")",
"{",
"$",
"msg",
"=",
"\"The mandatory attribute 'paramVariable' is missing from element '\"",
".",
"$",
"element",
"->",
"localName",
".",
"\"'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"if",
"(",
"(",
"$",
"mathVariable",
"=",
"$",
"this",
"->",
"getDOMElementAttributeAs",
"(",
"$",
"element",
",",
"'mathVariable'",
",",
"'boolean'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"object",
"->",
"setMathVariable",
"(",
"$",
"mathVariable",
")",
";",
"}",
"elseif",
"(",
"Version",
"::",
"compare",
"(",
"$",
"version",
",",
"'2.0.0'",
",",
"'=='",
")",
"===",
"true",
")",
"{",
"$",
"msg",
"=",
"\"The mandatory attribute 'mathVariable' is missing from element '\"",
".",
"$",
"element",
"->",
"localName",
".",
"\"'.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
")",
";",
"}",
"return",
"$",
"object",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"An unexpected error occured while unmarshalling the templateDeclaration.\"",
";",
"throw",
"new",
"UnmarshallingException",
"(",
"$",
"msg",
",",
"$",
"element",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Unmarshall a DOMElement object corresponding to a QTI templateDeclaration element.
@param \DOMElement $element A DOMElement object.
@return \qtism\data\QtiComponent A TemplateDeclaration object.
@throws \qtism\data\storage\xml\marshalling\UnmarshallingException | [
"Unmarshall",
"a",
"DOMElement",
"object",
"corresponding",
"to",
"a",
"QTI",
"templateDeclaration",
"element",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php#L72-L102 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpDocument.php | PhpDocument.save | public function save($url)
{
$stack = new SplStack();
$stack->push($this->getDocumentComponent());
// 1st/2nd pass marker.
$marker = array();
// marshalling context.
$stream = new MemoryStream();
$stream->open();
$streamAccess = new PhpStreamAccess($stream);
$streamAccess->writeOpeningTag();
$ctx = new PhpMarshallingContext($streamAccess);
$ctx->setFormatOutput(true);
while (count($stack) > 0) {
$component = $stack->pop();
$isMarked = in_array($component, $marker, true);
if ($isMarked === false && ($component instanceof QtiComponent)) {
// -- QtiComponent node, 1st pass.
// Mark as explored.
array_push($marker, $component);
// Ask for a 2nd pass.
$stack->push($component);
// Let's look at the Bean properties and ask for a future exploration.
$bean = new Bean($component, false, self::getBaseImplementation($component));
$ctorGetters = $bean->getConstructorGetters();
$bodyGetters = $bean->getGetters(true);
$getters = array_reverse(array_merge($bodyGetters->getArrayCopy(), $ctorGetters->getArrayCopy()));
foreach ($getters as $getter) {
$stack->push(call_user_func(array($component, $getter->getName())));
}
}
// Warning!!! Check for Coords Datatype objects. Indeed, it extends AbstractCollection, but must not be considered as it is.
elseif ($isMarked === false && ($component instanceof AbstractCollection && !$component instanceof QtiCoords)) {
// AbstractCollection node, 1st pass.
// Mark as explored.
array_push($marker, $component);
// Ask for a 2nd pass.
$stack->push($component);
// Explore all values of the collection please!
$values = array_reverse($component->getArrayCopy());
foreach ($values as $val) {
$stack->push($val);
}
} elseif ($isMarked === true && $component instanceof QtiComponent) {
// QtiComponent, 2nd pass.
$marshaller = new PhpQtiComponentMarshaller($ctx, $component);
$marshaller->setAsInstanceOf(self::getBaseImplementation($component));
if ($component === $this->getDocumentComponent()) {
$marshaller->setVariableName('rootcomponent');
}
$marshaller->marshall();
} elseif ($component instanceof QtiDatatype) {
// Leaf node QtiDataType.
$marshaller = new PhpQtiDatatypeMarshaller($ctx, $component);
$marshaller->marshall();
} elseif ($isMarked === true && $component instanceof AbstractCollection) {
// AbstractCollection, 2nd pass.
$marshaller = new PhpCollectionMarshaller($ctx, $component);
$marshaller->marshall();
} elseif (PhpUtils::isScalar($component) === true) {
// Leaf node (QtiDatatype or PHP scalar (including the null value)).
$marshaller = new PhpScalarMarshaller($ctx, $component);
$marshaller->marshall();
} elseif (is_array($component) === true) {
// Leaf node array.
$marshaller = new PhpArrayMarshaller($ctx, $component);
$marshaller->marshall();
} else {
$msg = "Datatype '" . gettype($component) . "' cannot be handled by the PhpDocument::save() method.";
throw new PhpStorageException($msg);
}
}
$exists = file_exists($url);
$written = @file_put_contents($url, $stream->getBinary());
if ($written === false) {
throw new PhpStorageException("File located at '${url}' could not be written.");
}
if ($written !== false && $exists === true && function_exists('opcache_invalidate') === true) {
opcache_invalidate($url, true);
}
} | php | public function save($url)
{
$stack = new SplStack();
$stack->push($this->getDocumentComponent());
// 1st/2nd pass marker.
$marker = array();
// marshalling context.
$stream = new MemoryStream();
$stream->open();
$streamAccess = new PhpStreamAccess($stream);
$streamAccess->writeOpeningTag();
$ctx = new PhpMarshallingContext($streamAccess);
$ctx->setFormatOutput(true);
while (count($stack) > 0) {
$component = $stack->pop();
$isMarked = in_array($component, $marker, true);
if ($isMarked === false && ($component instanceof QtiComponent)) {
// -- QtiComponent node, 1st pass.
// Mark as explored.
array_push($marker, $component);
// Ask for a 2nd pass.
$stack->push($component);
// Let's look at the Bean properties and ask for a future exploration.
$bean = new Bean($component, false, self::getBaseImplementation($component));
$ctorGetters = $bean->getConstructorGetters();
$bodyGetters = $bean->getGetters(true);
$getters = array_reverse(array_merge($bodyGetters->getArrayCopy(), $ctorGetters->getArrayCopy()));
foreach ($getters as $getter) {
$stack->push(call_user_func(array($component, $getter->getName())));
}
}
// Warning!!! Check for Coords Datatype objects. Indeed, it extends AbstractCollection, but must not be considered as it is.
elseif ($isMarked === false && ($component instanceof AbstractCollection && !$component instanceof QtiCoords)) {
// AbstractCollection node, 1st pass.
// Mark as explored.
array_push($marker, $component);
// Ask for a 2nd pass.
$stack->push($component);
// Explore all values of the collection please!
$values = array_reverse($component->getArrayCopy());
foreach ($values as $val) {
$stack->push($val);
}
} elseif ($isMarked === true && $component instanceof QtiComponent) {
// QtiComponent, 2nd pass.
$marshaller = new PhpQtiComponentMarshaller($ctx, $component);
$marshaller->setAsInstanceOf(self::getBaseImplementation($component));
if ($component === $this->getDocumentComponent()) {
$marshaller->setVariableName('rootcomponent');
}
$marshaller->marshall();
} elseif ($component instanceof QtiDatatype) {
// Leaf node QtiDataType.
$marshaller = new PhpQtiDatatypeMarshaller($ctx, $component);
$marshaller->marshall();
} elseif ($isMarked === true && $component instanceof AbstractCollection) {
// AbstractCollection, 2nd pass.
$marshaller = new PhpCollectionMarshaller($ctx, $component);
$marshaller->marshall();
} elseif (PhpUtils::isScalar($component) === true) {
// Leaf node (QtiDatatype or PHP scalar (including the null value)).
$marshaller = new PhpScalarMarshaller($ctx, $component);
$marshaller->marshall();
} elseif (is_array($component) === true) {
// Leaf node array.
$marshaller = new PhpArrayMarshaller($ctx, $component);
$marshaller->marshall();
} else {
$msg = "Datatype '" . gettype($component) . "' cannot be handled by the PhpDocument::save() method.";
throw new PhpStorageException($msg);
}
}
$exists = file_exists($url);
$written = @file_put_contents($url, $stream->getBinary());
if ($written === false) {
throw new PhpStorageException("File located at '${url}' could not be written.");
}
if ($written !== false && $exists === true && function_exists('opcache_invalidate') === true) {
opcache_invalidate($url, true);
}
} | [
"public",
"function",
"save",
"(",
"$",
"url",
")",
"{",
"$",
"stack",
"=",
"new",
"SplStack",
"(",
")",
";",
"$",
"stack",
"->",
"push",
"(",
"$",
"this",
"->",
"getDocumentComponent",
"(",
")",
")",
";",
"// 1st/2nd pass marker.",
"$",
"marker",
"=",
"array",
"(",
")",
";",
"// marshalling context.",
"$",
"stream",
"=",
"new",
"MemoryStream",
"(",
")",
";",
"$",
"stream",
"->",
"open",
"(",
")",
";",
"$",
"streamAccess",
"=",
"new",
"PhpStreamAccess",
"(",
"$",
"stream",
")",
";",
"$",
"streamAccess",
"->",
"writeOpeningTag",
"(",
")",
";",
"$",
"ctx",
"=",
"new",
"PhpMarshallingContext",
"(",
"$",
"streamAccess",
")",
";",
"$",
"ctx",
"->",
"setFormatOutput",
"(",
"true",
")",
";",
"while",
"(",
"count",
"(",
"$",
"stack",
")",
">",
"0",
")",
"{",
"$",
"component",
"=",
"$",
"stack",
"->",
"pop",
"(",
")",
";",
"$",
"isMarked",
"=",
"in_array",
"(",
"$",
"component",
",",
"$",
"marker",
",",
"true",
")",
";",
"if",
"(",
"$",
"isMarked",
"===",
"false",
"&&",
"(",
"$",
"component",
"instanceof",
"QtiComponent",
")",
")",
"{",
"// -- QtiComponent node, 1st pass.",
"// Mark as explored.",
"array_push",
"(",
"$",
"marker",
",",
"$",
"component",
")",
";",
"// Ask for a 2nd pass.",
"$",
"stack",
"->",
"push",
"(",
"$",
"component",
")",
";",
"// Let's look at the Bean properties and ask for a future exploration.",
"$",
"bean",
"=",
"new",
"Bean",
"(",
"$",
"component",
",",
"false",
",",
"self",
"::",
"getBaseImplementation",
"(",
"$",
"component",
")",
")",
";",
"$",
"ctorGetters",
"=",
"$",
"bean",
"->",
"getConstructorGetters",
"(",
")",
";",
"$",
"bodyGetters",
"=",
"$",
"bean",
"->",
"getGetters",
"(",
"true",
")",
";",
"$",
"getters",
"=",
"array_reverse",
"(",
"array_merge",
"(",
"$",
"bodyGetters",
"->",
"getArrayCopy",
"(",
")",
",",
"$",
"ctorGetters",
"->",
"getArrayCopy",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"getters",
"as",
"$",
"getter",
")",
"{",
"$",
"stack",
"->",
"push",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"component",
",",
"$",
"getter",
"->",
"getName",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"// Warning!!! Check for Coords Datatype objects. Indeed, it extends AbstractCollection, but must not be considered as it is.",
"elseif",
"(",
"$",
"isMarked",
"===",
"false",
"&&",
"(",
"$",
"component",
"instanceof",
"AbstractCollection",
"&&",
"!",
"$",
"component",
"instanceof",
"QtiCoords",
")",
")",
"{",
"// AbstractCollection node, 1st pass.",
"// Mark as explored.",
"array_push",
"(",
"$",
"marker",
",",
"$",
"component",
")",
";",
"// Ask for a 2nd pass.",
"$",
"stack",
"->",
"push",
"(",
"$",
"component",
")",
";",
"// Explore all values of the collection please!",
"$",
"values",
"=",
"array_reverse",
"(",
"$",
"component",
"->",
"getArrayCopy",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"val",
")",
"{",
"$",
"stack",
"->",
"push",
"(",
"$",
"val",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"isMarked",
"===",
"true",
"&&",
"$",
"component",
"instanceof",
"QtiComponent",
")",
"{",
"// QtiComponent, 2nd pass.",
"$",
"marshaller",
"=",
"new",
"PhpQtiComponentMarshaller",
"(",
"$",
"ctx",
",",
"$",
"component",
")",
";",
"$",
"marshaller",
"->",
"setAsInstanceOf",
"(",
"self",
"::",
"getBaseImplementation",
"(",
"$",
"component",
")",
")",
";",
"if",
"(",
"$",
"component",
"===",
"$",
"this",
"->",
"getDocumentComponent",
"(",
")",
")",
"{",
"$",
"marshaller",
"->",
"setVariableName",
"(",
"'rootcomponent'",
")",
";",
"}",
"$",
"marshaller",
"->",
"marshall",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"component",
"instanceof",
"QtiDatatype",
")",
"{",
"// Leaf node QtiDataType.",
"$",
"marshaller",
"=",
"new",
"PhpQtiDatatypeMarshaller",
"(",
"$",
"ctx",
",",
"$",
"component",
")",
";",
"$",
"marshaller",
"->",
"marshall",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"isMarked",
"===",
"true",
"&&",
"$",
"component",
"instanceof",
"AbstractCollection",
")",
"{",
"// AbstractCollection, 2nd pass.",
"$",
"marshaller",
"=",
"new",
"PhpCollectionMarshaller",
"(",
"$",
"ctx",
",",
"$",
"component",
")",
";",
"$",
"marshaller",
"->",
"marshall",
"(",
")",
";",
"}",
"elseif",
"(",
"PhpUtils",
"::",
"isScalar",
"(",
"$",
"component",
")",
"===",
"true",
")",
"{",
"// Leaf node (QtiDatatype or PHP scalar (including the null value)).",
"$",
"marshaller",
"=",
"new",
"PhpScalarMarshaller",
"(",
"$",
"ctx",
",",
"$",
"component",
")",
";",
"$",
"marshaller",
"->",
"marshall",
"(",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"component",
")",
"===",
"true",
")",
"{",
"// Leaf node array.",
"$",
"marshaller",
"=",
"new",
"PhpArrayMarshaller",
"(",
"$",
"ctx",
",",
"$",
"component",
")",
";",
"$",
"marshaller",
"->",
"marshall",
"(",
")",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"Datatype '\"",
".",
"gettype",
"(",
"$",
"component",
")",
".",
"\"' cannot be handled by the PhpDocument::save() method.\"",
";",
"throw",
"new",
"PhpStorageException",
"(",
"$",
"msg",
")",
";",
"}",
"}",
"$",
"exists",
"=",
"file_exists",
"(",
"$",
"url",
")",
";",
"$",
"written",
"=",
"@",
"file_put_contents",
"(",
"$",
"url",
",",
"$",
"stream",
"->",
"getBinary",
"(",
")",
")",
";",
"if",
"(",
"$",
"written",
"===",
"false",
")",
"{",
"throw",
"new",
"PhpStorageException",
"(",
"\"File located at '${url}' could not be written.\"",
")",
";",
"}",
"if",
"(",
"$",
"written",
"!==",
"false",
"&&",
"$",
"exists",
"===",
"true",
"&&",
"function_exists",
"(",
"'opcache_invalidate'",
")",
"===",
"true",
")",
"{",
"opcache_invalidate",
"(",
"$",
"url",
",",
"true",
")",
";",
"}",
"}"
] | Save the PhpDocument to a specific location.
@param string $url A URL (Uniform Resource Locator) describing where to save the document.
@throws PhpStorageException If an error occurs while saving. | [
"Save",
"the",
"PhpDocument",
"to",
"a",
"specific",
"location",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpDocument.php#L77-L170 |
oat-sa/qti-sdk | src/qtism/data/storage/php/PhpDocument.php | PhpDocument.load | public function load($url)
{
if (is_readable($url) === false) {
$msg = "The PHP document located at '${url}' is not readable or does not exist.";
throw new PhpStorageException($msg, PhpStorageException::READ);
}
try {
// Will return $rootcomponent.
require $url;
$this->setDocumentComponent($rootcomponent);
$this->setUrl($url);
} catch (Exception $e) {
$msg = "A PHP Runtime Error occured while executing the PHP source code representing the document to be loaded at '${url}'.";
throw new PhpStorageException($msg, PhpStorageException::UNKNOWN, $e);
}
} | php | public function load($url)
{
if (is_readable($url) === false) {
$msg = "The PHP document located at '${url}' is not readable or does not exist.";
throw new PhpStorageException($msg, PhpStorageException::READ);
}
try {
// Will return $rootcomponent.
require $url;
$this->setDocumentComponent($rootcomponent);
$this->setUrl($url);
} catch (Exception $e) {
$msg = "A PHP Runtime Error occured while executing the PHP source code representing the document to be loaded at '${url}'.";
throw new PhpStorageException($msg, PhpStorageException::UNKNOWN, $e);
}
} | [
"public",
"function",
"load",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"url",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"The PHP document located at '${url}' is not readable or does not exist.\"",
";",
"throw",
"new",
"PhpStorageException",
"(",
"$",
"msg",
",",
"PhpStorageException",
"::",
"READ",
")",
";",
"}",
"try",
"{",
"// Will return $rootcomponent.",
"require",
"$",
"url",
";",
"$",
"this",
"->",
"setDocumentComponent",
"(",
"$",
"rootcomponent",
")",
";",
"$",
"this",
"->",
"setUrl",
"(",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"\"A PHP Runtime Error occured while executing the PHP source code representing the document to be loaded at '${url}'.\"",
";",
"throw",
"new",
"PhpStorageException",
"(",
"$",
"msg",
",",
"PhpStorageException",
"::",
"UNKNOWN",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Load a PHP QTI document at the specified URL.
@param string $url A URL (Uniform Resource Locator) describing where to find the PHP document to load.
@throws PhpStorageException If an error occurs while loading the PHP file located at $url. | [
"Load",
"a",
"PHP",
"QTI",
"document",
"at",
"the",
"specified",
"URL",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/storage/php/PhpDocument.php#L178-L194 |
oat-sa/qti-sdk | src/qtism/data/rules/TemplateProcessing.php | TemplateProcessing.setTemplateRules | public function setTemplateRules(TemplateRuleCollection $templateRules)
{
if (count($templateRules) > 0) {
$this->templateRules = $templateRules;
} else {
$msg = "A TemplateProcessing object must be composed of at least one TemplateRule object, none given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setTemplateRules(TemplateRuleCollection $templateRules)
{
if (count($templateRules) > 0) {
$this->templateRules = $templateRules;
} else {
$msg = "A TemplateProcessing object must be composed of at least one TemplateRule object, none given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setTemplateRules",
"(",
"TemplateRuleCollection",
"$",
"templateRules",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"templateRules",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"templateRules",
"=",
"$",
"templateRules",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"A TemplateProcessing object must be composed of at least one TemplateRule object, none given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the collection of TemplateRule objects composing the template processing.
@param \qtism\data\rules\TemplateRuleCollection $templateRules A collection of TemplateRule objects.
@throws \InvalidArgumentException If $templateRules does not contain any TemplateRule objects. | [
"Set",
"the",
"collection",
"of",
"TemplateRule",
"objects",
"composing",
"the",
"template",
"processing",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/rules/TemplateProcessing.php#L67-L75 |
oat-sa/qti-sdk | src/qtism/runtime/expressions/operators/EqualProcessor.php | EqualProcessor.process | public function process()
{
$operands = $this->getOperands();
if ($operands->containsNull() === true) {
return null;
}
if ($operands->exclusivelySingle() === false) {
$msg = "The Equal operator only accepts operands with a single cardinality.";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
}
if ($operands->exclusivelyNumeric() === false) {
$msg = "The Equal operator only accepts operands with an integer or float baseType";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
}
$operand1 = $operands[0];
$operand2 = $operands[1];
$expression = $this->getExpression();
if ($expression->getToleranceMode() === ToleranceMode::EXACT) {
return new QtiBoolean($operand1->getValue() == $operand2->getValue());
} else {
$tolerance = $expression->getTolerance();
if (gettype($tolerance[0]) === 'string') {
$strTolerance = $tolerance;
$tolerance = array();
// variableRef to handle.
$state = $this->getState();
$tolerance0Name = Utils::sanitizeVariableRef($strTolerance[0]);
$varValue = $state[$tolerance0Name];
if (is_null($varValue)) {
$msg = "The variable with name '${tolerance0Name}' could not be resolved.";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE);
} elseif (!$varValue instanceof QtiFloat) {
$msg = "The variable with name '${tolerance0Name}' is not a float.";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_VARIABLE_BASETYPE);
}
$tolerance[] = $varValue->getValue();
if (isset($strTolerance[1]) && gettype($strTolerance[1]) === 'string') {
// A second variableRef to handle.
$tolerance1Name = Utils::sanitizeVariableRef($strTolerance[1]);
if (($varValue = $state[$tolerance1Name]) !== null && $varValue instanceof QtiFloat) {
$tolerance[] = $varValue->getValue();
}
}
}
if ($expression->getToleranceMode() === ToleranceMode::ABSOLUTE) {
$t0 = $operand1->getValue() - $tolerance[0];
$t1 = $operand1->getValue() + ((isset($tolerance[1])) ? $tolerance[1] : $tolerance[0]);
$moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0;
$lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1;
return new QtiBoolean($moreThanLower && $lessThanUpper);
} else {
// Tolerance mode RELATIVE
$tolerance = $expression->getTolerance();
$t0 = $operand1->getValue() * (1 - $tolerance[0] / 100);
$t1 = $operand1->getValue() * (1 + ((isset($tolerance[1])) ? $tolerance[1] : $tolerance[0]) / 100);
$moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0;
$lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1;
return new QtiBoolean($moreThanLower && $lessThanUpper);
}
}
} | php | public function process()
{
$operands = $this->getOperands();
if ($operands->containsNull() === true) {
return null;
}
if ($operands->exclusivelySingle() === false) {
$msg = "The Equal operator only accepts operands with a single cardinality.";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
}
if ($operands->exclusivelyNumeric() === false) {
$msg = "The Equal operator only accepts operands with an integer or float baseType";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
}
$operand1 = $operands[0];
$operand2 = $operands[1];
$expression = $this->getExpression();
if ($expression->getToleranceMode() === ToleranceMode::EXACT) {
return new QtiBoolean($operand1->getValue() == $operand2->getValue());
} else {
$tolerance = $expression->getTolerance();
if (gettype($tolerance[0]) === 'string') {
$strTolerance = $tolerance;
$tolerance = array();
// variableRef to handle.
$state = $this->getState();
$tolerance0Name = Utils::sanitizeVariableRef($strTolerance[0]);
$varValue = $state[$tolerance0Name];
if (is_null($varValue)) {
$msg = "The variable with name '${tolerance0Name}' could not be resolved.";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE);
} elseif (!$varValue instanceof QtiFloat) {
$msg = "The variable with name '${tolerance0Name}' is not a float.";
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_VARIABLE_BASETYPE);
}
$tolerance[] = $varValue->getValue();
if (isset($strTolerance[1]) && gettype($strTolerance[1]) === 'string') {
// A second variableRef to handle.
$tolerance1Name = Utils::sanitizeVariableRef($strTolerance[1]);
if (($varValue = $state[$tolerance1Name]) !== null && $varValue instanceof QtiFloat) {
$tolerance[] = $varValue->getValue();
}
}
}
if ($expression->getToleranceMode() === ToleranceMode::ABSOLUTE) {
$t0 = $operand1->getValue() - $tolerance[0];
$t1 = $operand1->getValue() + ((isset($tolerance[1])) ? $tolerance[1] : $tolerance[0]);
$moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0;
$lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1;
return new QtiBoolean($moreThanLower && $lessThanUpper);
} else {
// Tolerance mode RELATIVE
$tolerance = $expression->getTolerance();
$t0 = $operand1->getValue() * (1 - $tolerance[0] / 100);
$t1 = $operand1->getValue() * (1 + ((isset($tolerance[1])) ? $tolerance[1] : $tolerance[0]) / 100);
$moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0;
$lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1;
return new QtiBoolean($moreThanLower && $lessThanUpper);
}
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"operands",
"=",
"$",
"this",
"->",
"getOperands",
"(",
")",
";",
"if",
"(",
"$",
"operands",
"->",
"containsNull",
"(",
")",
"===",
"true",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"operands",
"->",
"exclusivelySingle",
"(",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"The Equal operator only accepts operands with a single cardinality.\"",
";",
"throw",
"new",
"OperatorProcessingException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"OperatorProcessingException",
"::",
"WRONG_CARDINALITY",
")",
";",
"}",
"if",
"(",
"$",
"operands",
"->",
"exclusivelyNumeric",
"(",
")",
"===",
"false",
")",
"{",
"$",
"msg",
"=",
"\"The Equal operator only accepts operands with an integer or float baseType\"",
";",
"throw",
"new",
"OperatorProcessingException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"OperatorProcessingException",
"::",
"WRONG_BASETYPE",
")",
";",
"}",
"$",
"operand1",
"=",
"$",
"operands",
"[",
"0",
"]",
";",
"$",
"operand2",
"=",
"$",
"operands",
"[",
"1",
"]",
";",
"$",
"expression",
"=",
"$",
"this",
"->",
"getExpression",
"(",
")",
";",
"if",
"(",
"$",
"expression",
"->",
"getToleranceMode",
"(",
")",
"===",
"ToleranceMode",
"::",
"EXACT",
")",
"{",
"return",
"new",
"QtiBoolean",
"(",
"$",
"operand1",
"->",
"getValue",
"(",
")",
"==",
"$",
"operand2",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"tolerance",
"=",
"$",
"expression",
"->",
"getTolerance",
"(",
")",
";",
"if",
"(",
"gettype",
"(",
"$",
"tolerance",
"[",
"0",
"]",
")",
"===",
"'string'",
")",
"{",
"$",
"strTolerance",
"=",
"$",
"tolerance",
";",
"$",
"tolerance",
"=",
"array",
"(",
")",
";",
"// variableRef to handle.",
"$",
"state",
"=",
"$",
"this",
"->",
"getState",
"(",
")",
";",
"$",
"tolerance0Name",
"=",
"Utils",
"::",
"sanitizeVariableRef",
"(",
"$",
"strTolerance",
"[",
"0",
"]",
")",
";",
"$",
"varValue",
"=",
"$",
"state",
"[",
"$",
"tolerance0Name",
"]",
";",
"if",
"(",
"is_null",
"(",
"$",
"varValue",
")",
")",
"{",
"$",
"msg",
"=",
"\"The variable with name '${tolerance0Name}' could not be resolved.\"",
";",
"throw",
"new",
"OperatorProcessingException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"OperatorProcessingException",
"::",
"NONEXISTENT_VARIABLE",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"varValue",
"instanceof",
"QtiFloat",
")",
"{",
"$",
"msg",
"=",
"\"The variable with name '${tolerance0Name}' is not a float.\"",
";",
"throw",
"new",
"OperatorProcessingException",
"(",
"$",
"msg",
",",
"$",
"this",
",",
"OperatorProcessingException",
"::",
"WRONG_VARIABLE_BASETYPE",
")",
";",
"}",
"$",
"tolerance",
"[",
"]",
"=",
"$",
"varValue",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"strTolerance",
"[",
"1",
"]",
")",
"&&",
"gettype",
"(",
"$",
"strTolerance",
"[",
"1",
"]",
")",
"===",
"'string'",
")",
"{",
"// A second variableRef to handle.",
"$",
"tolerance1Name",
"=",
"Utils",
"::",
"sanitizeVariableRef",
"(",
"$",
"strTolerance",
"[",
"1",
"]",
")",
";",
"if",
"(",
"(",
"$",
"varValue",
"=",
"$",
"state",
"[",
"$",
"tolerance1Name",
"]",
")",
"!==",
"null",
"&&",
"$",
"varValue",
"instanceof",
"QtiFloat",
")",
"{",
"$",
"tolerance",
"[",
"]",
"=",
"$",
"varValue",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"expression",
"->",
"getToleranceMode",
"(",
")",
"===",
"ToleranceMode",
"::",
"ABSOLUTE",
")",
"{",
"$",
"t0",
"=",
"$",
"operand1",
"->",
"getValue",
"(",
")",
"-",
"$",
"tolerance",
"[",
"0",
"]",
";",
"$",
"t1",
"=",
"$",
"operand1",
"->",
"getValue",
"(",
")",
"+",
"(",
"(",
"isset",
"(",
"$",
"tolerance",
"[",
"1",
"]",
")",
")",
"?",
"$",
"tolerance",
"[",
"1",
"]",
":",
"$",
"tolerance",
"[",
"0",
"]",
")",
";",
"$",
"moreThanLower",
"=",
"(",
"$",
"expression",
"->",
"doesIncludeLowerBound",
"(",
")",
")",
"?",
"$",
"operand2",
"->",
"getValue",
"(",
")",
">=",
"$",
"t0",
":",
"$",
"operand2",
"->",
"getValue",
"(",
")",
">",
"$",
"t0",
";",
"$",
"lessThanUpper",
"=",
"(",
"$",
"expression",
"->",
"doesIncludeUpperBound",
"(",
")",
")",
"?",
"$",
"operand2",
"->",
"getValue",
"(",
")",
"<=",
"$",
"t1",
":",
"$",
"operand2",
"->",
"getValue",
"(",
")",
"<",
"$",
"t1",
";",
"return",
"new",
"QtiBoolean",
"(",
"$",
"moreThanLower",
"&&",
"$",
"lessThanUpper",
")",
";",
"}",
"else",
"{",
"// Tolerance mode RELATIVE",
"$",
"tolerance",
"=",
"$",
"expression",
"->",
"getTolerance",
"(",
")",
";",
"$",
"t0",
"=",
"$",
"operand1",
"->",
"getValue",
"(",
")",
"*",
"(",
"1",
"-",
"$",
"tolerance",
"[",
"0",
"]",
"/",
"100",
")",
";",
"$",
"t1",
"=",
"$",
"operand1",
"->",
"getValue",
"(",
")",
"*",
"(",
"1",
"+",
"(",
"(",
"isset",
"(",
"$",
"tolerance",
"[",
"1",
"]",
")",
")",
"?",
"$",
"tolerance",
"[",
"1",
"]",
":",
"$",
"tolerance",
"[",
"0",
"]",
")",
"/",
"100",
")",
";",
"$",
"moreThanLower",
"=",
"(",
"$",
"expression",
"->",
"doesIncludeLowerBound",
"(",
")",
")",
"?",
"$",
"operand2",
"->",
"getValue",
"(",
")",
">=",
"$",
"t0",
":",
"$",
"operand2",
"->",
"getValue",
"(",
")",
">",
"$",
"t0",
";",
"$",
"lessThanUpper",
"=",
"(",
"$",
"expression",
"->",
"doesIncludeUpperBound",
"(",
")",
")",
"?",
"$",
"operand2",
"->",
"getValue",
"(",
")",
"<=",
"$",
"t1",
":",
"$",
"operand2",
"->",
"getValue",
"(",
")",
"<",
"$",
"t1",
";",
"return",
"new",
"QtiBoolean",
"(",
"$",
"moreThanLower",
"&&",
"$",
"lessThanUpper",
")",
";",
"}",
"}",
"}"
] | Process the Equal operator.
@return boolean|null Whether the two expressions are numerically equal and false if they are not or NULL if either sub-expression is NULL.
@throws \qtism\runtime\expressions\operators\OperatorProcessingException | [
"Process",
"the",
"Equal",
"operator",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/runtime/expressions/operators/EqualProcessor.php#L73-L150 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setBase | public function setBase($base)
{
if (is_int($base) === true && $base >= 0) {
$this->base = $base;
} else {
$msg = "The 'base' argument must be a positive (>= 0) integer value, '" . gettype($base) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setBase($base)
{
if (is_int($base) === true && $base >= 0) {
$this->base = $base;
} else {
$msg = "The 'base' argument must be a positive (>= 0) integer value, '" . gettype($base) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setBase",
"(",
"$",
"base",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"base",
")",
"===",
"true",
"&&",
"$",
"base",
">=",
"0",
")",
"{",
"$",
"this",
"->",
"base",
"=",
"$",
"base",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'base' argument must be a positive (>= 0) integer value, '\"",
".",
"gettype",
"(",
"$",
"base",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | If the interaction is bound to a numeric response variable, get the number base in which
to interpret the value entered by the candidate.
@param integer $base A positive (>= 0) integer.
@throws \InvalidArgumentException If $base is not a positive integer. | [
"If",
"the",
"interaction",
"is",
"bound",
"to",
"a",
"numeric",
"response",
"variable",
"get",
"the",
"number",
"base",
"in",
"which",
"to",
"interpret",
"the",
"value",
"entered",
"by",
"the",
"candidate",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L188-L196 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setStringIdentifier | public function setStringIdentifier($stringIdentifier)
{
if (Format::isIdentifier($stringIdentifier, false) === true || (is_string($stringIdentifier) && empty($stringIdentifier) === true)) {
$this->stringIdentifier = $stringIdentifier;
} else {
$msg = "The 'stringIdentifier' argument must be a valid QTI identifier or an empty string, '" . $stringIdentifier . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setStringIdentifier($stringIdentifier)
{
if (Format::isIdentifier($stringIdentifier, false) === true || (is_string($stringIdentifier) && empty($stringIdentifier) === true)) {
$this->stringIdentifier = $stringIdentifier;
} else {
$msg = "The 'stringIdentifier' argument must be a valid QTI identifier or an empty string, '" . $stringIdentifier . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setStringIdentifier",
"(",
"$",
"stringIdentifier",
")",
"{",
"if",
"(",
"Format",
"::",
"isIdentifier",
"(",
"$",
"stringIdentifier",
",",
"false",
")",
"===",
"true",
"||",
"(",
"is_string",
"(",
"$",
"stringIdentifier",
")",
"&&",
"empty",
"(",
"$",
"stringIdentifier",
")",
"===",
"true",
")",
")",
"{",
"$",
"this",
"->",
"stringIdentifier",
"=",
"$",
"stringIdentifier",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'stringIdentifier' argument must be a valid QTI identifier or an empty string, '\"",
".",
"$",
"stringIdentifier",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | If the interaction is bound to a numeric response variable, set the identifier of the response variable where the
plain text entered by the candidate will be stored. If $stringIdentifier is an empty string, it means that
there is no value for the stringIdentifier attribute.
@param string $stringIdentifier A QTI Identifier or an empty string.
@throws \InvalidArgumentException If $stringIdentifier is not a valid QTIIdentifier nor an empty string. | [
"If",
"the",
"interaction",
"is",
"bound",
"to",
"a",
"numeric",
"response",
"variable",
"set",
"the",
"identifier",
"of",
"the",
"response",
"variable",
"where",
"the",
"plain",
"text",
"entered",
"by",
"the",
"candidate",
"will",
"be",
"stored",
".",
"If",
"$stringIdentifier",
"is",
"an",
"empty",
"string",
"it",
"means",
"that",
"there",
"is",
"no",
"value",
"for",
"the",
"stringIdentifier",
"attribute",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L217-L225 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setExpectedLength | public function setExpectedLength($expectedLength)
{
if (is_int($expectedLength) && ($expectedLength > 0 || $expectedLength === -1)) {
$this->expectedLength = $expectedLength;
} else {
$msg = "The 'expectedLength' argument must be a strictly positive (> 0) integer or -1, '" . gettype($expectedLength) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setExpectedLength($expectedLength)
{
if (is_int($expectedLength) && ($expectedLength > 0 || $expectedLength === -1)) {
$this->expectedLength = $expectedLength;
} else {
$msg = "The 'expectedLength' argument must be a strictly positive (> 0) integer or -1, '" . gettype($expectedLength) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setExpectedLength",
"(",
"$",
"expectedLength",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"expectedLength",
")",
"&&",
"(",
"$",
"expectedLength",
">",
"0",
"||",
"$",
"expectedLength",
"===",
"-",
"1",
")",
")",
"{",
"$",
"this",
"->",
"expectedLength",
"=",
"$",
"expectedLength",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'expectedLength' argument must be a strictly positive (> 0) integer or -1, '\"",
".",
"gettype",
"(",
"$",
"expectedLength",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the hint to the candidate about the expected overall length of its response. If $expectedLength
is -1, it means that no value is defined for the expectedLength attribute.
@param integer A strictly positive (> 0) integer or -1.
@throws \InvalidArgumentException If $expectedLength is not a strictly positive integer nor -1. | [
"Set",
"the",
"hint",
"to",
"the",
"candidate",
"about",
"the",
"expected",
"overall",
"length",
"of",
"its",
"response",
".",
"If",
"$expectedLength",
"is",
"-",
"1",
"it",
"means",
"that",
"no",
"value",
"is",
"defined",
"for",
"the",
"expectedLength",
"attribute",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L256-L264 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setPatternMask | public function setPatternMask($patternMask)
{
if (is_string($patternMask) === true) {
$this->patternMask = $patternMask;
} else {
$msg = "The 'patternMask' argument must be a string value, '" . gettype($patternMask) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setPatternMask($patternMask)
{
if (is_string($patternMask) === true) {
$this->patternMask = $patternMask;
} else {
$msg = "The 'patternMask' argument must be a string value, '" . gettype($patternMask) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setPatternMask",
"(",
"$",
"patternMask",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"patternMask",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"patternMask",
"=",
"$",
"patternMask",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'patternMask' argument must be a string value, '\"",
".",
"gettype",
"(",
"$",
"patternMask",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the pattern mask specifying an XML Schema 2 regular expression that the candidate response must
match with. If $patternMask is an empty string, it means that there is no value defined for patternMask.
@param string $patternMask An XML Schema 2 regular expression or an empty string.
@throws \InvalidArgumentException If $patternMask is not a string value. | [
"Set",
"the",
"pattern",
"mask",
"specifying",
"an",
"XML",
"Schema",
"2",
"regular",
"expression",
"that",
"the",
"candidate",
"response",
"must",
"match",
"with",
".",
"If",
"$patternMask",
"is",
"an",
"empty",
"string",
"it",
"means",
"that",
"there",
"is",
"no",
"value",
"defined",
"for",
"patternMask",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L294-L302 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setPlaceholderText | public function setPlaceholderText($placeholderText)
{
if (is_string($placeholderText) === true) {
$this->placeholderText = $placeholderText;
} else {
$msg = "The 'placeholderText' argument must be a string value, '" . gettype($placeholderText) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setPlaceholderText($placeholderText)
{
if (is_string($placeholderText) === true) {
$this->placeholderText = $placeholderText;
} else {
$msg = "The 'placeholderText' argument must be a string value, '" . gettype($placeholderText) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setPlaceholderText",
"(",
"$",
"placeholderText",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"placeholderText",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"placeholderText",
"=",
"$",
"placeholderText",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'placeholderText' argument must be a string value, '\"",
".",
"gettype",
"(",
"$",
"placeholderText",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set a placeholder text. If $placeholderText is an empty string, it means that no value is defined
for the placeholderText attribute.
@param string $placeholderText A placeholder text or an empty string.
@throws \InvalidArgumentException If $placeholderText is not a string value. | [
"Set",
"a",
"placeholder",
"text",
".",
"If",
"$placeholderText",
"is",
"an",
"empty",
"string",
"it",
"means",
"that",
"no",
"value",
"is",
"defined",
"for",
"the",
"placeholderText",
"attribute",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L333-L341 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setMaxStrings | public function setMaxStrings($maxStrings)
{
if (is_int($maxStrings) === true && ($maxStrings > 0 || $maxStrings === -1)) {
$this->maxStrings = $maxStrings;
} else {
$msg = "The 'maxStrings' argument must be a strictly positive (> 0) integer or -1, '" . gettype($maxStrings) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setMaxStrings($maxStrings)
{
if (is_int($maxStrings) === true && ($maxStrings > 0 || $maxStrings === -1)) {
$this->maxStrings = $maxStrings;
} else {
$msg = "The 'maxStrings' argument must be a strictly positive (> 0) integer or -1, '" . gettype($maxStrings) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setMaxStrings",
"(",
"$",
"maxStrings",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"maxStrings",
")",
"===",
"true",
"&&",
"(",
"$",
"maxStrings",
">",
"0",
"||",
"$",
"maxStrings",
"===",
"-",
"1",
")",
")",
"{",
"$",
"this",
"->",
"maxStrings",
"=",
"$",
"maxStrings",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'maxStrings' argument must be a strictly positive (> 0) integer or -1, '\"",
".",
"gettype",
"(",
"$",
"maxStrings",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | If the interaction is bound to a numeric response variable, get the number of separate strings
accepted from the candidate. If $maxStrings is -1, it means no value is defined for the attribute.
@param integer $maxStrings A strictly positive (> 0) integer or -1.
@throws \InvalidArgumentException If $maxStrings is not a strictly positive integer nor -1. | [
"If",
"the",
"interaction",
"is",
"bound",
"to",
"a",
"numeric",
"response",
"variable",
"get",
"the",
"number",
"of",
"separate",
"strings",
"accepted",
"from",
"the",
"candidate",
".",
"If",
"$maxStrings",
"is",
"-",
"1",
"it",
"means",
"no",
"value",
"is",
"defined",
"for",
"the",
"attribute",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L371-L379 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setMinStrings | public function setMinStrings($minStrings)
{
if (is_int($minStrings) && $minStrings >= 0) {
$this->minStrings = $minStrings;
} else {
$msg = "The 'minStrings' argument must be a positive (>= 0) integer, '" . gettype($minStrings) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setMinStrings($minStrings)
{
if (is_int($minStrings) && $minStrings >= 0) {
$this->minStrings = $minStrings;
} else {
$msg = "The 'minStrings' argument must be a positive (>= 0) integer, '" . gettype($minStrings) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setMinStrings",
"(",
"$",
"minStrings",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"minStrings",
")",
"&&",
"$",
"minStrings",
">=",
"0",
")",
"{",
"$",
"this",
"->",
"minStrings",
"=",
"$",
"minStrings",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'minStrings' argument must be a positive (>= 0) integer, '\"",
".",
"gettype",
"(",
"$",
"minStrings",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the minimum separate (non-empty) strings required from the candidate.
@param string $minStrings A positive (>= 0) integer.
@throws \InvalidArgumentException If $minStrings is not a positive integer. | [
"Set",
"the",
"minimum",
"separate",
"(",
"non",
"-",
"empty",
")",
"strings",
"required",
"from",
"the",
"candidate",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L408-L416 |
oat-sa/qti-sdk | src/qtism/data/content/interactions/ExtendedTextInteraction.php | ExtendedTextInteraction.setExpectedLines | public function setExpectedLines($expectedLines)
{
if (is_int($expectedLines) && ($expectedLines > 0 || $expectedLines === -1)) {
$this->expectedLines = $expectedLines;
} else {
$msg = "The 'expectedLines' argument must be a strictly positive (> 0) intege or -1, '" . gettype($expectedLines) . "' given.";
throw new InvalidArgumentException($msg);
}
} | php | public function setExpectedLines($expectedLines)
{
if (is_int($expectedLines) && ($expectedLines > 0 || $expectedLines === -1)) {
$this->expectedLines = $expectedLines;
} else {
$msg = "The 'expectedLines' argument must be a strictly positive (> 0) intege or -1, '" . gettype($expectedLines) . "' given.";
throw new InvalidArgumentException($msg);
}
} | [
"public",
"function",
"setExpectedLines",
"(",
"$",
"expectedLines",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"expectedLines",
")",
"&&",
"(",
"$",
"expectedLines",
">",
"0",
"||",
"$",
"expectedLines",
"===",
"-",
"1",
")",
")",
"{",
"$",
"this",
"->",
"expectedLines",
"=",
"$",
"expectedLines",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"\"The 'expectedLines' argument must be a strictly positive (> 0) intege or -1, '\"",
".",
"gettype",
"(",
"$",
"expectedLines",
")",
".",
"\"' given.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Set the hint to the candidate as to the expected number of lines of input required. If
$expectedLines is -1, it means that no value is defined for the expectedLines attribute.
@param integer $expectedLines A strictly positive (> 0) integer or -1.
@throws \InvalidArgumentException If $expectedLines is not a strictly positive integer nor -1. | [
"Set",
"the",
"hint",
"to",
"the",
"candidate",
"as",
"to",
"the",
"expected",
"number",
"of",
"lines",
"of",
"input",
"required",
".",
"If",
"$expectedLines",
"is",
"-",
"1",
"it",
"means",
"that",
"no",
"value",
"is",
"defined",
"for",
"the",
"expectedLines",
"attribute",
"."
] | train | https://github.com/oat-sa/qti-sdk/blob/fc3568d2a293ae6dbfe9f400dad2b94a0033ddb2/src/qtism/data/content/interactions/ExtendedTextInteraction.php#L435-L443 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.