ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPrgUserRiskyToFailCronJob Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilPrgUserRiskyToFailCronJob:
+ Collaboration diagram for ilPrgUserRiskyToFailCronJob:

Public Member Functions

 __construct ()
 
 getTitle ()
 
 getDescription ()
 
 getId ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?CronJobScheduleType $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?CronJobScheduleType $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Protected Member Functions

 getNow ()
 
 log (string $msg)
 

Protected Attributes

ilComponentLogger $log
 
ilLanguage $lng
 
ilPRGAssignmentDBRepository $assignment_repo
 
ilPrgCronJobAdapter $adapter
 
- Protected Attributes inherited from ilCronJob
CronJobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

const ID = 'prg_user_risky_to_fail'
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 23 of file class.ilPrgUserRiskyToFailCronJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilPrgUserRiskyToFailCronJob::__construct ( )

Definition at line 32 of file class.ilPrgUserRiskyToFailCronJob.php.

References $DIC, $dic, ilStudyProgrammeDIC\dic(), ILIAS\Repository\lng(), and log().

33  {
34  global $DIC;
35  $this->log = $DIC['ilLog'];
36  $this->lng = $DIC['lng'];
37  $this->lng->loadLanguageModule('prg');
38 
40  $this->assignment_repo = $dic['repo.assignment'];
41  $this->adapter = $dic['cron.riskyToFail'];
42  }
global $DIC
Definition: feed.php:28
$dic
Definition: result.php:32
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilPrgUserRiskyToFailCronJob::getDefaultScheduleType ( )

Definition at line 69 of file class.ilPrgUserRiskyToFailCronJob.php.

70  {
71  return CronJobScheduleType::SCHEDULE_TYPE_IN_DAYS;
72  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilPrgUserRiskyToFailCronJob::getDefaultScheduleValue ( )

Definition at line 74 of file class.ilPrgUserRiskyToFailCronJob.php.

74  : ?int
75  {
76  return 1;
77  }

◆ getDescription()

ilPrgUserRiskyToFailCronJob::getDescription ( )

Definition at line 49 of file class.ilPrgUserRiskyToFailCronJob.php.

References ILIAS\Repository\lng().

49  : string
50  {
51  return $this->lng->txt('prg_user_risky_to_fail_desc');
52  }
+ Here is the call graph for this function:

◆ getId()

ilPrgUserRiskyToFailCronJob::getId ( )

Definition at line 54 of file class.ilPrgUserRiskyToFailCronJob.php.

54  : string
55  {
56  return self::ID;
57  }

◆ getNow()

ilPrgUserRiskyToFailCronJob::getNow ( )
protected

Definition at line 123 of file class.ilPrgUserRiskyToFailCronJob.php.

Referenced by run().

123  : \DateTimeImmutable
124  {
125  return new DateTimeImmutable();
126  }
+ Here is the caller graph for this function:

◆ getTitle()

ilPrgUserRiskyToFailCronJob::getTitle ( )

Definition at line 44 of file class.ilPrgUserRiskyToFailCronJob.php.

References ILIAS\Repository\lng().

44  : string
45  {
46  return $this->lng->txt('prg_user_risky_to_fail_title');
47  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilPrgUserRiskyToFailCronJob::hasAutoActivation ( )

Definition at line 59 of file class.ilPrgUserRiskyToFailCronJob.php.

59  : bool
60  {
61  return true;
62  }

◆ hasFlexibleSchedule()

ilPrgUserRiskyToFailCronJob::hasFlexibleSchedule ( )

Definition at line 64 of file class.ilPrgUserRiskyToFailCronJob.php.

64  : bool
65  {
66  return true;
67  }

◆ log()

ilPrgUserRiskyToFailCronJob::log ( string  $msg)
protected

Definition at line 128 of file class.ilPrgUserRiskyToFailCronJob.php.

Referenced by __construct(), and run().

128  : void
129  {
130  $this->log->write($msg);
131  }
+ Here is the caller graph for this function:

◆ run()

ilPrgUserRiskyToFailCronJob::run ( )

Definition at line 79 of file class.ilPrgUserRiskyToFailCronJob.php.

References getNow(), log(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

Referenced by ilStudyProgrammeCronRiskyToFailTest\testRiskyToFailEvents().

80  {
81  $result = new ilCronJobResult();
82  $result->setStatus(ilCronJobResult::STATUS_NO_ACTION);
83 
84  $programmes_to_send = $this->adapter->getRelevantProgrammeIds();
85  if (count($programmes_to_send) == 0) {
86  return $result;
87  }
88 
89  $today = $this->getNow();
90  $programmes_and_due = [];
91  foreach ($programmes_to_send as $programme_obj_id => $days_offset_mail) {
92  $interval = new DateInterval('P' . $days_offset_mail . 'D');
93  $due = $today->add($interval);
94  $programmes_and_due[$programme_obj_id] = $due;
95  }
96 
97 
98  //root-assignments for any node that has deadline = $due and was not sent before;
99  $assignments = $this->assignment_repo->getRiskyToFail($programmes_and_due, true);
100 
101  if (count($assignments) == 0) {
102  return $result;
103  }
104 
105  foreach ($assignments as $ass) {
106  $pgs = $ass->getProgressTree();
107  $this->log(
108  sprintf(
109  'PRG, RiskyToFail: user %s at progress %s (prg obj_id %s)',
110  $ass->getUserId(),
111  $ass->getId(),
112  $pgs->getNodeId()
113  )
114  );
115 
116  $this->adapter->actOnSingleAssignment($ass);
117  $this->assignment_repo->storeRiskyToFailSentFor($ass);
118  }
119  $result->setStatus(ilCronJobResult::STATUS_OK);
120  return $result;
121  }
final const STATUS_NO_ACTION
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $adapter

ilPrgCronJobAdapter ilPrgUserRiskyToFailCronJob::$adapter
protected

◆ $assignment_repo

ilPRGAssignmentDBRepository ilPrgUserRiskyToFailCronJob::$assignment_repo
protected

Definition at line 29 of file class.ilPrgUserRiskyToFailCronJob.php.

◆ $lng

ilLanguage ilPrgUserRiskyToFailCronJob::$lng
protected

Definition at line 28 of file class.ilPrgUserRiskyToFailCronJob.php.

◆ $log

ilComponentLogger ilPrgUserRiskyToFailCronJob::$log
protected

Definition at line 27 of file class.ilPrgUserRiskyToFailCronJob.php.

◆ ID

const ilPrgUserRiskyToFailCronJob::ID = 'prg_user_risky_to_fail'
private

Definition at line 25 of file class.ilPrgUserRiskyToFailCronJob.php.


The documentation for this class was generated from the following file: