ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPrgUserRiskyToFailCronJob.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2019 Denis Klöpfer <denis.kloepfer@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 /* Copyright (c) 2019 Stefan Hecken <stefan.hecken@concepts-and-training.de> Extended GPL, see docs/LICENSE */
5 
6 declare(strict_types=1);
7 
8 
10 {
11  const ID = 'prg_user_risky_to_fail';
12 
16  protected $user_progress_db;
17 
21  protected $log;
22 
26  protected $lng;
27 
28  public function __construct()
29  {
30  global $DIC;
31 
32  $this->user_progress_db = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserProgressDB'];
33  $this->log = $DIC['ilLog'];
34  $this->lng = $DIC['lng'];
35  $this->lng->loadLanguageModule('prg');
36  }
37 
43  public function getTitle()
44  {
45  return $this->lng->txt('prg_user_risky_to_fail_title');
46  }
47 
53  public function getDescription()
54  {
55  return $this->lng->txt('prg_user_risky_to_fail_desc');
56  }
57 
63  public function getId()
64  {
65  return self::ID;
66  }
67 
73  public function hasAutoActivation()
74  {
75  return true;
76  }
77 
83  public function hasFlexibleSchedule()
84  {
85  return true;
86  }
87 
93  public function getDefaultScheduleType()
94  {
95  return self::SCHEDULE_TYPE_IN_DAYS;
96  }
97 
103  public function getDefaultScheduleValue()
104  {
105  return 1;
106  }
107 
114  public function run()
115  {
116  $result = new ilCronJobResult();
117  foreach ($this->user_progress_db->getRiskyToFailInstances() as $progress) {
118  try {
119  $auto_mail_settings = $progress->getStudyProgramme()->getAutoMailSettings();
120  $remind_days = $auto_mail_settings->getProcessingEndsNotSuccessfulDays();
121 
122  if (is_null($remind_days)) {
123  continue;
124  }
125 
126  $check_date = new DateTime();
127  $check_date->sub(new DateInterval('P' . $remind_days . 'D'));
128  if ($progress->getDeadline()->format('Y-m-d') < $check_date->format('Y-m-d')) {
129  continue;
130  }
131 
132  $progress->informUserForRiskToFail();
133  } catch (ilException $e) {
134  $this->log->write('an error occured: ' . $e->getMessage());
135  }
136  }
138  return $result;
139  }
140 }
hasFlexibleSchedule()
Can the schedule be configured?
$result
Cron job application base class.
hasAutoActivation()
Is to be activated on "installation".
$DIC
Definition: xapitoken.php:46
Cron job result data container.