19 declare(strict_types=1);
34 public const JOB_ID =
'xapi_deletion_cron';
42 private \ILIAS\DI\Container
$dic;
49 $DIC->language()->loadLanguageModule(
'cmix');
54 $lrsTypeId = $settings->get(
'lrs_type_id',
'0');
59 $this->lrsType =
null;
72 return $this->dic->language()->txt(
"cron_xapi_del");
77 return $this->dic->language()->txt(
"cron_xapi_del_desc");
98 return JobScheduleType::DAILY;
120 $this->log->debug(
'run');
223 $newDeletedObjects = $this->model->getNewDeletedXapiObjects();
226 $deletedObjectData = array();
228 foreach ($newDeletedObjects as $deletedObject) {
229 $this->log->debug(
"delete for " . (
string) $deletedObject[
'obj_id']);
231 $this->model->setXapiObjAsUpdated($deletedObject[
'obj_id']);
234 (
int) $deletedObject[
'obj_id'],
235 (
int) $deletedObject[
'type_id'],
236 (
string) $deletedObject[
'activity_id'],
240 $done = $deleteRequest->delete();
244 $this->log->debug(
"deleted data for object: " . (
string) $deletedObject[
'obj_id']);
245 $deletedObjectData[] = $deletedObject[
'obj_id'];
246 $this->model->deleteXapiObjectEntry($deletedObject[
'obj_id']);
248 $this->log->debug(
"error: delete data for object: " . (
string) $deletedObject[
'obj_id']);
249 $this->model->resetUpdatedXapiObj($deletedObject[
'obj_id']);
256 $newDeletedUsers = $this->model->getNewDeletedUsers();
257 foreach ($newDeletedUsers as $deletedUser) {
258 $usrId = $deletedUser[
'usr_id'];
260 $this->model->setUserAsUpdated($usrId);
262 $xapiObjects = $this->model->getXapiObjectsByUser($usrId);
263 $usrObjectsDone =
true;
264 foreach ($xapiObjects as $xapiObject) {
265 $objId = $xapiObject[
'obj_id'];
267 if (in_array(
$objId, $deletedObjectData)) {
268 $this->log->debug(
"nothing to do, because of complete object data deletion in previous step");
272 (
int) $xapiObject[
'obj_id'],
273 (
int) $xapiObject[
'lrs_type_id'],
274 (
string) $xapiObject[
'activity_id'],
278 $done = $deleteRequest->delete();
281 $this->log->debug(
"deleted object " . (
string)
$objId .
" data for user " . (
string) $usrId);
283 $this->log->debug(
"error deleting object " . (
string)
$objId .
" data for user " . (
string) $usrId);
284 $usrObjectsDone =
false;
288 if ($usrObjectsDone) {
289 $this->model->deleteUserEntry($usrId);
291 $this->model->resetUpdatedXapiUser($usrId);
301 $cronResult->setStatus(JobResult::STATUS_OK);
303 $cronResult->setStatus(JobResult::STATUS_FAIL);
static getLogger(string $a_component_id)
Get component logger.
hasAutoActivation()
@inheritdoc
Class ilCmiXapiStatementsDeleteRequest.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
hasFlexibleSchedule()
@inheritdoc
ilCmiXapiLrsType $lrsType
getDefaultScheduleValue()