Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.
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
36 changes: 34 additions & 2 deletions src/ToolProvider/Outcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,23 @@ class Outcome
*/
private $value = null;

/**
* Outcome result data passback.
*
* @var array $resultData (type=>value)
*/
private $resultData = null;


/**
* Class constructor.
*
* @param string $value Outcome value (optional, default is none)
*/
public function __construct($value = null)
public function __construct($value = null, $resultData = null)
{

$this->value = $value;
$this->resultData = $resultData;
$this->language = 'en-US';
$this->date = gmdate('Y-m-d\TH:i:s\Z', time());
$this->type = 'decimal';
Expand Down Expand Up @@ -91,4 +99,28 @@ public function setValue($value)

}

/**
* Get the outcome result data.
*
* @return array Outcome Result Data (type=>value)
*/
public function getResultData()
{

return $this->resultData;

}

/**
* Set the outcome result data.
*
* @param array $resultData Outcome result (type=>value)
*/
public function setResultData($resultData)
{

$this->resultData = $resultData;

}

}
14 changes: 14 additions & 0 deletions src/ToolProvider/ResourceLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,27 @@ public function doOutcomesService($action, $ltiOutcome, $user)
if ($urlLTI11) {
$xml = '';
if ($action === self::EXT_WRITE) {
$xmlResultAppend = null;
if($ltiOutcome->getResultData() && is_array($ltiOutcome->getResultData())) {
$resultData = $ltiOutcome->getResultData();
reset($resultData);
$resultKey = key($resultData);
$resultValue = current($resultData);
$xmlResultAppend = <<<EOF
<resultData>
<{$resultKey}>{$resultValue}</{$resultKey}>
</resultData>
EOF;

}
$xml = <<<EOF

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