ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilPrgInvalidateExpiredProgressesCronJob.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 /*
24  * This invalidates a successful progress if validityOfQualification is reached.
25  *
26  * This is deprecated, I think.
27  * It is perfectly feasible to raise some event for this, though,
28  * but invalidation is reached by a date rather than a flag set by a cron job.
29  */
31 {
32  private const ID = 'prg_invalidate_expired_progresses';
33 
35  protected ilLanguage $lng;
38 
39  public function __construct()
40  {
41  global $DIC;
42  $this->log = $DIC['ilLog'];
43  $this->lng = $DIC['lng'];
44  $this->lng->loadLanguageModule('prg');
45 
47  $this->assignment_repo = $dic['repo.assignment'];
48  $this->settings_repo = $dic['model.Settings.ilStudyProgrammeSettingsRepository'];
49  }
50 
51  public function getTitle(): string
52  {
53  return $this->lng->txt('prg_invalidate_expired_progresses_title');
54  }
55 
56  public function getDescription(): string
57  {
58  return $this->lng->txt('prg_invalidate_expired_progresses_desc');
59  }
60 
61  public function getId(): string
62  {
63  return self::ID;
64  }
65 
66  public function hasAutoActivation(): bool
67  {
68  return true;
69  }
70 
71  public function hasFlexibleSchedule(): bool
72  {
73  return true;
74  }
75 
77  {
78  return CronJobScheduleType::SCHEDULE_TYPE_IN_DAYS;
79  }
80 
81  public function getDefaultScheduleValue(): ?int
82  {
83  return 1;
84  }
85 
86  public function run(): ilCronJobResult
87  {
88  $result = new ilCronJobResult();
89  $expired = $this->assignment_repo->getExpiredAndNotInvalidated();
90 
91  if ($expired === []) {
92  $result->setStatus(ilCronJobResult::STATUS_NO_ACTION);
93  return $result;
94  }
95 
96  foreach ($expired as $assignment) {
97  try {
98  $assignment = $assignment->invalidate($this->settings_repo);
99  $this->assignment_repo->store($assignment);
100  } catch (ilException $e) {
101  $this->log->write('an error occured: ' . $e->getMessage());
102  $result->setStatus(ilCronJobResult::STATUS_FAIL);
103  return $result;
104  }
105  }
106 
107  $result->setStatus(ilCronJobResult::STATUS_OK);
108  return $result;
109  }
110 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
final const STATUS_NO_ACTION
global $DIC
Definition: shib_login.php:25
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
$dic
Definition: ltiresult.php:33