ILIAS  release_8 Revision v8.24
ILIAS\LTI\ToolProvider\UserResult Class Reference

Class to represent a platform user. More...

+ Inheritance diagram for ILIAS\LTI\ToolProvider\UserResult:
+ Collaboration diagram for ILIAS\LTI\ToolProvider\UserResult:

Public Member Functions

 __construct ()
 Class constructor. More...
 
 initialize ()
 Initialise the user. More...
 
 save ()
 Save the user to the database. More...
 
 delete ()
 Delete the user from the database. More...
 
 getResourceLink ()
 Get resource link. More...
 
 setResourceLink (ResourceLink $resourceLink)
 Set resource link. More...
 
 getRecordId ()
 Get record ID of user. More...
 
 setRecordId (int $id)
 Set record ID of user. More...
 
 setResourceLinkId (int $resourceLinkId)
 Set resource link ID of user. More...
 
 getDataConnector ()
 Get the data connector. More...
 
 setDataConnector (DataConnector $dataConnector)
 Set the data connector. More...
 
 getId (int $idScope=null, Platform $platform=null)
 Get the user ID (which may be a compound of the platform and resource link IDs). More...
 
- Public Member Functions inherited from ILIAS\LTI\ToolProvider\User
 __construct ()
 Class constructor. More...
 
 initialize ()
 Initialise the user. More...
 
 initialise ()
 Initialise the user. More...
 
 setNames (string $firstname, string $lastname, string $fullname)
 Set the user's name. More...
 
 setEmail (string $email, string $defaultEmail=null)
 Set the user's email address. More...
 
 isAdmin ()
 Check if the user is an administrator (at any of the system, institution or context levels). More...
 
 isStaff ()
 Check if the user is staff. More...
 
 isLearner ()
 Check if the user is a learner. More...
 

Static Public Member Functions

static fromRecordId (int $id, DataConnector $dataConnector)
 Load the user from the database. More...
 
static fromResourceLink (ResourceLink $resourceLink, string $ltiUserId)
 Class constructor from resource link. More...
 

Data Fields

string $ltiResultSourcedId = null
 UserResult's result sourcedid. More...
 
int $created = null
 Date/time the record was created. More...
 
int $updated = null
 Date/time the record was last updated. More...
 
- Data Fields inherited from ILIAS\LTI\ToolProvider\User
string $firstname = ''
 User's first name. More...
 
string $lastname = ''
 User's last name (surname or family name). More...
 
string $fullname = ''
 User's fullname. More...
 
string $sourcedId = null
 User's sourcedId. More...
 
string $username = null
 User's username. More...
 
string $email = ''
 User's email address. More...
 
string $image = ''
 User's image URI. More...
 
array $roles = array()
 Roles for user. More...
 
array $groups = array()
 Groups for user. More...
 
string $ltiUserId = null
 user ID as supplied in the last connection request. More...
 

Private Member Functions

 load (int $id=null)
 Load the user from the database. More...
 

Private Attributes

ResourceLink $resourceLink = null
 Resource link object. More...
 
int $resourceLinkId = null
 Resource link record ID. More...
 
int $id = null
 UserResult record ID value. More...
 
DataConnector $dataConnector = null
 Data connector object or string. More...
 

Additional Inherited Members

- Static Public Attributes inherited from ILIAS\LTI\ToolProvider\User
static bool $allowEmptyName = false
 Allow user name field to be empty? More...
 

Detailed Description

Class to represent a platform user.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com

Definition at line 30 of file UserResult.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LTI\ToolProvider\UserResult::__construct ( )

Class constructor.

Reimplemented from ILIAS\LTI\ToolProvider\User.

Definition at line 84 of file UserResult.php.

85 {
86 $this->initialize();
87 }
initialize()
Initialise the user.
Definition: UserResult.php:92

References ILIAS\LTI\ToolProvider\UserResult\initialize().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ILIAS\LTI\ToolProvider\UserResult::delete ( )

Delete the user from the database.

Returns
bool True if the user object was successfully deleted

Definition at line 121 of file UserResult.php.

121 : bool
122 {
123 $ok = $this->getDataConnector()->deleteUserResult($this);
124
125 return $ok;
126 }
getDataConnector()
Get the data connector.
Definition: UserResult.php:185

References ILIAS\LTI\ToolProvider\UserResult\getDataConnector().

+ Here is the call graph for this function:

◆ fromRecordId()

static ILIAS\LTI\ToolProvider\UserResult::fromRecordId ( int  $id,
DataConnector  $dataConnector 
)
static

Load the user from the database.

Parameters
int$idRecord ID of user
DataConnector$dataConnectorDatabase connection object
Returns
UserResult UserResult object

Definition at line 250 of file UserResult.php.

250 : UserResult
251 {
252 $userresult = new UserResult();
253 $userresult->dataConnector = $dataConnector;
254 $userresult->load($id);
255
256 return $userresult;
257 }
int $id
UserResult record ID value.
Definition: UserResult.php:72
DataConnector $dataConnector
Data connector object or string.
Definition: UserResult.php:79

References ILIAS\LTI\ToolProvider\UserResult\$dataConnector, and ILIAS\LTI\ToolProvider\UserResult\$id.

◆ fromResourceLink()

static ILIAS\LTI\ToolProvider\UserResult::fromResourceLink ( ResourceLink  $resourceLink,
string  $ltiUserId 
)
static

Class constructor from resource link.

Parameters
ResourceLink$resourceLinkResourceLink object
string$ltiUserIdUserResult ID value
Returns
UserResult UserResult object

Definition at line 265 of file UserResult.php.

265 : UserResult
266 {
267 $userresult = new UserResult();
268 $userresult->resourceLink = $resourceLink;
269 if (!is_null($resourceLink)) {
270 $userresult->resourceLinkId = $resourceLink->getRecordId();
271 $userresult->dataConnector = $resourceLink->getDataConnector();
272 }
273 $userresult->ltiUserId = $ltiUserId;
274 if (!empty($ltiUserId)) {
275 $userresult->load();
276 }
277
278 return $userresult;
279 }
ResourceLink $resourceLink
Resource link object.
Definition: UserResult.php:58
string $ltiUserId
user ID as supplied in the last connection request.
Definition: User.php:107

References ILIAS\LTI\ToolProvider\User\$ltiUserId, ILIAS\LTI\ToolProvider\UserResult\$resourceLink, ILIAS\LTI\ToolProvider\ResourceLink\getDataConnector(), and ILIAS\LTI\ToolProvider\ResourceLink\getRecordId().

Referenced by ILIAS\LTI\ToolProvider\Tool\authenticate(), ILIAS\LTI\ToolProvider\Service\Membership\getMembers(), ILIAS\LTI\ToolProvider\ResourceLink\getMemberships(), ilLTIAppEventListener\handleOutcomeWithoutLP(), and ilLTIAppEventListener\tryOutcomeService().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataConnector()

ILIAS\LTI\ToolProvider\UserResult::getDataConnector ( )

Get the data connector.

Returns
mixed Data connector object or string

Definition at line 185 of file UserResult.php.

186 {
188 }

References ILIAS\LTI\ToolProvider\UserResult\$dataConnector.

Referenced by ILIAS\LTI\ToolProvider\UserResult\delete(), ILIAS\LTI\ToolProvider\UserResult\getResourceLink(), ILIAS\LTI\ToolProvider\UserResult\load(), and ILIAS\LTI\ToolProvider\UserResult\save().

+ Here is the caller graph for this function:

◆ getId()

ILIAS\LTI\ToolProvider\UserResult::getId ( int  $idScope = null,
Platform  $platform = null 
)

Get the user ID (which may be a compound of the platform and resource link IDs).

Parameters
int | null$idScopeScope to use for user ID (optional, default is null for consumer default setting)
Platform | null$platformPlatform for user (optional)
Returns
string UserResult ID value

Definition at line 205 of file UserResult.php.

205 : string
206 {
207 $key = '';
208 if (is_null($platform) && !is_null($this->getResourceLink())) {
209 $platform = $this->getResourceLink()->getPlatform();
210 }
211 if (!is_null($platform)) {
212 $key = $platform->getId();
213 }
214 if (is_null($idScope) && !is_null($this->getResourceLink())) {
215 $idScope = $this->resourceLink->getPlatform()->idScope;
216 }
217 if (is_null($idScope)) {
218 $idScope = Tool::ID_SCOPE_ID_ONLY;
219 }
220 switch ($idScope) {
223 break;
225 if ($this->resourceLink->getContext() && $this->resourceLink->getContext()->ltiContextId) {
226 $id = $key . Tool::ID_SCOPE_SEPARATOR . $this->resourceLink->getContext()->ltiContextId;
227 }
229 break;
231 if (!is_null($this->resourceLink) && !empty($this->resourceLink->ltiResourceLinkId)) {
232 $id = $key . Tool::ID_SCOPE_SEPARATOR . $this->resourceLink->ltiResourceLinkId;
233 }
235 break;
236 default:
238 break;
239 }
240
241 return $id;
242 }
getId()
Get the platform ID.
Definition: Platform.php:285
const ID_SCOPE_RESOURCE
Prefix the ID with the consumer key and resource ID.
Definition: Tool.php:66
const ID_SCOPE_GLOBAL
Prefix an ID with the consumer key.
Definition: Tool.php:56
const ID_SCOPE_ID_ONLY
Use ID value only.
Definition: Tool.php:51
const ID_SCOPE_SEPARATOR
Character used to separate each element of an ID.
Definition: Tool.php:71
const ID_SCOPE_CONTEXT
Prefix the ID with the consumer key and context ID.
Definition: Tool.php:61
getResourceLink()
Get resource link.
Definition: UserResult.php:133
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\UserResult\$id, ILIAS\LTI\ToolProvider\$key, ILIAS\LTI\ToolProvider\User\$ltiUserId, ILIAS\LTI\ToolProvider\UserResult\getResourceLink(), ILIAS\LTI\ToolProvider\Tool\ID_SCOPE_CONTEXT, ILIAS\LTI\ToolProvider\Tool\ID_SCOPE_GLOBAL, ILIAS\LTI\ToolProvider\Tool\ID_SCOPE_ID_ONLY, ILIAS\LTI\ToolProvider\Tool\ID_SCOPE_RESOURCE, and ILIAS\LTI\ToolProvider\Tool\ID_SCOPE_SEPARATOR.

+ Here is the call graph for this function:

◆ getRecordId()

ILIAS\LTI\ToolProvider\UserResult::getRecordId ( )

Get record ID of user.

Returns
int Record ID of user

Definition at line 156 of file UserResult.php.

156 : ?int
157 {
158 return $this->id;
159 }

References ILIAS\LTI\ToolProvider\UserResult\$id.

◆ getResourceLink()

ILIAS\LTI\ToolProvider\UserResult::getResourceLink ( )

Get resource link.

Returns
ResourceLink Resource link object

Definition at line 133 of file UserResult.php.

133 : ?ResourceLink
134 {
135 if (is_null($this->resourceLink) && !is_null($this->resourceLinkId)) {
136 $this->resourceLink = ResourceLink::fromRecordId($this->resourceLinkId, $this->getDataConnector());
137 }
138
139 return $this->resourceLink;
140 }

References ILIAS\LTI\ToolProvider\UserResult\$resourceLink, ILIAS\LTI\ToolProvider\ResourceLink\fromRecordId(), and ILIAS\LTI\ToolProvider\UserResult\getDataConnector().

Referenced by ILIAS\LTI\ToolProvider\ResourceLink\doOutcomesService(), and ILIAS\LTI\ToolProvider\UserResult\getId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize()

ILIAS\LTI\ToolProvider\UserResult::initialize ( )

Initialise the user.

Reimplemented from ILIAS\LTI\ToolProvider\User.

Definition at line 92 of file UserResult.php.

93 {
94 parent::initialize();
95 $this->ltiResultSourcedId = null;
96 $this->created = null;
97 $this->updated = null;
98 }

Referenced by ILIAS\LTI\ToolProvider\UserResult\__construct(), ILIAS\LTI\ToolProvider\DataConnector\DataConnector\deleteUserResult(), and ILIAS\LTI\ToolProvider\UserResult\load().

+ Here is the caller graph for this function:

◆ load()

ILIAS\LTI\ToolProvider\UserResult::load ( int  $id = null)
private

Load the user from the database.

Parameters
int | null$idRecord ID of user (optional, default is null)
Returns
bool True if the user object was successfully loaded

Definition at line 290 of file UserResult.php.

290 : bool
291 {
292 $this->initialize();
293 $this->id = $id;
295 if (!is_null($dataConnector)) {
296 return $dataConnector->loadUserResult($this);
297 }
298
299 return false;
300 }
loadUserResult(UserResult $userresult)
Load user object.

References ILIAS\LTI\ToolProvider\UserResult\$dataConnector, ILIAS\LTI\ToolProvider\UserResult\$id, ILIAS\LTI\ToolProvider\UserResult\getDataConnector(), ILIAS\LTI\ToolProvider\UserResult\initialize(), and ILIAS\LTI\ToolProvider\DataConnector\DataConnector\loadUserResult().

+ Here is the call graph for this function:

◆ save()

ILIAS\LTI\ToolProvider\UserResult::save ( )

Save the user to the database.

Returns
bool True if the user object was successfully saved

Definition at line 105 of file UserResult.php.

105 : bool
106 {
107 if (!is_null($this->resourceLinkId)) {
108 $ok = $this->getDataConnector()->saveUserResult($this);
109 } else {
110 $ok = true;
111 }
112
113 return $ok;
114 }

References ILIAS\LTI\ToolProvider\UserResult\getDataConnector().

+ Here is the call graph for this function:

◆ setDataConnector()

ILIAS\LTI\ToolProvider\UserResult::setDataConnector ( DataConnector  $dataConnector)

Set the data connector.

Parameters
DataConnector$dataConnectorData connector object

Definition at line 194 of file UserResult.php.

195 {
196 $this->dataConnector = $dataConnector;
197 }

References ILIAS\LTI\ToolProvider\UserResult\$dataConnector.

◆ setRecordId()

ILIAS\LTI\ToolProvider\UserResult::setRecordId ( int  $id)

Set record ID of user.

Parameters
int$idRecord ID of user

Definition at line 165 of file UserResult.php.

166 {
167 $this->id = $id;
168 }

References ILIAS\LTI\ToolProvider\UserResult\$id.

◆ setResourceLink()

ILIAS\LTI\ToolProvider\UserResult::setResourceLink ( ResourceLink  $resourceLink)

Set resource link.

Parameters
ResourceLink$resourceLinkResource link object

Definition at line 146 of file UserResult.php.

147 {
148 $this->resourceLink = $resourceLink;
149 }

References ILIAS\LTI\ToolProvider\UserResult\$resourceLink.

◆ setResourceLinkId()

ILIAS\LTI\ToolProvider\UserResult::setResourceLinkId ( int  $resourceLinkId)

Set resource link ID of user.

Parameters
int$resourceLinkIdResource link ID of user

Definition at line 174 of file UserResult.php.

175 {
176 $this->resourceLink = null;
177 $this->resourceLinkId = $resourceLinkId;
178 }
int $resourceLinkId
Resource link record ID.
Definition: UserResult.php:65

References ILIAS\LTI\ToolProvider\UserResult\$resourceLinkId.

Field Documentation

◆ $created

int null ILIAS\LTI\ToolProvider\UserResult::$created = null

Date/time the record was created.

Definition at line 44 of file UserResult.php.

◆ $dataConnector

DataConnector null ILIAS\LTI\ToolProvider\UserResult::$dataConnector = null
private

◆ $id

◆ $ltiResultSourcedId

string null ILIAS\LTI\ToolProvider\UserResult::$ltiResultSourcedId = null

UserResult's result sourcedid.

Definition at line 37 of file UserResult.php.

◆ $resourceLink

ResourceLink null ILIAS\LTI\ToolProvider\UserResult::$resourceLink = null
private

◆ $resourceLinkId

int null ILIAS\LTI\ToolProvider\UserResult::$resourceLinkId = null
private

Resource link record ID.

Definition at line 65 of file UserResult.php.

Referenced by ILIAS\LTI\ToolProvider\UserResult\setResourceLinkId().

◆ $updated

int null ILIAS\LTI\ToolProvider\UserResult::$updated = null

Date/time the record was last updated.

Definition at line 51 of file UserResult.php.


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