Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Added the ability to pass text and URL parameters to the Outcome #15

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
60 changes: 57 additions & 3 deletions src/ToolProvider/Outcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,22 @@ class Outcome
* @var string $value
*/
private $value = null;
private $text = null;
private $url = null;

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

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

}

}
/**
* Get the outcome text.
*
* @return string Outcome text
*/
public function getText()
{

return $this->text;

}

/**
* Set the outcome text.
*
* @param string $text Outcome text
*/
public function setText($text)
{

$this->text = $text;

}

/**
* Get the outcome url.
*
* @return string Outcome url
*/
public function getUrl()
{

return $this->url;

}

/**
* Set the outcome url.
*
* @param string $url Outcome url
*/
public function setUrl($url)
{

$this->url = $url;

}

}
13 changes: 13 additions & 0 deletions src/ToolProvider/ResourceLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,19 @@ public function doOutcomesService($action, $ltiOutcome, $user)
}
}
if (isset($do)) {
//get the params
$value = $ltiOutcome->getValue();
if (is_null($value)) {
$value = '';
}
$text = $ltiOutcome->getText();
if (is_null($text)) {
$text = '';
}
$url = $ltiOutcome->getUrl();
if (is_null($url)) {
$url = '';
}
if ($urlLTI11) {
$xml = '';
if ($action === self::EXT_WRITE) {
Expand All @@ -598,6 +607,10 @@ public function doOutcomesService($action, $ltiOutcome, $user)
<language>{$ltiOutcome->language}</language>
<textString>{$value}</textString>
</resultScore>
<resultData>
<text><![CDATA[{$text}]]></text>
<url><![CDATA[{$url}]]></url>
</resultData>
</result>
EOF;
}
Expand Down