From b5a3bd62a62efe7b27be9387443cb7963e257b8f Mon Sep 17 00:00:00 2001 From: Bryce Ott Date: Thu, 17 Nov 2016 17:20:50 -0700 Subject: [PATCH] Added the ability to pass text and URL parameters to the Outcome service. --- src/ToolProvider/Outcome.php | 60 +++++++++++++++++++++++++++++-- src/ToolProvider/ResourceLink.php | 13 +++++++ 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/ToolProvider/Outcome.php b/src/ToolProvider/Outcome.php index 77508fd..28697df 100644 --- a/src/ToolProvider/Outcome.php +++ b/src/ToolProvider/Outcome.php @@ -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'; @@ -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; + + } + +} \ No newline at end of file diff --git a/src/ToolProvider/ResourceLink.php b/src/ToolProvider/ResourceLink.php index f08f11c..075ac98 100644 --- a/src/ToolProvider/ResourceLink.php +++ b/src/ToolProvider/ResourceLink.php @@ -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) { @@ -598,6 +607,10 @@ public function doOutcomesService($action, $ltiOutcome, $user) {$ltiOutcome->language} {$value} + + + + EOF; }