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