* @package taoQTI * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10089 */ class OutcomeDeclaration extends VariableDeclaration { /** * the QTI tag name as defined in QTI standard * * @access protected * @var string */ protected static $qtiTagName = 'outcomeDeclaration'; protected function getUsedAttributes() { return array_merge( parent::getUsedAttributes(), [ 'oat\\taoQtiItem\\model\\qti\\attribute\\View', 'oat\\taoQtiItem\\model\\qti\\attribute\\Interpretation', 'oat\\taoQtiItem\\model\\qti\\attribute\\LongInterpretation', 'oat\\taoQtiItem\\model\\qti\\attribute\\ExternalScored', 'oat\\taoQtiItem\\model\\qti\\attribute\\NormalMaximum', 'oat\\taoQtiItem\\model\\qti\\attribute\\NormalMinimum', 'oat\\taoQtiItem\\model\\qti\\attribute\\MasteryValue' ] ); } public function toArray($filterVariableContent = false, &$filtered = []) { $data = parent::toArray($filterVariableContent, $filtered); $data['defaultValue'] = $this->getDefaultValue(); return $data; } protected function getTemplateQtiVariables() { $variables = parent::getTemplateQtiVariables(); $variables['defaultValue'] = null; $defaultValue = $this->getDefaultValue(); if (!is_null($defaultValue) || trim($defaultValue) != '') { $variables['defaultValue'] = $defaultValue; } return $variables; } /** * get the outcome in JSON format * * @deprecated now use the new qtism lib for response evaluation * @access public * @author Joel Bout, */ public function toJSON() { $outcomeValue = null; if ($this->defaultValue != '') { $outcomeValue = [$this->defaultValue]; } elseif ($this->getAttributeValue('baseType') == 'integer' || $this->getAttributeValue('baseType') == 'float') { $outcomeValue = [0]; } else { $outcomeValue = null; } $returnValue = taoQTI_models_classes_Matching_VariableFactory::createJSONVariableFromQTIData( $this->getIdentifier(), $this->getAttributeValue('cardinality'), $this->getAttributeValue('baseType'), $outcomeValue ); return $returnValue; } }