diff --git a/src/ToolProvider/Outcome.php b/src/ToolProvider/Outcome.php index 77508fd..7beb698 100644 --- a/src/ToolProvider/Outcome.php +++ b/src/ToolProvider/Outcome.php @@ -13,6 +13,15 @@ */ class Outcome { +/** + * Text Data Type + */ + const DATA_TYPE_TEXT = 'text'; + +/** + * Url Data Type + */ + const DATA_TYPE_URL = 'url'; /** * Language value. @@ -52,18 +61,34 @@ class Outcome */ private $value = null; +/** + * Data value. + * + * @var string $data + */ + private $data = null; + +/** + * Data Type value. + * + * @var string $dataType + */ + private $dataType = null; + /** * Class constructor. * * @param string $value Outcome value (optional, default is none) */ - public function __construct($value = null) + public function __construct($value = null, $data = null) { $this->value = $value; $this->language = 'en-US'; $this->date = gmdate('Y-m-d\TH:i:s\Z', time()); $this->type = 'decimal'; + $this->data = $data; + $this->dataType = self::DATA_TYPE_TEXT; } @@ -91,4 +116,51 @@ public function setValue($value) } +/** + * Get the data value. + * + * @return string Data value + */ + public function getData() + { + + return $this->data; + + } + +/** + * Set the data value. + * + * @param string $data Data value + */ + public function setData($data) + { + + $this->data = $data; + + } +/** + * Get the dataType value. + * + * @return string DataType value + */ + public function getDataType() + { + + return $this->dataType; + + } + +/** + * Set the dataType value. + * + * @param string $dataType DataType value + */ + public function setDataType($dataType) + { + + $this->dataType = $dataType; + + } + } diff --git a/src/ToolProvider/ResourceLink.php b/src/ToolProvider/ResourceLink.php index 72e6c9e..85687cb 100644 --- a/src/ToolProvider/ResourceLink.php +++ b/src/ToolProvider/ResourceLink.php @@ -591,13 +591,22 @@ public function doOutcomesService($action, $ltiOutcome, $user) if ($urlLTI11) { $xml = ''; if ($action === self::EXT_WRITE) { + if(!empty($ltiOutcome->getData())) { + $xml = << + <{$ltiOutcome->getDataType()}>{$ltiOutcome->getData()}getDataType()}> + +EOF; + } + $xml = << {$ltiOutcome->language} {$value} - + {$xml} EOF; }