Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing Outcome result data #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 73 additions & 1 deletion src/ToolProvider/Outcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
*/
class Outcome
{
/**
* Text Data Type
*/
const DATA_TYPE_TEXT = 'text';

/**
* Url Data Type
*/
const DATA_TYPE_URL = 'url';

/**
* Language value.
Expand Down Expand Up @@ -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;

}

Expand Down Expand Up @@ -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;

}

}
11 changes: 10 additions & 1 deletion src/ToolProvider/ResourceLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,22 @@ public function doOutcomesService($action, $ltiOutcome, $user)
if ($urlLTI11) {
$xml = '';
if ($action === self::EXT_WRITE) {
if(!empty($ltiOutcome->getData())) {
$xml = <<<EOF

<resultData>
<{$ltiOutcome->getDataType()}>{$ltiOutcome->getData()}</{$ltiOutcome->getDataType()}>
</resultData>
EOF;
}

$xml = <<<EOF

<result>
<resultScore>
<language>{$ltiOutcome->language}</language>
<textString>{$value}</textString>
</resultScore>
</resultScore>{$xml}
</result>
EOF;
}
Expand Down