ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IMSGlobal\LTI\ToolProvider\ResourceLink Class Reference

Class to represent a tool consumer resource link. More...

+ Collaboration diagram for IMSGlobal\LTI\ToolProvider\ResourceLink:

Public Member Functions

 __construct ()
 Class constructor. More...
 
 initialize ()
 Initialise the resource link. More...
 
 initialise ()
 Initialise the resource link. More...
 
 save ()
 Save the resource link to the database. More...
 
 delete ()
 Delete the resource link from the database. More...
 
 getConsumer ()
 Get tool consumer. More...
 
 setConsumerId ($consumerId)
 Set tool consumer ID. More...
 
 getContext ()
 Get context. More...
 
 getContextId ()
 Get context record ID. More...
 
 setContextId ($contextId)
 Set context ID. More...
 
 getKey ()
 Get tool consumer key. More...
 
 getId ()
 Get resource link ID. More...
 
 getRecordId ()
 Get resource link record ID. More...
 
 setRecordId ($id)
 Set resource link record ID. More...
 
 getDataConnector ()
 Get the data connector. More...
 
 getSetting ($name, $default='')
 Get a setting value. More...
 
 setSetting ($name, $value=null)
 Set a setting value. More...
 
 getSettings ()
 Get an array of all setting values. More...
 
 setSettings ($settings)
 Set an array of all setting values. More...
 
 saveSettings ()
 Save setting values. More...
 
 hasOutcomesService ()
 Check if the Outcomes service is supported. More...
 
 hasMembershipsService ()
 Check if the Memberships extension service is supported. More...
 
 hasSettingService ()
 Check if the Setting extension service is supported. More...
 
 doOutcomesService ($action, $ltiOutcome, $user)
 Perform an Outcomes service request. More...
 
 doMembershipsService ($withGroups=false)
 Perform a Memberships service request. More...
 
 doSettingService ($action, $value=null)
 Perform a Setting service request. More...
 
 hasToolSettingsService ()
 Check if the Tool Settings service is supported. More...
 
 getToolSettings ($mode=Service\ToolSettings::MODE_CURRENT_LEVEL, $simple=true)
 Get Tool Settings. More...
 
 setToolSettings ($settings=array())
 Perform a Tool Settings service request. More...
 
 hasMembershipService ()
 Check if the Membership service is supported. More...
 
 getMembership ()
 Get Memberships. More...
 
 getUserResultSourcedIDs ($localOnly=false, $idScope=null)
 Obtain an array of User objects for users with a result sourcedId. More...
 
 getShares ()
 Get an array of ResourceLinkShare objects for each resource link which is sharing this context. More...
 

Static Public Member Functions

static fromConsumer ($consumer, $ltiResourceLinkId, $tempId=null)
 Class constructor from consumer. More...
 
static fromContext ($context, $ltiResourceLinkId, $tempId=null)
 Class constructor from context. More...
 
static fromRecordId ($id, $dataConnector)
 Load the resource link from the database. More...
 

Data Fields

const EXT_READ = 1
 Read action. More...
 
const EXT_WRITE = 2
 Write (create/update) action. More...
 
const EXT_DELETE = 3
 Delete action. More...
 
const EXT_CREATE = 4
 Create action. More...
 
const EXT_UPDATE = 5
 Update action. More...
 
const EXT_TYPE_DECIMAL = 'decimal'
 Decimal outcome type. More...
 
const EXT_TYPE_PERCENTAGE = 'percentage'
 Percentage outcome type. More...
 
const EXT_TYPE_RATIO = 'ratio'
 Ratio outcome type. More...
 
const EXT_TYPE_LETTER_AF = 'letteraf'
 Letter (A-F) outcome type. More...
 
const EXT_TYPE_LETTER_AF_PLUS = 'letterafplus'
 Letter (A-F) with optional +/- outcome type. More...
 
const EXT_TYPE_PASS_FAIL = 'passfail'
 Pass/fail outcome type. More...
 
const EXT_TYPE_TEXT = 'freetext'
 Free text outcome type. More...
 
 $title = null
 Context title. More...
 
 $ltiResourceLinkId = null
 Resource link ID as supplied in the last connection request. More...
 
 $groupSets = null
 User group sets (null if the consumer does not support the groups enhancement) More...
 
 $groups = null
 User groups (null if the consumer does not support the groups enhancement) More...
 
 $extRequest = null
 Request for last service request. More...
 
 $extRequestHeaders = null
 Request headers for last service request. More...
 
 $extResponse = null
 Response from last service request. More...
 
 $extResponseHeaders = null
 Response header from last service request. More...
 
 $primaryResourceLinkId = null
 Consumer key value for resource link being shared (if any). More...
 
 $shareApproved = null
 Whether the sharing request has been approved by the primary resource link. More...
 
 $created = null
 Date/time when the object was created. More...
 
 $updated = null
 Date/time when the object was last updated. More...
 

Private Member Functions

 load ($id=null)
 Load the resource link from the database. More...
 
 checkValueType ($ltiOutcome, $supportedTypes=null)
 Convert data type of value to a supported type if possible. More...
 
 doService ($type, $url, $params)
 Send a service request to the tool consumer. More...
 
 doLTI11Service ($type, $url, $xml)
 Send a service request to the tool consumer. More...
 
 domnodeToArray ($node)
 Convert DOM nodes to array. More...
 

Private Attributes

 $id = null
 Record ID for this resource link. More...
 
 $consumer = null
 Tool Consumer for this resource link. More...
 
 $consumerId = null
 Tool Consumer ID for this resource link. More...
 
 $context = null
 Context for this resource link. More...
 
 $contextId = null
 Context ID for this resource link. More...
 
 $settings = null
 Setting values (LTI parameters, custom parameters and local parameters). More...
 
 $settingsChanged = false
 Whether the settings value have changed since last saved. More...
 
 $extDoc = null
 XML document for the last extension service request. More...
 
 $extNodes = null
 XML node array for the last extension service request. More...
 
 $dataConnector = null
 Data connector object or string. More...
 

Detailed Description

Class to represent a tool consumer resource link.

Author
Stephen P Vickers svick.nosp@m.ers@.nosp@m.imsgl.nosp@m.obal.nosp@m..org
Date
2016
Version
3.0.2 http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0

Definition at line 21 of file ResourceLink.php.

Constructor & Destructor Documentation

◆ __construct()

IMSGlobal\LTI\ToolProvider\ResourceLink::__construct ( )

Class constructor.

Definition at line 211 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\initialize().

212  {
213 
214  $this->initialize();
215 
216  }
+ Here is the call graph for this function:

Member Function Documentation

◆ checkValueType()

IMSGlobal\LTI\ToolProvider\ResourceLink::checkValueType (   $ltiOutcome,
  $supportedTypes = null 
)
private

Convert data type of value to a supported type if possible.

Parameters
Outcome$ltiOutcomeOutcome object
string[]$supportedTypes Array of outcome types to be supported (optional, default is null to use supported types reported in the last launch for this resource link)
Returns
boolean True if the type/value are valid and supported

Definition at line 1082 of file ResourceLink.php.

References $ok, $type, and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doOutcomesService().

1083  {
1084 
1085  if (empty($supportedTypes)) {
1086  $supportedTypes = explode(',', str_replace(' ', '', strtolower($this->getSetting('ext_ims_lis_resultvalue_sourcedids', self::EXT_TYPE_DECIMAL))));
1087  }
1088  $type = $ltiOutcome->type;
1089  $value = $ltiOutcome->getValue();
1090 // Check whether the type is supported or there is no value
1091  $ok = in_array($type, $supportedTypes) || (strlen($value) <= 0);
1092  if (!$ok) {
1093 // Convert numeric values to decimal
1094  if ($type === self::EXT_TYPE_PERCENTAGE) {
1095  if (substr($value, -1) === '%') {
1096  $value = substr($value, 0, -1);
1097  }
1098  $ok = is_numeric($value) && ($value >= 0) && ($value <= 100);
1099  if ($ok) {
1100  $ltiOutcome->setValue($value / 100);
1101  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1102  }
1103  } else if ($type === self::EXT_TYPE_RATIO) {
1104  $parts = explode('/', $value, 2);
1105  $ok = (count($parts) === 2) && is_numeric($parts[0]) && is_numeric($parts[1]) && ($parts[0] >= 0) && ($parts[1] > 0);
1106  if ($ok) {
1107  $ltiOutcome->setValue($parts[0] / $parts[1]);
1108  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1109  }
1110 // Convert letter_af to letter_af_plus or text
1111  } else if ($type === self::EXT_TYPE_LETTER_AF) {
1112  if (in_array(self::EXT_TYPE_LETTER_AF_PLUS, $supportedTypes)) {
1113  $ok = true;
1114  $ltiOutcome->type = self::EXT_TYPE_LETTER_AF_PLUS;
1115  } else if (in_array(self::EXT_TYPE_TEXT, $supportedTypes)) {
1116  $ok = true;
1117  $ltiOutcome->type = self::EXT_TYPE_TEXT;
1118  }
1119 // Convert letter_af_plus to letter_af or text
1120  } else if ($type === self::EXT_TYPE_LETTER_AF_PLUS) {
1121  if (in_array(self::EXT_TYPE_LETTER_AF, $supportedTypes) && (strlen($value) === 1)) {
1122  $ok = true;
1123  $ltiOutcome->type = self::EXT_TYPE_LETTER_AF;
1124  } else if (in_array(self::EXT_TYPE_TEXT, $supportedTypes)) {
1125  $ok = true;
1126  $ltiOutcome->type = self::EXT_TYPE_TEXT;
1127  }
1128 // Convert text to decimal
1129  } else if ($type === self::EXT_TYPE_TEXT) {
1130  $ok = is_numeric($value) && ($value >= 0) && ($value <=1);
1131  if ($ok) {
1132  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1133  } else if (substr($value, -1) === '%') {
1134  $value = substr($value, 0, -1);
1135  $ok = is_numeric($value) && ($value >= 0) && ($value <=100);
1136  if ($ok) {
1137  if (in_array(self::EXT_TYPE_PERCENTAGE, $supportedTypes)) {
1138  $ltiOutcome->type = self::EXT_TYPE_PERCENTAGE;
1139  } else {
1140  $ltiOutcome->setValue($value / 100);
1141  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1142  }
1143  }
1144  }
1145  }
1146  }
1147 
1148  return $ok;
1149 
1150  }
$type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

IMSGlobal\LTI\ToolProvider\ResourceLink::delete ( )

Delete the resource link from the database.

Returns
boolean True if the resource link was successfully deleted.

Definition at line 269 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\getDataConnector().

270  {
271 
272  return $this->getDataConnector()->deleteResourceLink($this);
273 
274  }
+ Here is the call graph for this function:

◆ doLTI11Service()

IMSGlobal\LTI\ToolProvider\ResourceLink::doLTI11Service (   $type,
  $url,
  $xml 
)
private

Send a service request to the tool consumer.

Parameters
string$typeMessage type value
string$urlURL to send request to
string$xmlXML of message request
Returns
boolean True if the request successfully obtained a response

Definition at line 1215 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$consumer, $header, $http, IMSGlobal\LTI\ToolProvider\ResourceLink\$id, $ok, PHPMailer\PHPMailer\$params, $req, $type, $url, $xml, IMSGlobal\LTI\ToolProvider\ResourceLink\domnodeToArray(), EOD, IMSGlobal\LTI\OAuth\OAuthRequest\from_consumer_and_token(), IMSGlobal\LTI\ToolProvider\ResourceLink\getConsumer(), IMSGlobal\LTI\ToolProvider\ResourceLink\getKey(), and ilLoggerFactory\getLogger().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doOutcomesService().

1216  {
1217 
1218  $ok = false;
1219  $this->extRequest = null;
1220  $this->extRequestHeaders = '';
1221  $this->extResponse = null;
1222  $this->extResponseHeaders = '';
1223  if (!empty($url)) {
1224  $id = uniqid();
1225  $xmlRequest = <<< EOD
1226 <?xml version = "1.0" encoding = "UTF-8"?>
1227 <imsx_POXEnvelopeRequest xmlns = "http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">
1228  <imsx_POXHeader>
1229  <imsx_POXRequestHeaderInfo>
1230  <imsx_version>V1.0</imsx_version>
1231  <imsx_messageIdentifier>{$id}</imsx_messageIdentifier>
1232  </imsx_POXRequestHeaderInfo>
1233  </imsx_POXHeader>
1234  <imsx_POXBody>
1235  <{$type}Request>
1236 {$xml}
1237  </{$type}Request>
1238  </imsx_POXBody>
1239 </imsx_POXEnvelopeRequest>
1240 EOD;
1241 // Calculate body hash
1242  $hash = base64_encode(sha1($xmlRequest, true));
1243  $params = array('oauth_body_hash' => $hash);
1244 
1245 // Add OAuth signature
1246  $hmacMethod = new OAuth\OAuthSignatureMethod_HMAC_SHA1();
1247  $consumer = new OAuth\OAuthConsumer($this->getConsumer()->getKey(), $this->getConsumer()->secret, null);
1249  $req->sign_request($hmacMethod, $consumer, null);
1250  $params = $req->get_parameters();
1251  $header = $req->to_header();
1252  $header .= "\nContent-Type: application/xml";
1253 // Connect to tool consumer
1254  $http = new HTTPMessage($url, 'POST', $xmlRequest, $header);
1255 
1256  \ilLoggerFactory::getLogger('lti')->debug('Sending post: ' . $header);
1257  \ilLoggerFactory::getLogger('lti')->debug('Sending post: ' . $xmlRequest);
1258 
1259 // Parse XML response
1260  if ($http->send()) {
1261  $this->extResponse = $http->response;
1262  $this->extResponseHeaders = $http->responseHeaders;
1263  \ilLoggerFactory::getLogger('lti')->debug('Got response: ' . $http->response);
1264  \ilLoggerFactory::getLogger('lti')->debug('Got response: ' . $http->responseHeaders);
1265  try {
1266  $this->extDoc = new DOMDocument();
1267  $this->extDoc->loadXML($http->response);
1268  $this->extNodes = $this->domnodeToArray($this->extDoc->documentElement);
1269  if (isset($this->extNodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_codeMajor']) &&
1270  ($this->extNodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_codeMajor'] === 'success')) {
1271  $ok = true;
1272  }
1273  } catch (\Exception $e) {
1274  \ilLoggerFactory::getLogger('lti')->warning('lti 1.1 outcome failed with message: ' . $e->getMessage());
1275  }
1276  }
1277  else {
1278  \ilLoggerFactory::getLogger('lti')->debug('Got response: ' . $http->response);
1279  \ilLoggerFactory::getLogger('lti')->debug('Got response: ' . $http->responseHeaders);
1280  }
1281  $this->extRequest = $http->request;
1282  $this->extRequestHeaders = $http->requestHeaders;
1283  }
1284 
1285  return $ok;
1286 
1287  }
$type
$req
Definition: getUserInfo.php:20
static from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null)
pretty much a helper function to set up the request
$http
Definition: raiseError.php:7
EOD
Definition: example_053.php:93
static getLogger($a_component_id)
Get component logger.
$url
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doMembershipsService()

IMSGlobal\LTI\ToolProvider\ResourceLink::doMembershipsService (   $withGroups = false)

Perform a Memberships service request.

The user table is updated with the new list of user objects.

Parameters
boolean$withGroupsTrue is group information is to be requested as well
Returns
mixed Array of User objects or False if the request was not successful

Set the user roles

Definition at line 693 of file ResourceLink.php.

References $email, IMSGlobal\LTI\ToolProvider\ResourceLink\$groups, $i, IMSGlobal\LTI\ToolProvider\ResourceLink\$id, $ok, PHPMailer\PHPMailer\$params, $url, $user, $users, IMSGlobal\LTI\ToolProvider\ResourceLink\doService(), IMSGlobal\LTI\ToolProvider\User\fromResourceLink(), IMSGlobal\LTI\ToolProvider\ResourceLink\getConsumer(), IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting(), IMSGlobal\LTI\ToolProvider\ResourceLink\getUserResultSourcedIDs(), IMSGlobal\LTI\ToolProvider\ToolProvider\ID_SCOPE_RESOURCE, and IMSGlobal\LTI\ToolProvider\ToolProvider\parseRoles().

694  {
695 
696  $users = array();
698  $this->extResponse = null;
699  $url = $this->getSetting('ext_ims_lis_memberships_url');
700  $params = array();
701  $params['id'] = $this->getSetting('ext_ims_lis_memberships_id');
702  $ok = false;
703  if ($withGroups) {
704  $ok = $this->doService('basic-lis-readmembershipsforcontextwithgroups', $url, $params);
705  }
706  if ($ok) {
707  $this->groupSets = array();
708  $this->groups = array();
709  } else {
710  $ok = $this->doService('basic-lis-readmembershipsforcontext', $url, $params);
711  }
712 
713  if ($ok) {
714  if (!isset($this->extNodes['memberships']['member'])) {
715  $members = array();
716  } else if (!isset($this->extNodes['memberships']['member'][0])) {
717  $members = array();
718  $members[0] = $this->extNodes['memberships']['member'];
719  } else {
720  $members = $this->extNodes['memberships']['member'];
721  }
722 
723  for ($i = 0; $i < count($members); $i++) {
724 
725  $user = User::fromResourceLink($this, $members[$i]['user_id']);
726 
727 // Set the user name
728  $firstname = (isset($members[$i]['person_name_given'])) ? $members[$i]['person_name_given'] : '';
729  $lastname = (isset($members[$i]['person_name_family'])) ? $members[$i]['person_name_family'] : '';
730  $fullname = (isset($members[$i]['person_name_full'])) ? $members[$i]['person_name_full'] : '';
731  $user->setNames($firstname, $lastname, $fullname);
732 
733 // Set the user email
734  $email = (isset($members[$i]['person_contact_email_primary'])) ? $members[$i]['person_contact_email_primary'] : '';
735  $user->setEmail($email, $this->getConsumer()->defaultEmail);
736 
738  if (isset($members[$i]['roles'])) {
739  $user->roles = ToolProvider::parseRoles($members[$i]['roles']);
740  }
741 
742 // Set the user groups
743  if (!isset($members[$i]['groups']['group'])) {
744  $groups = array();
745  } else if (!isset($members[$i]['groups']['group'][0])) {
746  $groups = array();
747  $groups[0] = $members[$i]['groups']['group'];
748  } else {
749  $groups = $members[$i]['groups']['group'];
750  }
751  for ($j = 0; $j < count($groups); $j++) {
752  $group = $groups[$j];
753  if (isset($group['set'])) {
754  $set_id = $group['set']['id'];
755  if (!isset($this->groupSets[$set_id])) {
756  $this->groupSets[$set_id] = array('title' => $group['set']['title'], 'groups' => array(),
757  'num_members' => 0, 'num_staff' => 0, 'num_learners' => 0);
758  }
759  $this->groupSets[$set_id]['num_members']++;
760  if ($user->isStaff()) {
761  $this->groupSets[$set_id]['num_staff']++;
762  }
763  if ($user->isLearner()) {
764  $this->groupSets[$set_id]['num_learners']++;
765  }
766  if (!in_array($group['id'], $this->groupSets[$set_id]['groups'])) {
767  $this->groupSets[$set_id]['groups'][] = $group['id'];
768  }
769  $this->groups[$group['id']] = array('title' => $group['title'], 'set' => $set_id);
770  } else {
771  $this->groups[$group['id']] = array('title' => $group['title']);
772  }
773  $user->groups[] = $group['id'];
774  }
775 
776 // If a result sourcedid is provided save the user
777  if (isset($members[$i]['lis_result_sourcedid'])) {
778  $user->ltiResultSourcedId = $members[$i]['lis_result_sourcedid'];
779  $user->save();
780  }
781  $users[] = $user;
782 
783 // Remove old user (if it exists)
784  unset($oldUsers[$user->getId(ToolProvider::ID_SCOPE_RESOURCE)]);
785  }
786 
787 // Delete any old users which were not in the latest list from the tool consumer
788  foreach ($oldUsers as $id => $user) {
789  $user->delete();
790  }
791  } else {
792  $users = false;
793  }
794 
795  return $users;
796 
797  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
static parseRoles($roles)
Get an array of fully qualified user roles.
const ID_SCOPE_RESOURCE
Prefix the ID with the consumer key and resource ID.
static fromResourceLink($resourceLink, $ltiUserId)
Class constructor from resource link.
Definition: User.php:413
$user
Definition: migrateto20.php:57
$users
Definition: authpage.php:44
$i
Definition: disco.tpl.php:19
$url
+ Here is the call graph for this function:

◆ domnodeToArray()

IMSGlobal\LTI\ToolProvider\ResourceLink::domnodeToArray (   $node)
private

Convert DOM nodes to array.

Parameters
DOMElement$nodeXML element
Returns
array Array of XML document elements

Definition at line 1296 of file ResourceLink.php.

References $i, Sabre\VObject\$output, $s, and $t.

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doLTI11Service(), and IMSGlobal\LTI\ToolProvider\ResourceLink\doService().

1297  {
1298 
1299  $output = '';
1300  switch ($node->nodeType) {
1301  case XML_CDATA_SECTION_NODE:
1302  case XML_TEXT_NODE:
1303  $output = trim($node->textContent);
1304  break;
1305  case XML_ELEMENT_NODE:
1306  for ($i = 0; $i < $node->childNodes->length; $i++) {
1307  $child = $node->childNodes->item($i);
1308  $v = $this->domnodeToArray($child);
1309  if (isset($child->tagName)) {
1310  $t = $child->tagName;
1311  if (!isset($output[$t])) {
1312  $output[$t] = array();
1313  }
1314  $output[$t][] = $v;
1315  } else {
1316  $s = (string) $v;
1317  if (strlen($s) > 0) {
1318  $output = $s;
1319  }
1320  }
1321  }
1322  if (is_array($output)) {
1323  if ($node->attributes->length) {
1324  $a = array();
1325  foreach ($node->attributes as $attrName => $attrNode) {
1326  $a[$attrName] = (string) $attrNode->value;
1327  }
1328  $output['@attributes'] = $a;
1329  }
1330  foreach ($output as $t => $v) {
1331  if (is_array($v) && count($v)==1 && $t!='@attributes') {
1332  $output[$t] = $v[0];
1333  }
1334  }
1335  }
1336  break;
1337  }
1338 
1339  return $output;
1340 
1341  }
$s
Definition: pwgen.php:45
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ doOutcomesService()

IMSGlobal\LTI\ToolProvider\ResourceLink::doOutcomesService (   $action,
  $ltiOutcome,
  $user 
)

Perform an Outcomes service request.

Parameters
int$actionThe action type constant
Outcome$ltiOutcomeOutcome object
User$userUser object
Returns
boolean True if the request was successfully processed

Definition at line 547 of file ResourceLink.php.

References $action, $DIC, PHPMailer\PHPMailer\$params, $response, $user, $xml, IMSGlobal\LTI\ToolProvider\ResourceLink\checkValueType(), IMSGlobal\LTI\ToolProvider\ResourceLink\doLTI11Service(), IMSGlobal\LTI\ToolProvider\ResourceLink\doService(), and EOF.

548  {
549  global $DIC;
550  $logger = $DIC->logger()->lti();
551 
552  $response = false;
553  $this->extResponse = null;
554 
555 // Lookup service details from the source resource link appropriate to the user (in case the destination is being shared)
556  $sourceResourceLink = $user->getResourceLink();
557  $sourcedId = $user->ltiResultSourcedId;
558 
559 // Use LTI 1.1 service in preference to extension service if it is available
560  $urlLTI11 = $sourceResourceLink->getSetting('lis_outcome_service_url');
561  $urlExt = $sourceResourceLink->getSetting('ext_ims_lis_basic_outcome_url');
562  if ($urlExt || $urlLTI11) {
563  switch ($action) {
564  case self::EXT_READ:
565  if ($urlLTI11 && ($ltiOutcome->type === self::EXT_TYPE_DECIMAL)) {
566  $do = 'readResult';
567  } else if ($urlExt) {
568  $urlLTI11 = null;
569  $do = 'basic-lis-readresult';
570  }
571  break;
572  case self::EXT_WRITE:
573  if ($urlLTI11 && $this->checkValueType($ltiOutcome, array(self::EXT_TYPE_DECIMAL))) {
574  $do = 'replaceResult';
575  } else if ($this->checkValueType($ltiOutcome)) {
576  $urlLTI11 = null;
577  $do = 'basic-lis-updateresult';
578  }
579  break;
580  case self::EXT_DELETE:
581  if ($urlLTI11 && ($ltiOutcome->type === self::EXT_TYPE_DECIMAL)) {
582  $do = 'deleteResult';
583  } else if ($urlExt) {
584  $urlLTI11 = null;
585  $do = 'basic-lis-deleteresult';
586  }
587  break;
588  }
589  }
590 
591  $logger->debug('Command is: ' . $do);
592 
593  if (isset($do)) {
594  $value = $ltiOutcome->getValue();
595  if (is_null($value)) {
596  $value = '';
597  }
598  if ($urlLTI11) {
599  $xml = '';
600  if ($action === self::EXT_WRITE) {
601  $xml = <<<EOF
602 
603  <result>
604  <resultScore>
605  <language>{$ltiOutcome->language}</language>
606  <textString>{$value}</textString>
607  </resultScore>
608  </result>
609 EOF;
610  }
611  $sourcedId = htmlentities($sourcedId);
612  $xml = <<<EOF
613  <resultRecord>
614  <sourcedGUID>
615  <sourcedId>{$sourcedId}</sourcedId>
616  </sourcedGUID>{$xml}
617  </resultRecord>
618 EOF;
619 
620  $logger->debug($urlLTI11);
621  $logger->debug('xml for doLTI11Service: ' . $xml);
622 
623  if ($this->doLTI11Service($do, $urlLTI11, $xml)) {
624  switch ($action) {
625  case self::EXT_READ:
626  if (!isset($this->extNodes['imsx_POXBody']["{$do}Response"]['result']['resultScore']['textString'])) {
627  break;
628  } else {
629  $ltiOutcome->setValue($this->extNodes['imsx_POXBody']["{$do}Response"]['result']['resultScore']['textString']);
630  }
631  case self::EXT_WRITE:
632  case self::EXT_DELETE:
633  $response = true;
634  break;
635  }
636  }
637  } else {
638  $params = array();
639  $params['sourcedid'] = $sourcedId;
640  $params['result_resultscore_textstring'] = $value;
641  if (!empty($ltiOutcome->language)) {
642  $params['result_resultscore_language'] = $ltiOutcome->language;
643  }
644  if (!empty($ltiOutcome->status)) {
645  $params['result_statusofresult'] = $ltiOutcome->status;
646  }
647  if (!empty($ltiOutcome->date)) {
648  $params['result_date'] = $ltiOutcome->date;
649  }
650  if (!empty($ltiOutcome->type)) {
651  $params['result_resultvaluesourcedid'] = $ltiOutcome->type;
652  }
653  if (!empty($ltiOutcome->data_source)) {
654  $params['result_datasource'] = $ltiOutcome->data_source;
655  }
656 
657  $logger->debug($urlExt);
658  $logger->dump($params);
659 
660 
661  if ($this->doService($do, $urlExt, $params)) {
662  switch ($action) {
663  case self::EXT_READ:
664  if (isset($this->extNodes['result']['resultscore']['textstring'])) {
665  $response = $this->extNodes['result']['resultscore']['textstring'];
666  }
667  break;
668  case self::EXT_WRITE:
669  case self::EXT_DELETE:
670  $response = true;
671  break;
672  }
673  }
674  }
675  if (is_array($response) && (count($response) <= 0)) {
676  $response = '';
677  }
678  }
679 
680  return $response;
681 
682  }
$action
global $DIC
Definition: saml.php:7
$user
Definition: migrateto20.php:57
$response
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
+ Here is the call graph for this function:

◆ doService()

IMSGlobal\LTI\ToolProvider\ResourceLink::doService (   $type,
  $url,
  $params 
)
private

Send a service request to the tool consumer.

Parameters
string$typeMessage type value
string$urlURL to send request to
array$paramsAssociative array of parameter values to be passed
Returns
boolean True if the request successfully obtained a response

Definition at line 1161 of file ResourceLink.php.

References $http, $ok, PHPMailer\PHPMailer\$params, $type, $url, IMSGlobal\LTI\ToolProvider\ResourceLink\domnodeToArray(), IMSGlobal\LTI\ToolProvider\ResourceLink\getConsumer(), and ilLoggerFactory\getLogger().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doMembershipsService(), IMSGlobal\LTI\ToolProvider\ResourceLink\doOutcomesService(), and IMSGlobal\LTI\ToolProvider\ResourceLink\doSettingService().

1162  {
1163 
1164  $ok = false;
1165  $this->extRequest = null;
1166  $this->extRequestHeaders = '';
1167  $this->extResponse = null;
1168  $this->extResponseHeaders = '';
1169  if (!empty($url)) {
1170  $params = $this->getConsumer()->signParameters($url, $type, $this->getConsumer()->ltiVersion, $params);
1171 // Connect to tool consumer
1172  $http = new HTTPMessage($url, 'POST', $params);
1173  \ilLoggerFactory::getLogger('lti')->debug('Sending to ' . $url);
1174  \ilLoggerFactory::getLogger('lti')->dump($params);
1175 
1176 // Parse XML response
1177  if ($http->send()) {
1178  $this->extResponse = $http->response;
1179  $this->extResponseHeaders = $http->responseHeaders;
1180 
1181  \ilLoggerFactory::getLogger('lti')->debug('Response: ' . $http->response);
1182  \ilLoggerFactory::getLogger('lti')->debug('Response: ' . $http->responseHeaders);
1183 
1184  try {
1185  $this->extDoc = new DOMDocument();
1186  $this->extDoc->loadXML($http->response);
1187  $this->extNodes = $this->domnodeToArray($this->extDoc->documentElement);
1188  if (isset($this->extNodes['statusinfo']['codemajor']) && ($this->extNodes['statusinfo']['codemajor'] === 'Success')) {
1189  $ok = true;
1190  }
1191  } catch (\Exception $e) {
1192  \ilLoggerFactory::getLogger('lti')->warning('Outcome failed with message: ' . $e->getMessage());
1193  }
1194  }
1195  $this->extRequest = $http->request;
1196  $this->extRequestHeaders = $http->requestHeaders;
1197 
1198  \ilLoggerFactory::getLogger('lti')->debug('Request: ' . $http->request);
1199  \ilLoggerFactory::getLogger('lti')->debug('RequestHeaders: ' . $http->requestHeaders);
1200  }
1201 
1202  return $ok;
1203 
1204  }
$type
$http
Definition: raiseError.php:7
static getLogger($a_component_id)
Get component logger.
$url
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doSettingService()

IMSGlobal\LTI\ToolProvider\ResourceLink::doSettingService (   $action,
  $value = null 
)

Perform a Setting service request.

Parameters
int$actionThe action type constant
string$valueThe setting value (optional, default is null)
Returns
mixed The setting value for a read action, true if a write or delete action was successful, otherwise false

Definition at line 807 of file ResourceLink.php.

References $action, PHPMailer\PHPMailer\$params, $response, $url, IMSGlobal\LTI\ToolProvider\ResourceLink\doService(), IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting(), IMSGlobal\LTI\ToolProvider\ResourceLink\saveSettings(), and IMSGlobal\LTI\ToolProvider\ResourceLink\setSetting().

808  {
809 
810  $response = false;
811  $this->extResponse = null;
812  switch ($action) {
813  case self::EXT_READ:
814  $do = 'basic-lti-loadsetting';
815  break;
816  case self::EXT_WRITE:
817  $do = 'basic-lti-savesetting';
818  break;
819  case self::EXT_DELETE:
820  $do = 'basic-lti-deletesetting';
821  break;
822  }
823  if (isset($do)) {
824 
825  $url = $this->getSetting('ext_ims_lti_tool_setting_url');
826  $params = array();
827  $params['id'] = $this->getSetting('ext_ims_lti_tool_setting_id');
828  if (is_null($value)) {
829  $value = '';
830  }
831  $params['setting'] = $value;
832 
833  if ($this->doService($do, $url, $params)) {
834  switch ($action) {
835  case self::EXT_READ:
836  if (isset($this->extNodes['setting']['value'])) {
837  $response = $this->extNodes['setting']['value'];
838  if (is_array($response)) {
839  $response = '';
840  }
841  }
842  break;
843  case self::EXT_WRITE:
844  $this->setSetting('ext_ims_lti_tool_setting', $value);
845  $this->saveSettings();
846  $response = true;
847  break;
848  case self::EXT_DELETE:
849  $response = true;
850  break;
851  }
852  }
853  }
854 
855  return $response;
856 
857  }
$action
$url
$response
+ Here is the call graph for this function:

◆ fromConsumer()

static IMSGlobal\LTI\ToolProvider\ResourceLink::fromConsumer (   $consumer,
  $ltiResourceLinkId,
  $tempId = null 
)
static

Class constructor from consumer.

Parameters
ToolConsumer$consumerConsumer object
string$ltiResourceLinkIdResource link ID value
string$tempIdTemporary Resource link ID value (optional, default is null)
Returns
ResourceLink

Definition at line 986 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$consumer, and IMSGlobal\LTI\ToolProvider\ResourceLink\$ltiResourceLinkId.

Referenced by IMSGlobal\LTI\ToolProvider\ToolProvider\authenticate(), and IMSGlobal\LTI\ToolProvider\ToolProvider\checkForShare().

987  {
988 
989  $resourceLink = new ResourceLink();
990  $resourceLink->consumer = $consumer;
991  $resourceLink->dataConnector = $consumer->getDataConnector();
992  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
993  if (!empty($ltiResourceLinkId)) {
994  $resourceLink->load();
995  if (is_null($resourceLink->id) && !empty($tempId)) {
996  $resourceLink->ltiResourceLinkId = $tempId;
997  $resourceLink->load();
998  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
999  }
1000  }
1001 
1002  return $resourceLink;
1003 
1004  }
+ Here is the caller graph for this function:

◆ fromContext()

static IMSGlobal\LTI\ToolProvider\ResourceLink::fromContext (   $context,
  $ltiResourceLinkId,
  $tempId = null 
)
static

Class constructor from context.

Parameters
Context$contextContext object
string$ltiResourceLinkIdResource link ID value
string$tempIdTemporary Resource link ID value (optional, default is null)
Returns
ResourceLink

Definition at line 1014 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$context, and IMSGlobal\LTI\ToolProvider\ResourceLink\$ltiResourceLinkId.

1015  {
1016 
1017  $resourceLink = new ResourceLink();
1018  $resourceLink->setContextId($context->getRecordId());
1019  $resourceLink->context = $context;
1020  $resourceLink->dataConnector = $context->getDataConnector();
1021  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
1022  if (!empty($ltiResourceLinkId)) {
1023  $resourceLink->load();
1024  if (is_null($resourceLink->id) && !empty($tempId)) {
1025  $resourceLink->ltiResourceLinkId = $tempId;
1026  $resourceLink->load();
1027  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
1028  }
1029  }
1030 
1031  return $resourceLink;
1032 
1033  }

◆ fromRecordId()

static IMSGlobal\LTI\ToolProvider\ResourceLink::fromRecordId (   $id,
  $dataConnector 
)
static

Load the resource link from the database.

Parameters
int$idRecord ID of resource link
DataConnector$dataConnectorDatabase connection object
Returns
ResourceLink ResourceLink object

Definition at line 1043 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$dataConnector, and IMSGlobal\LTI\ToolProvider\ResourceLink\$id.

Referenced by IMSGlobal\LTI\ToolProvider\User\getResourceLink(), ilLTIAppEventListener\handleOutcomeWithoutLP(), and ilLTIAppEventListener\tryOutcomeService().

1044  {
1045  $resourceLink = new ResourceLink();
1046  $resourceLink->dataConnector = $dataConnector;
1047  $resourceLink->load($id);
1048 
1049  return $resourceLink;
1050 
1051  }
+ Here is the caller graph for this function:

◆ getConsumer()

IMSGlobal\LTI\ToolProvider\ResourceLink::getConsumer ( )

Get tool consumer.

Returns
ToolConsumer Tool consumer object for this resource link.

Definition at line 281 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$consumer, IMSGlobal\LTI\ToolProvider\ToolConsumer\fromRecordId(), IMSGlobal\LTI\ToolProvider\ResourceLink\getContext(), and IMSGlobal\LTI\ToolProvider\ResourceLink\getDataConnector().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doLTI11Service(), IMSGlobal\LTI\ToolProvider\ResourceLink\doMembershipsService(), IMSGlobal\LTI\ToolProvider\ResourceLink\doService(), and IMSGlobal\LTI\ToolProvider\ResourceLink\getKey().

282  {
283 
284  if (is_null($this->consumer)) {
285  // begin-patch ilias
286  #if (!is_null($this->context) || !is_null($this->contextId)) {
287  if($this->context || $this->contextId) {
288  $this->consumer = $this->getContext()->getConsumer();
289  } else {
290  $this->consumer = ToolConsumer::fromRecordId($this->consumerId, $this->getDataConnector());
291  }
292  }
293 
294  return $this->consumer;
295 
296  }
static fromRecordId($id, $dataConnector)
Load the tool consumer from the database by its record ID.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContext()

IMSGlobal\LTI\ToolProvider\ResourceLink::getContext ( )

Get context.

Returns
object LTIContext object for this resource link.

Definition at line 316 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$context, IMSGlobal\LTI\ToolProvider\Context\fromRecordId(), and IMSGlobal\LTI\ToolProvider\ResourceLink\getDataConnector().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\getConsumer(), IMSGlobal\LTI\ToolProvider\ResourceLink\getMembership(), and IMSGlobal\LTI\ToolProvider\ResourceLink\hasMembershipService().

317  {
318 
319  if (is_null($this->context) && !is_null($this->contextId)) {
320  $this->context = Context::fromRecordId($this->contextId, $this->getDataConnector());
321  }
322 
323  return $this->context;
324 
325  }
static fromRecordId($id, $dataConnector)
Load the context from the database.
Definition: Context.php:407
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContextId()

IMSGlobal\LTI\ToolProvider\ResourceLink::getContextId ( )

Get context record ID.

Returns
int Context record ID for this resource link.

Definition at line 332 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$contextId.

333  {
334 
335  return $this->contextId;
336 
337  }

◆ getDataConnector()

IMSGlobal\LTI\ToolProvider\ResourceLink::getDataConnector ( )

◆ getId()

IMSGlobal\LTI\ToolProvider\ResourceLink::getId ( )

Get resource link ID.

Returns
string ID for this resource link.

Definition at line 369 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$ltiResourceLinkId.

370  {
371 
373 
374  }

◆ getKey()

IMSGlobal\LTI\ToolProvider\ResourceLink::getKey ( )

Get tool consumer key.

Returns
string Consumer key value for this resource link.

Definition at line 357 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\getConsumer().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doLTI11Service().

358  {
359 
360  return $this->getConsumer()->getKey();
361 
362  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMembership()

IMSGlobal\LTI\ToolProvider\ResourceLink::getMembership ( )

Get Memberships.

Returns
mixed The array of User objects if successful, otherwise false

Definition at line 932 of file ResourceLink.php.

References $response, $url, and IMSGlobal\LTI\ToolProvider\ResourceLink\getContext().

933  {
934 
935  $response = false;
936  if (!empty($this->contextId)) {
937  $url = $this->getContext()->getSetting('custom_context_memberships_url');
938  if (!empty($url)) {
939  $service = new Service\Membership($this, $url);
940  $response = $service->get();
941  }
942  }
943 
944  return $response;
945 
946  }
$url
$response
+ Here is the call graph for this function:

◆ getRecordId()

IMSGlobal\LTI\ToolProvider\ResourceLink::getRecordId ( )

Get resource link record ID.

Returns
int Record ID for this resource link.

Definition at line 381 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$id.

382  {
383 
384  return $this->id;
385 
386  }

◆ getSetting()

IMSGlobal\LTI\ToolProvider\ResourceLink::getSetting (   $name,
  $default = '' 
)

Get a setting value.

Parameters
string$nameName of setting
string$defaultValue to return if the setting does not exist (optional, default is an empty string)
Returns
string Setting value

Definition at line 420 of file ResourceLink.php.

References $default, $name, and settings().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\checkValueType(), IMSGlobal\LTI\ToolProvider\ResourceLink\doMembershipsService(), IMSGlobal\LTI\ToolProvider\ResourceLink\doSettingService(), IMSGlobal\LTI\ToolProvider\ResourceLink\getToolSettings(), IMSGlobal\LTI\ToolProvider\ResourceLink\hasMembershipService(), IMSGlobal\LTI\ToolProvider\ResourceLink\hasMembershipsService(), IMSGlobal\LTI\ToolProvider\ResourceLink\hasOutcomesService(), IMSGlobal\LTI\ToolProvider\ResourceLink\hasSettingService(), IMSGlobal\LTI\ToolProvider\ResourceLink\hasToolSettingsService(), IMSGlobal\LTI\ToolProvider\ResourceLink\setSetting(), and IMSGlobal\LTI\ToolProvider\ResourceLink\setToolSettings().

421  {
422 
423  if (array_key_exists($name, $this->settings)) {
424  $value = $this->settings[$name];
425  } else {
426  $value = $default;
427  }
428 
429  return $value;
430 
431  }
settings()
Definition: settings.php:2
$default
Definition: build.php:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

IMSGlobal\LTI\ToolProvider\ResourceLink::getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 459 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$settings.

460  {
461 
462  return $this->settings;
463 
464  }

◆ getShares()

IMSGlobal\LTI\ToolProvider\ResourceLink::getShares ( )

Get an array of ResourceLinkShare objects for each resource link which is sharing this context.

Returns
array Array of ResourceLinkShare objects

Definition at line 971 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\getDataConnector().

972  {
973 
974  return $this->getDataConnector()->getSharesResourceLink($this);
975 
976  }
+ Here is the call graph for this function:

◆ getToolSettings()

IMSGlobal\LTI\ToolProvider\ResourceLink::getToolSettings (   $mode = Service\ToolSettings::MODE_CURRENT_LEVEL,
  $simple = true 
)

Get Tool Settings.

Parameters
int$modeMode for request (optional, default is current level only)
boolean$simpleTrue if all the simple media type is to be used (optional, default is true)
Returns
mixed The array of settings if successful, otherwise false

Definition at line 881 of file ResourceLink.php.

References $response, $url, and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

882  {
883 
884  $url = $this->getSetting('custom_link_setting_url');
885  $service = new Service\ToolSettings($this, $url, $simple);
886  $response = $service->get($mode);
887 
888  return $response;
889 
890  }
$url
$response
+ Here is the call graph for this function:

◆ getUserResultSourcedIDs()

IMSGlobal\LTI\ToolProvider\ResourceLink::getUserResultSourcedIDs (   $localOnly = false,
  $idScope = null 
)

Obtain an array of User objects for users with a result sourcedId.

The array may include users from other resource links which are sharing this resource link. It may also be optionally indexed by the user ID of a specified scope.

Parameters
boolean$localOnlyTrue if only users from this resource link are to be returned, not users from shared resource links (optional, default is false)
int$idScopeScope to use for ID values (optional, default is null for consumer default)
Returns
array Array of User objects

Definition at line 959 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\getDataConnector().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doMembershipsService().

960  {
961 
962  return $this->getDataConnector()->getUserResultSourcedIDsResourceLink($this, $localOnly, $idScope);
963 
964  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasMembershipService()

IMSGlobal\LTI\ToolProvider\ResourceLink::hasMembershipService ( )

Check if the Membership service is supported.

Returns
boolean True if this resource link supports the Membership service

Definition at line 915 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\getContext(), and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

916  {
917 
918  $has = !empty($this->contextId);
919  if ($has) {
920  $has = !empty($this->getContext()->getSetting('custom_context_memberships_url'));
921  }
922 
923  return $has;
924 
925  }
+ Here is the call graph for this function:

◆ hasMembershipsService()

IMSGlobal\LTI\ToolProvider\ResourceLink::hasMembershipsService ( )

Check if the Memberships extension service is supported.

Returns
boolean True if this resource link supports the Memberships extension service

Definition at line 515 of file ResourceLink.php.

References $url, and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

516  {
517 
518  $url = $this->getSetting('ext_ims_lis_memberships_url');
519 
520  return !empty($url);
521 
522  }
$url
+ Here is the call graph for this function:

◆ hasOutcomesService()

IMSGlobal\LTI\ToolProvider\ResourceLink::hasOutcomesService ( )

Check if the Outcomes service is supported.

Returns
boolean True if this resource link supports the Outcomes service (either the LTI 1.1 or extension service)

Definition at line 501 of file ResourceLink.php.

References $url, and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

502  {
503 
504  $url = $this->getSetting('ext_ims_lis_basic_outcome_url') . $this->getSetting('lis_outcome_service_url');
505 
506  return !empty($url);
507 
508  }
$url
+ Here is the call graph for this function:

◆ hasSettingService()

IMSGlobal\LTI\ToolProvider\ResourceLink::hasSettingService ( )

Check if the Setting extension service is supported.

Returns
boolean True if this resource link supports the Setting extension service

Definition at line 529 of file ResourceLink.php.

References $url, and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

530  {
531 
532  $url = $this->getSetting('ext_ims_lti_tool_setting_url');
533 
534  return !empty($url);
535 
536  }
$url
+ Here is the call graph for this function:

◆ hasToolSettingsService()

IMSGlobal\LTI\ToolProvider\ResourceLink::hasToolSettingsService ( )

Check if the Tool Settings service is supported.

Returns
boolean True if this resource link supports the Tool Settings service

Definition at line 864 of file ResourceLink.php.

References $url, and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

865  {
866 
867  $url = $this->getSetting('custom_link_setting_url');
868 
869  return !empty($url);
870 
871  }
$url
+ Here is the call graph for this function:

◆ initialise()

IMSGlobal\LTI\ToolProvider\ResourceLink::initialise ( )

Initialise the resource link.

Pseudonym for initialize().

Definition at line 240 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\initialize().

241  {
242 
243  $this->initialize();
244 
245  }
+ Here is the call graph for this function:

◆ initialize()

IMSGlobal\LTI\ToolProvider\ResourceLink::initialize ( )

Initialise the resource link.

Definition at line 221 of file ResourceLink.php.

References settings().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\__construct(), IMSGlobal\LTI\ToolProvider\ResourceLink\initialise(), and IMSGlobal\LTI\ToolProvider\ResourceLink\load().

222  {
223 
224  $this->title = '';
225  $this->settings = array();
226  $this->groupSets = null;
227  $this->groups = null;
228  $this->primaryResourceLinkId = null;
229  $this->shareApproved = null;
230  $this->created = null;
231  $this->updated = null;
232 
233  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

IMSGlobal\LTI\ToolProvider\ResourceLink::load (   $id = null)
private

Load the resource link from the database.

Parameters
int$idRecord ID of resource link (optional, default is null)
Returns
boolean True if resource link was successfully loaded

Definition at line 1064 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$id, IMSGlobal\LTI\ToolProvider\ResourceLink\getDataConnector(), and IMSGlobal\LTI\ToolProvider\ResourceLink\initialize().

1065  {
1066 
1067  $this->initialize();
1068  $this->id = $id;
1069 
1070  return $this->getDataConnector()->loadResourceLink($this);
1071 
1072  }
+ Here is the call graph for this function:

◆ save()

IMSGlobal\LTI\ToolProvider\ResourceLink::save ( )

Save the resource link to the database.

Returns
boolean True if the resource link was successfully saved.

Definition at line 252 of file ResourceLink.php.

References $ok, and IMSGlobal\LTI\ToolProvider\ResourceLink\getDataConnector().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\saveSettings().

253  {
254 
255  $ok = $this->getDataConnector()->saveResourceLink($this);
256  if ($ok) {
257  $this->settingsChanged = false;
258  }
259 
260  return $ok;
261 
262  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSettings()

IMSGlobal\LTI\ToolProvider\ResourceLink::saveSettings ( )

Save setting values.

Returns
boolean True if the settings were successfully saved

Definition at line 483 of file ResourceLink.php.

References $ok, and IMSGlobal\LTI\ToolProvider\ResourceLink\save().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doSettingService().

484  {
485 
486  if ($this->settingsChanged) {
487  $ok = $this->save();
488  } else {
489  $ok = true;
490  }
491 
492  return $ok;
493 
494  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConsumerId()

IMSGlobal\LTI\ToolProvider\ResourceLink::setConsumerId (   $consumerId)

Set tool consumer ID.

Parameters
int$consumerIdTool Consumer ID for this resource link.

Definition at line 303 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$consumerId.

304  {
305 
306  $this->consumer = null;
307  $this->consumerId = $consumerId;
308 
309  }

◆ setContextId()

IMSGlobal\LTI\ToolProvider\ResourceLink::setContextId (   $contextId)

Set context ID.

Parameters
int$contextIdContext ID for this resource link.

Definition at line 344 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$contextId.

345  {
346 
347  $this->context = null;
348  $this->contextId = $contextId;
349 
350  }

◆ setRecordId()

IMSGlobal\LTI\ToolProvider\ResourceLink::setRecordId (   $id)

Set resource link record ID.

Parameters
int$idRecord ID for this resource link.

Definition at line 393 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$id.

394  {
395 
396  $this->id = $id;
397 
398  }

◆ setSetting()

IMSGlobal\LTI\ToolProvider\ResourceLink::setSetting (   $name,
  $value = null 
)

Set a setting value.

Parameters
string$nameName of setting
string$valueValue to set, use an empty value to delete a setting (optional, default is null)

Definition at line 439 of file ResourceLink.php.

References $name, IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting(), and settings().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doSettingService().

440  {
441 
442  $old_value = $this->getSetting($name);
443  if ($value !== $old_value) {
444  if (!empty($value)) {
445  $this->settings[$name] = $value;
446  } else {
447  unset($this->settings[$name]);
448  }
449  $this->settingsChanged = true;
450  }
451 
452  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSettings()

IMSGlobal\LTI\ToolProvider\ResourceLink::setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 471 of file ResourceLink.php.

References IMSGlobal\LTI\ToolProvider\ResourceLink\$settings, and settings().

472  {
473 
474  $this->settings = $settings;
475 
476  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

◆ setToolSettings()

IMSGlobal\LTI\ToolProvider\ResourceLink::setToolSettings (   $settings = array())

Perform a Tool Settings service request.

Parameters
array$settingsAn associative array of settings (optional, default is none)
Returns
boolean True if action was successful, otherwise false

Definition at line 899 of file ResourceLink.php.

References $response, IMSGlobal\LTI\ToolProvider\ResourceLink\$settings, $url, and IMSGlobal\LTI\ToolProvider\ResourceLink\getSetting().

900  {
901 
902  $url = $this->getSetting('custom_link_setting_url');
903  $service = new Service\ToolSettings($this, $url);
904  $response = $service->set($settings);
905 
906  return $response;
907 
908  }
$url
$response
+ Here is the call graph for this function:

Field Documentation

◆ $consumer

ToolConsumer IMSGlobal\LTI\ToolProvider\ResourceLink::$consumer = null
private

◆ $consumerId

int IMSGlobal\LTI\ToolProvider\ResourceLink::$consumerId = null
private

Tool Consumer ID for this resource link.

Definition at line 164 of file ResourceLink.php.

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\setConsumerId().

◆ $context

Context IMSGlobal\LTI\ToolProvider\ResourceLink::$context = null
private

◆ $contextId

int IMSGlobal\LTI\ToolProvider\ResourceLink::$contextId = null
private

◆ $created

int IMSGlobal\LTI\ToolProvider\ResourceLink::$created = null

Date/time when the object was created.

Definition at line 139 of file ResourceLink.php.

◆ $dataConnector

mixed IMSGlobal\LTI\ToolProvider\ResourceLink::$dataConnector = null
private

◆ $extDoc

string IMSGlobal\LTI\ToolProvider\ResourceLink::$extDoc = null
private

XML document for the last extension service request.

Definition at line 194 of file ResourceLink.php.

◆ $extNodes

array IMSGlobal\LTI\ToolProvider\ResourceLink::$extNodes = null
private

XML node array for the last extension service request.

Definition at line 200 of file ResourceLink.php.

◆ $extRequest

string IMSGlobal\LTI\ToolProvider\ResourceLink::$extRequest = null

Request for last service request.

Definition at line 103 of file ResourceLink.php.

◆ $extRequestHeaders

array IMSGlobal\LTI\ToolProvider\ResourceLink::$extRequestHeaders = null

Request headers for last service request.

Definition at line 109 of file ResourceLink.php.

◆ $extResponse

string IMSGlobal\LTI\ToolProvider\ResourceLink::$extResponse = null

Response from last service request.

Definition at line 115 of file ResourceLink.php.

◆ $extResponseHeaders

array IMSGlobal\LTI\ToolProvider\ResourceLink::$extResponseHeaders = null

Response header from last service request.

Definition at line 121 of file ResourceLink.php.

◆ $groups

array IMSGlobal\LTI\ToolProvider\ResourceLink::$groups = null

User groups (null if the consumer does not support the groups enhancement)

Definition at line 97 of file ResourceLink.php.

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\doMembershipsService().

◆ $groupSets

array IMSGlobal\LTI\ToolProvider\ResourceLink::$groupSets = null

User group sets (null if the consumer does not support the groups enhancement)

Definition at line 91 of file ResourceLink.php.

◆ $id

◆ $ltiResourceLinkId

string IMSGlobal\LTI\ToolProvider\ResourceLink::$ltiResourceLinkId = null

Resource link ID as supplied in the last connection request.

Definition at line 85 of file ResourceLink.php.

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\fromConsumer(), IMSGlobal\LTI\ToolProvider\ResourceLink\fromContext(), and IMSGlobal\LTI\ToolProvider\ResourceLink\getId().

◆ $primaryResourceLinkId

string IMSGlobal\LTI\ToolProvider\ResourceLink::$primaryResourceLinkId = null

Consumer key value for resource link being shared (if any).

Definition at line 127 of file ResourceLink.php.

◆ $settings

array IMSGlobal\LTI\ToolProvider\ResourceLink::$settings = null
private

Setting values (LTI parameters, custom parameters and local parameters).

Definition at line 182 of file ResourceLink.php.

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLink\getSettings(), IMSGlobal\LTI\ToolProvider\ResourceLink\setSettings(), and IMSGlobal\LTI\ToolProvider\ResourceLink\setToolSettings().

◆ $settingsChanged

boolean IMSGlobal\LTI\ToolProvider\ResourceLink::$settingsChanged = false
private

Whether the settings value have changed since last saved.

Definition at line 188 of file ResourceLink.php.

◆ $shareApproved

boolean IMSGlobal\LTI\ToolProvider\ResourceLink::$shareApproved = null

Whether the sharing request has been approved by the primary resource link.

Definition at line 133 of file ResourceLink.php.

◆ $title

string IMSGlobal\LTI\ToolProvider\ResourceLink::$title = null

Context title.

Definition at line 79 of file ResourceLink.php.

◆ $updated

int IMSGlobal\LTI\ToolProvider\ResourceLink::$updated = null

Date/time when the object was last updated.

Definition at line 145 of file ResourceLink.php.

◆ EXT_CREATE

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_CREATE = 4

Create action.

Definition at line 39 of file ResourceLink.php.

◆ EXT_DELETE

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_DELETE = 3

Delete action.

Definition at line 35 of file ResourceLink.php.

◆ EXT_READ

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_READ = 1

Read action.

Definition at line 27 of file ResourceLink.php.

◆ EXT_TYPE_DECIMAL

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_TYPE_DECIMAL = 'decimal'

Decimal outcome type.

Definition at line 48 of file ResourceLink.php.

◆ EXT_TYPE_LETTER_AF

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_TYPE_LETTER_AF = 'letteraf'

Letter (A-F) outcome type.

Definition at line 60 of file ResourceLink.php.

◆ EXT_TYPE_LETTER_AF_PLUS

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_TYPE_LETTER_AF_PLUS = 'letterafplus'

Letter (A-F) with optional +/- outcome type.

Definition at line 64 of file ResourceLink.php.

◆ EXT_TYPE_PASS_FAIL

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_TYPE_PASS_FAIL = 'passfail'

Pass/fail outcome type.

Definition at line 68 of file ResourceLink.php.

◆ EXT_TYPE_PERCENTAGE

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_TYPE_PERCENTAGE = 'percentage'

Percentage outcome type.

Definition at line 52 of file ResourceLink.php.

◆ EXT_TYPE_RATIO

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_TYPE_RATIO = 'ratio'

Ratio outcome type.

Definition at line 56 of file ResourceLink.php.

◆ EXT_TYPE_TEXT

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_TYPE_TEXT = 'freetext'

Free text outcome type.

Definition at line 72 of file ResourceLink.php.

◆ EXT_UPDATE

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_UPDATE = 5

Update action.

Definition at line 43 of file ResourceLink.php.

◆ EXT_WRITE

const IMSGlobal\LTI\ToolProvider\ResourceLink::EXT_WRITE = 2

Write (create/update) action.

Definition at line 31 of file ResourceLink.php.


The documentation for this class was generated from the following file: