Class ilLTIAppEventListener.
More...
|
static | handleEvent (string $a_component, string $a_event, array $a_parameter) |
| Handle an event in a listener.- Parameters
-
string | $a_component | component, e.g. "components/ILIAS/Forum" or "components/ILIAS/User" |
string | $a_event | event e.g. "createUser", "updateUser", "deleteUser", ... |
| array<string,mixed> | $a_parameter parameter array (assoc), array("name" => ..., "phone_office" => ...) |
More...
|
|
static | handleCronUpdate (ilDateTime $since) |
|
static | handleOutcomeWithoutLP (int $a_obj_id, int $a_usr_id, ?float $a_percentage) |
|
◆ __construct()
ilLTIAppEventListener::__construct |
( |
| ) |
|
|
protected |
◆ doCronUpdate()
ilLTIAppEventListener::doCronUpdate |
( |
ilDateTime |
$since | ) |
|
|
protected |
- Parameters
-
- Exceptions
-
Definition at line 96 of file class.ilLTIAppEventListener.php.
References $resources, ilObjUser\_checkExternalAuthAccount(), ilObjUser\_lookupId(), ilObject\_lookupObjId(), ilLPStatus\_lookupPercentage(), ilLPStatus\_lookupStatus(), ILIAS\Repository\logger(), and tryOutcomeService().
98 $this->
logger->debug(
'Starting cron update for lti outcome service');
100 $resources = $this->connector->lookupResourcesForAllUsersSinceDate($since);
101 foreach (
$resources as $consumer_ext_account => $user_resources) {
102 list($consumer, $ext_account) = explode(
'__', $consumer_ext_account, 2);
106 $this->
logger->info(
'No user found for lti_' . $consumer .
' -> ' . $ext_account);
110 foreach ($user_resources as $resource_info) {
111 $this->
logger->debug(
'Found resource: ' . $resource_info);
112 list($resource_id, $resource_ref_id) = explode(
'__', $resource_info);
123 $this->
tryOutcomeService((
int) $resource_id, $ext_account, $status, $percentage);
static _lookupPercentage(int $a_obj_id, int $a_user_id)
Lookup percentage.
static _lookupId($a_user_str)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
static _lookupObjId(int $ref_id)
tryOutcomeService(int $resource, string $ext_account, int $a_status, int $a_percentage)
try outcome service
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
◆ getInstance()
static ilLTIAppEventListener::getInstance |
( |
| ) |
|
|
staticprotected |
◆ handleCronUpdate()
static ilLTIAppEventListener::handleCronUpdate |
( |
ilDateTime |
$since | ) |
|
|
static |
◆ handleEvent()
static ilLTIAppEventListener::handleEvent |
( |
string |
$a_component, |
|
|
string |
$a_event, |
|
|
array |
$a_parameter |
|
) |
| |
|
static |
Handle an event in a listener.
- Parameters
-
string | $a_component | component, e.g. "components/ILIAS/Forum" or "components/ILIAS/User" |
string | $a_event | event e.g. "createUser", "updateUser", "deleteUser", ... |
| array<string,mixed> | $a_parameter parameter array (assoc), array("name" => ..., "phone_office" => ...) |
Implements ilAppEventListener.
Definition at line 175 of file class.ilLTIAppEventListener.php.
References ilLoggerFactory\getLogger().
178 $logger->
debug(
'Handling event: ' . $a_event .
' from ' . $a_component);
180 if ($a_component ==
'components/ILIAS/Tracking') {
181 if ($a_event ==
'updateStatus') {
182 $listener = self::getInstance();
183 $listener->handleUpdateStatus(
184 $a_parameter[
'obj_id'],
185 $a_parameter[
'usr_id'],
186 $a_parameter[
'status'],
187 $a_parameter[
'percentage']
static getLogger(string $a_component_id)
Get component logger.
debug(string $message, array $context=[])
◆ handleOutcomeWithoutLP()
static ilLTIAppEventListener::handleOutcomeWithoutLP |
( |
int |
$a_obj_id, |
|
|
int |
$a_usr_id, |
|
|
?float |
$a_percentage |
|
) |
| |
|
static |
Definition at line 206 of file class.ilLTIAppEventListener.php.
References $DIC, $ref_id, $resources, ilObject\_getAllReferences(), ilObjUser\_lookupAuthMode(), ilObjUser\_lookupExternalAccount(), ilObjectLP\getInstance(), ilLoggerFactory\getLogger(), and ilLPObjSettings\LP_MODE_DEACTIVATED.
Referenced by ilSCORM2004StoreData\persistCMIData(), and ilObjSCORMTracking\storeJsApiCmi().
213 if (strpos($auth_mode,
'lti_') ===
false) {
224 if ($a_percentage && $a_percentage > 0) {
225 $score = round($a_percentage / 100, 4);
230 list($lti, $consumer) = explode(
'_', $auth_mode);
234 foreach ((array) $refs as
$ref_id) {
245 $resource_link = ResourceLink::fromRecordId($resource,
$connector);
246 if ($resource_link->hasOutcomesService()) {
247 $user = UserResult::fromResourceLink($resource_link, $ext_account);
249 $outcome =
new Outcome((
string) $score);
251 $resource_link->doOutcomesService(
252 ServiceAction::Write,
ilLTIDataConnector $connector
static getLogger(string $a_component_id)
Get component logger.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupExternalAccount(int $a_user_id)
static _lookupAuthMode(int $a_usr_id)
lookupResourcesForUserObjectRelation(int $a_ref_id, string $a_lti_user, int $a_ext_consumer, ?ilDateTime $since=null)
Lookup resources for user object relation.
const LP_MODE_DEACTIVATED
debug(string $message, array $context=[])
static getInstance(int $obj_id)
◆ handleUpdateStatus()
ilLTIAppEventListener::handleUpdateStatus |
( |
int |
$a_obj_id, |
|
|
int |
$a_usr_id, |
|
|
int |
$a_status, |
|
|
int |
$a_percentage |
|
) |
| |
|
protected |
Handle update status.
Definition at line 61 of file class.ilLTIAppEventListener.php.
References $ref_id, $resources, ilObject\_getAllReferences(), ilObjUser\_lookupAuthMode(), ilObjUser\_lookupExternalAccount(), ilLogLevel\DEBUG, isLTIAuthMode(), ILIAS\Repository\logger(), and tryOutcomeService().
63 $this->
logger->debug(
'Handle update status');
66 $this->
logger->debug(
'Ignoring update for non-LTI-user.');
70 list($lti, $consumer) = explode(
'_', $auth_mode);
74 $this->
logger->debug(
'Refs for : ' . $a_obj_id .
': ' . count($refs));
75 foreach ((array) $refs as
$ref_id) {
76 $resources = $this->connector->lookupResourcesForUserObjectRelation(
82 $this->
logger->debug(
'Resources for update:');
86 $this->
tryOutcomeService((
int) $resource, $ext_account, $a_status, $a_percentage);
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupExternalAccount(int $a_user_id)
static _lookupAuthMode(int $a_usr_id)
tryOutcomeService(int $resource, string $ext_account, int $a_status, int $a_percentage)
try outcome service
isLTIAuthMode(string $auth_mode)
◆ isLTIAuthMode()
ilLTIAppEventListener::isLTIAuthMode |
( |
string |
$auth_mode | ) |
|
|
protected |
◆ tryOutcomeService()
ilLTIAppEventListener::tryOutcomeService |
( |
int |
$resource, |
|
|
string |
$ext_account, |
|
|
int |
$a_status, |
|
|
int |
$a_percentage |
|
) |
| |
|
protected |
◆ $connector
◆ $instance
◆ $logger
The documentation for this class was generated from the following file: