ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 1068 of file ResourceLink.php.

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

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

1069  {
1070 
1071  if (empty($supportedTypes)) {
1072  $supportedTypes = explode(',', str_replace(' ', '', strtolower($this->getSetting('ext_ims_lis_resultvalue_sourcedids', self::EXT_TYPE_DECIMAL))));
1073  }
1074  $type = $ltiOutcome->type;
1075  $value = $ltiOutcome->getValue();
1076 // Check whether the type is supported or there is no value
1077  $ok = in_array($type, $supportedTypes) || (strlen($value) <= 0);
1078  if (!$ok) {
1079 // Convert numeric values to decimal
1080  if ($type === self::EXT_TYPE_PERCENTAGE) {
1081  if (substr($value, -1) === '%') {
1082  $value = substr($value, 0, -1);
1083  }
1084  $ok = is_numeric($value) && ($value >= 0) && ($value <= 100);
1085  if ($ok) {
1086  $ltiOutcome->setValue($value / 100);
1087  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1088  }
1089  } else if ($type === self::EXT_TYPE_RATIO) {
1090  $parts = explode('/', $value, 2);
1091  $ok = (count($parts) === 2) && is_numeric($parts[0]) && is_numeric($parts[1]) && ($parts[0] >= 0) && ($parts[1] > 0);
1092  if ($ok) {
1093  $ltiOutcome->setValue($parts[0] / $parts[1]);
1094  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1095  }
1096 // Convert letter_af to letter_af_plus or text
1097  } else if ($type === self::EXT_TYPE_LETTER_AF) {
1098  if (in_array(self::EXT_TYPE_LETTER_AF_PLUS, $supportedTypes)) {
1099  $ok = true;
1100  $ltiOutcome->type = self::EXT_TYPE_LETTER_AF_PLUS;
1101  } else if (in_array(self::EXT_TYPE_TEXT, $supportedTypes)) {
1102  $ok = true;
1103  $ltiOutcome->type = self::EXT_TYPE_TEXT;
1104  }
1105 // Convert letter_af_plus to letter_af or text
1106  } else if ($type === self::EXT_TYPE_LETTER_AF_PLUS) {
1107  if (in_array(self::EXT_TYPE_LETTER_AF, $supportedTypes) && (strlen($value) === 1)) {
1108  $ok = true;
1109  $ltiOutcome->type = self::EXT_TYPE_LETTER_AF;
1110  } else if (in_array(self::EXT_TYPE_TEXT, $supportedTypes)) {
1111  $ok = true;
1112  $ltiOutcome->type = self::EXT_TYPE_TEXT;
1113  }
1114 // Convert text to decimal
1115  } else if ($type === self::EXT_TYPE_TEXT) {
1116  $ok = is_numeric($value) && ($value >= 0) && ($value <=1);
1117  if ($ok) {
1118  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1119  } else if (substr($value, -1) === '%') {
1120  $value = substr($value, 0, -1);
1121  $ok = is_numeric($value) && ($value >= 0) && ($value <=100);
1122  if ($ok) {
1123  if (in_array(self::EXT_TYPE_PERCENTAGE, $supportedTypes)) {
1124  $ltiOutcome->type = self::EXT_TYPE_PERCENTAGE;
1125  } else {
1126  $ltiOutcome->setValue($value / 100);
1127  $ltiOutcome->type = self::EXT_TYPE_DECIMAL;
1128  }
1129  }
1130  }
1131  }
1132  }
1133 
1134  return $ok;
1135 
1136  }
$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 1190 of file ResourceLink.php.

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

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

1191  {
1192 
1193  $ok = false;
1194  $this->extRequest = null;
1195  $this->extRequestHeaders = '';
1196  $this->extResponse = null;
1197  $this->extResponseHeaders = '';
1198  if (!empty($url)) {
1199  $id = uniqid();
1200  $xmlRequest = <<< EOD
1201 <?xml version = "1.0" encoding = "UTF-8"?>
1202 <imsx_POXEnvelopeRequest xmlns = "http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">
1203  <imsx_POXHeader>
1204  <imsx_POXRequestHeaderInfo>
1205  <imsx_version>V1.0</imsx_version>
1206  <imsx_messageIdentifier>{$id}</imsx_messageIdentifier>
1207  </imsx_POXRequestHeaderInfo>
1208  </imsx_POXHeader>
1209  <imsx_POXBody>
1210  <{$type}Request>
1211 {$xml}
1212  </{$type}Request>
1213  </imsx_POXBody>
1214 </imsx_POXEnvelopeRequest>
1215 EOD;
1216 // Calculate body hash
1217  $hash = base64_encode(sha1($xmlRequest, true));
1218  $params = array('oauth_body_hash' => $hash);
1219 
1220 // Add OAuth signature
1221  $hmacMethod = new OAuth\OAuthSignatureMethod_HMAC_SHA1();
1222  $consumer = new OAuth\OAuthConsumer($this->getConsumer()->getKey(), $this->getConsumer()->secret, null);
1224  $req->sign_request($hmacMethod, $consumer, null);
1225  $params = $req->get_parameters();
1226  $header = $req->to_header();
1227  $header .= "\nContent-Type: application/xml";
1228 // Connect to tool consumer
1229  $http = new HTTPMessage($url, 'POST', $xmlRequest, $header);
1230 // Parse XML response
1231  if ($http->send()) {
1232  $this->extResponse = $http->response;
1233  $this->extResponseHeaders = $http->responseHeaders;
1234  try {
1235  $this->extDoc = new DOMDocument();
1236  $this->extDoc->loadXML($http->response);
1237  $this->extNodes = $this->domnodeToArray($this->extDoc->documentElement);
1238  if (isset($this->extNodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_codeMajor']) &&
1239  ($this->extNodes['imsx_POXHeader']['imsx_POXResponseHeaderInfo']['imsx_statusInfo']['imsx_codeMajor'] === 'success')) {
1240  $ok = true;
1241  }
1242  } catch (\Exception $e) {
1243  }
1244  }
1245  $this->extRequest = $http->request;
1246  $this->extRequestHeaders = $http->requestHeaders;
1247  }
1248 
1249  return $ok;
1250 
1251  }
$params
Definition: disable.php:11
$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
$xml
Definition: metadata.php:240
$http
Definition: raiseError.php:7
EOD
Definition: example_053.php:93
Create styles array
The data for the language used.
$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 679 of file ResourceLink.php.

References $email, IMSGlobal\LTI\ToolProvider\ResourceLink\$groups, $i, IMSGlobal\LTI\ToolProvider\ResourceLink\$id, $ok, $params, $url, $users, array, 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().

680  {
681 
682  $users = array();
684  $this->extResponse = null;
685  $url = $this->getSetting('ext_ims_lis_memberships_url');
686  $params = array();
687  $params['id'] = $this->getSetting('ext_ims_lis_memberships_id');
688  $ok = false;
689  if ($withGroups) {
690  $ok = $this->doService('basic-lis-readmembershipsforcontextwithgroups', $url, $params);
691  }
692  if ($ok) {
693  $this->groupSets = array();
694  $this->groups = array();
695  } else {
696  $ok = $this->doService('basic-lis-readmembershipsforcontext', $url, $params);
697  }
698 
699  if ($ok) {
700  if (!isset($this->extNodes['memberships']['member'])) {
701  $members = array();
702  } else if (!isset($this->extNodes['memberships']['member'][0])) {
703  $members = array();
704  $members[0] = $this->extNodes['memberships']['member'];
705  } else {
706  $members = $this->extNodes['memberships']['member'];
707  }
708 
709  for ($i = 0; $i < count($members); $i++) {
710 
711  $user = User::fromResourceLink($this, $members[$i]['user_id']);
712 
713 // Set the user name
714  $firstname = (isset($members[$i]['person_name_given'])) ? $members[$i]['person_name_given'] : '';
715  $lastname = (isset($members[$i]['person_name_family'])) ? $members[$i]['person_name_family'] : '';
716  $fullname = (isset($members[$i]['person_name_full'])) ? $members[$i]['person_name_full'] : '';
717  $user->setNames($firstname, $lastname, $fullname);
718 
719 // Set the user email
720  $email = (isset($members[$i]['person_contact_email_primary'])) ? $members[$i]['person_contact_email_primary'] : '';
721  $user->setEmail($email, $this->getConsumer()->defaultEmail);
722 
724  if (isset($members[$i]['roles'])) {
725  $user->roles = ToolProvider::parseRoles($members[$i]['roles']);
726  }
727 
728 // Set the user groups
729  if (!isset($members[$i]['groups']['group'])) {
730  $groups = array();
731  } else if (!isset($members[$i]['groups']['group'][0])) {
732  $groups = array();
733  $groups[0] = $members[$i]['groups']['group'];
734  } else {
735  $groups = $members[$i]['groups']['group'];
736  }
737  for ($j = 0; $j < count($groups); $j++) {
738  $group = $groups[$j];
739  if (isset($group['set'])) {
740  $set_id = $group['set']['id'];
741  if (!isset($this->groupSets[$set_id])) {
742  $this->groupSets[$set_id] = array('title' => $group['set']['title'], 'groups' => array(),
743  'num_members' => 0, 'num_staff' => 0, 'num_learners' => 0);
744  }
745  $this->groupSets[$set_id]['num_members']++;
746  if ($user->isStaff()) {
747  $this->groupSets[$set_id]['num_staff']++;
748  }
749  if ($user->isLearner()) {
750  $this->groupSets[$set_id]['num_learners']++;
751  }
752  if (!in_array($group['id'], $this->groupSets[$set_id]['groups'])) {
753  $this->groupSets[$set_id]['groups'][] = $group['id'];
754  }
755  $this->groups[$group['id']] = array('title' => $group['title'], 'set' => $set_id);
756  } else {
757  $this->groups[$group['id']] = array('title' => $group['title']);
758  }
759  $user->groups[] = $group['id'];
760  }
761 
762 // If a result sourcedid is provided save the user
763  if (isset($members[$i]['lis_result_sourcedid'])) {
764  $user->ltiResultSourcedId = $members[$i]['lis_result_sourcedid'];
765  $user->save();
766  }
767  $users[] = $user;
768 
769 // Remove old user (if it exists)
770  unset($oldUsers[$user->getId(ToolProvider::ID_SCOPE_RESOURCE)]);
771  }
772 
773 // Delete any old users which were not in the latest list from the tool consumer
774  foreach ($oldUsers as $id => $user) {
775  $user->delete();
776  }
777  } else {
778  $users = false;
779  }
780 
781  return $users;
782 
783  }
$params
Definition: disable.php:11
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:193
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
Create styles array
The data for the language used.
$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 1260 of file ResourceLink.php.

References $i, $output, $s, $t, array, and string.

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

1261  {
1262 
1263  $output = '';
1264  switch ($node->nodeType) {
1265  case XML_CDATA_SECTION_NODE:
1266  case XML_TEXT_NODE:
1267  $output = trim($node->textContent);
1268  break;
1269  case XML_ELEMENT_NODE:
1270  for ($i = 0; $i < $node->childNodes->length; $i++) {
1271  $child = $node->childNodes->item($i);
1272  $v = $this->domnodeToArray($child);
1273  if (isset($child->tagName)) {
1274  $t = $child->tagName;
1275  if (!isset($output[$t])) {
1276  $output[$t] = array();
1277  }
1278  $output[$t][] = $v;
1279  } else {
1280  $s = (string) $v;
1281  if (strlen($s) > 0) {
1282  $output = $s;
1283  }
1284  }
1285  }
1286  if (is_array($output)) {
1287  if ($node->attributes->length) {
1288  $a = array();
1289  foreach ($node->attributes as $attrName => $attrNode) {
1290  $a[$attrName] = (string) $attrNode->value;
1291  }
1292  $output['@attributes'] = $a;
1293  }
1294  foreach ($output as $t => $v) {
1295  if (is_array($v) && count($v)==1 && $t!='@attributes') {
1296  $output[$t] = $v[0];
1297  }
1298  }
1299  }
1300  break;
1301  }
1302 
1303  return $output;
1304 
1305  }
Add rich text string
$s
Definition: pwgen.php:45
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Create styles array
The data for the language used.
$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, $params, $response, $xml, array, IMSGlobal\LTI\ToolProvider\ResourceLink\checkValueType(), IMSGlobal\LTI\ToolProvider\ResourceLink\doLTI11Service(), IMSGlobal\LTI\ToolProvider\ResourceLink\doService(), and EOF.

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

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

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

1148  {
1149 
1150  $ok = false;
1151  $this->extRequest = null;
1152  $this->extRequestHeaders = '';
1153  $this->extResponse = null;
1154  $this->extResponseHeaders = '';
1155  if (!empty($url)) {
1156  $params = $this->getConsumer()->signParameters($url, $type, $this->getConsumer()->ltiVersion, $params);
1157 // Connect to tool consumer
1158  $http = new HTTPMessage($url, 'POST', $params);
1159 // Parse XML response
1160  if ($http->send()) {
1161  $this->extResponse = $http->response;
1162  $this->extResponseHeaders = $http->responseHeaders;
1163  try {
1164  $this->extDoc = new DOMDocument();
1165  $this->extDoc->loadXML($http->response);
1166  $this->extNodes = $this->domnodeToArray($this->extDoc->documentElement);
1167  if (isset($this->extNodes['statusinfo']['codemajor']) && ($this->extNodes['statusinfo']['codemajor'] === 'Success')) {
1168  $ok = true;
1169  }
1170  } catch (\Exception $e) {
1171  }
1172  }
1173  $this->extRequest = $http->request;
1174  $this->extRequestHeaders = $http->requestHeaders;
1175  }
1176 
1177  return $ok;
1178 
1179  }
$params
Definition: disable.php:11
$type
$http
Definition: raiseError.php:7
$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 793 of file ResourceLink.php.

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

794  {
795 
796  $response = false;
797  $this->extResponse = null;
798  switch ($action) {
799  case self::EXT_READ:
800  $do = 'basic-lti-loadsetting';
801  break;
802  case self::EXT_WRITE:
803  $do = 'basic-lti-savesetting';
804  break;
805  case self::EXT_DELETE:
806  $do = 'basic-lti-deletesetting';
807  break;
808  }
809  if (isset($do)) {
810 
811  $url = $this->getSetting('ext_ims_lti_tool_setting_url');
812  $params = array();
813  $params['id'] = $this->getSetting('ext_ims_lti_tool_setting_id');
814  if (is_null($value)) {
815  $value = '';
816  }
817  $params['setting'] = $value;
818 
819  if ($this->doService($do, $url, $params)) {
820  switch ($action) {
821  case self::EXT_READ:
822  if (isset($this->extNodes['setting']['value'])) {
823  $response = $this->extNodes['setting']['value'];
824  if (is_array($response)) {
825  $response = '';
826  }
827  }
828  break;
829  case self::EXT_WRITE:
830  $this->setSetting('ext_ims_lti_tool_setting', $value);
831  $this->saveSettings();
832  $response = true;
833  break;
834  case self::EXT_DELETE:
835  $response = true;
836  break;
837  }
838  }
839  }
840 
841  return $response;
842 
843  }
$params
Definition: disable.php:11
$action
Create styles array
The data for the language used.
$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 972 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().

973  {
974 
975  $resourceLink = new ResourceLink();
976  $resourceLink->consumer = $consumer;
977  $resourceLink->dataConnector = $consumer->getDataConnector();
978  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
979  if (!empty($ltiResourceLinkId)) {
980  $resourceLink->load();
981  if (is_null($resourceLink->id) && !empty($tempId)) {
982  $resourceLink->ltiResourceLinkId = $tempId;
983  $resourceLink->load();
984  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
985  }
986  }
987 
988  return $resourceLink;
989 
990  }
+ 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 1000 of file ResourceLink.php.

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

1001  {
1002 
1003  $resourceLink = new ResourceLink();
1004  $resourceLink->setContextId($context->getRecordId());
1005  $resourceLink->context = $context;
1006  $resourceLink->dataConnector = $context->getDataConnector();
1007  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
1008  if (!empty($ltiResourceLinkId)) {
1009  $resourceLink->load();
1010  if (is_null($resourceLink->id) && !empty($tempId)) {
1011  $resourceLink->ltiResourceLinkId = $tempId;
1012  $resourceLink->load();
1013  $resourceLink->ltiResourceLinkId = $ltiResourceLinkId;
1014  }
1015  }
1016 
1017  return $resourceLink;
1018 
1019  }

◆ 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 1029 of file ResourceLink.php.

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

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

1030  {
1031  $resourceLink = new ResourceLink();
1032  $resourceLink->dataConnector = $dataConnector;
1033  $resourceLink->load($id);
1034 
1035  return $resourceLink;
1036 
1037  }
+ 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 918 of file ResourceLink.php.

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

919  {
920 
921  $response = false;
922  if (!empty($this->contextId)) {
923  $url = $this->getContext()->getSetting('custom_context_memberships_url');
924  if (!empty($url)) {
925  $service = new Service\Membership($this, $url);
926  $response = $service->get();
927  }
928  }
929 
930  return $response;
931 
932  }
$service
Definition: login.php:15
$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 $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  }
if($format !==null) $name
Definition: metadata.php:146
settings()
Definition: settings.php:2
+ 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 957 of file ResourceLink.php.

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

958  {
959 
960  return $this->getDataConnector()->getSharesResourceLink($this);
961 
962  }
+ 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 867 of file ResourceLink.php.

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

868  {
869 
870  $url = $this->getSetting('custom_link_setting_url');
871  $service = new Service\ToolSettings($this, $url, $simple);
872  $response = $service->get($mode);
873 
874  return $response;
875 
876  }
$service
Definition: login.php:15
$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 945 of file ResourceLink.php.

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

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

946  {
947 
948  return $this->getDataConnector()->getUserResultSourcedIDsResourceLink($this, $localOnly, $idScope);
949 
950  }
+ 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 901 of file ResourceLink.php.

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

902  {
903 
904  $has = !empty($this->contextId);
905  if ($has) {
906  $has = !empty($this->getContext()->getSetting('custom_context_memberships_url'));
907  }
908 
909  return $has;
910 
911  }
+ 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 850 of file ResourceLink.php.

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

851  {
852 
853  $url = $this->getSetting('custom_link_setting_url');
854 
855  return !empty($url);
856 
857  }
$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 array, and 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  }
Create styles array
The data for the language used.
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 1050 of file ResourceLink.php.

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

1051  {
1052 
1053  $this->initialize();
1054  $this->id = $id;
1055 
1056  return $this->getDataConnector()->loadResourceLink($this);
1057 
1058  }
+ 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  }
if($format !==null) $name
Definition: metadata.php:146
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 885 of file ResourceLink.php.

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

886  {
887 
888  $url = $this->getSetting('custom_link_setting_url');
889  $service = new Service\ToolSettings($this, $url);
890  $response = $service->set($settings);
891 
892  return $response;
893 
894  }
$service
Definition: login.php:15
$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: