ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPrgUpdateProgressCronJob.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
28 {
29  private const ID = 'prg_update_progress';
30 
32  protected ilLanguage $lng;
35  protected int $acting_user_id;
36 
37  public function __construct()
38  {
39  global $DIC;
40  $this->lng = $DIC['lng'];
41  $this->lng->loadLanguageModule('prg');
42 
43  $dic = ilStudyProgrammeDIC::dic();
44  $this->settings_repo = $dic['model.Settings.ilStudyProgrammeSettingsRepository'];
45  $this->assignment_repo = $dic['repo.assignment'];
46  $this->acting_user_id = $dic['current_user']->getId();
47  }
48 
49  public function getTitle(): string
50  {
51  return $this->lng->txt('prg_update_progress_title');
52  }
53 
54  public function getDescription(): string
55  {
56  return $this->lng->txt('prg_update_progress_description');
57  }
58 
59  public function getId(): string
60  {
61  return self::ID;
62  }
63 
64  public function hasAutoActivation(): bool
65  {
66  return true;
67  }
68 
69  public function hasFlexibleSchedule(): bool
70  {
71  return true;
72  }
73 
75  {
76  return CronJobScheduleType::SCHEDULE_TYPE_IN_DAYS;
77  }
78 
79  public function getDefaultScheduleValue(): ?int
80  {
81  return 1;
82  }
83 
84  public function run(): ilCronJobResult
85  {
86  $result = new ilCronJobResult();
87  $result->setStatus(ilCronJobResult::STATUS_NO_ACTION);
88 
89  $now = new DateTimeImmutable();
90 
91  foreach ($this->assignment_repo->getPassedDeadline($now) as $assignment) {
92  $assignment = $assignment->markProgressesFailedForExpiredDeadline(
93  $this->settings_repo,
94  $this->acting_user_id
95  );
96  $this->assignment_repo->store($assignment);
97  }
98 
99  $result->setStatus(ilCronJobResult::STATUS_OK);
100  return $result;
101  }
102 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilPRGAssignmentDBRepository $assignment_repo
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
final const STATUS_NO_ACTION
ilStudyProgrammeSettingsDBRepository $settings_repo
This will set progresses to FAILED, if they are past the deadline (and not successful, yet)
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...