ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilPrgRestartAssignmentsCronJob Class Reference

Re-assign users (according to restart-date). More...

+ Inheritance diagram for ilPrgRestartAssignmentsCronJob:
+ Collaboration diagram for ilPrgRestartAssignmentsCronJob:

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

 getStudyProgramme (int $prg_obj_id)
 
 getNow ()
 
 log (string $msg)
 

Protected Attributes

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

Private Attributes

const ID = 'prg_restart_assignments_temporal_progress'
 
const ACTING_USR_ID = ilPRGAssignment::AUTO_ASSIGNED_BY_RESTART
 

Detailed Description

Re-assign users (according to restart-date).

This will result in a new/additional assignment

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

Constructor & Destructor Documentation

◆ __construct()

ilPrgRestartAssignmentsCronJob::__construct ( )

Definition at line 40 of file class.ilPrgRestartAssignmentsCronJob.php.

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

41  {
42  global $DIC;
43  $this->log = $DIC['ilLog'];
44  $this->lng = $DIC['lng'];
45  $this->lng->loadLanguageModule('prg');
46 
48  $this->assignment_repo = $dic['repo.assignment'];
49  $this->adapter = $dic['cron.restart'];
50  }
global $DIC
Definition: shib_login.php:25
$dic
Definition: ltiresult.php:33
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleType ( )

Definition at line 77 of file class.ilPrgRestartAssignmentsCronJob.php.

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

◆ getDefaultScheduleValue()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleValue ( )

Definition at line 82 of file class.ilPrgRestartAssignmentsCronJob.php.

82  : ?int
83  {
84  return 1;
85  }

◆ getDescription()

ilPrgRestartAssignmentsCronJob::getDescription ( )

Definition at line 57 of file class.ilPrgRestartAssignmentsCronJob.php.

References ILIAS\Repository\lng().

57  : string
58  {
59  return $this->lng->txt('prg_restart_assignments_temporal_progress_desc');
60  }
+ Here is the call graph for this function:

◆ getId()

ilPrgRestartAssignmentsCronJob::getId ( )

Definition at line 62 of file class.ilPrgRestartAssignmentsCronJob.php.

62  : string
63  {
64  return self::ID;
65  }

◆ getNow()

ilPrgRestartAssignmentsCronJob::getNow ( )
protected

Definition at line 154 of file class.ilPrgRestartAssignmentsCronJob.php.

Referenced by run().

155  {
156  return new DateTimeImmutable();
157  }
+ Here is the caller graph for this function:

◆ getStudyProgramme()

ilPrgRestartAssignmentsCronJob::getStudyProgramme ( int  $prg_obj_id)
protected

Definition at line 146 of file class.ilPrgRestartAssignmentsCronJob.php.

References ilObjStudyProgramme\getInstanceByObjId().

Referenced by run().

147  {
148  if (!array_key_exists($prg_obj_id, $this->prgs)) {
149  $this->prgs[$prg_obj_id] = ilObjStudyProgramme::getInstanceByObjId($prg_obj_id);
150  }
151  return $this->prgs[$prg_obj_id];
152  }
static getInstanceByObjId(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilPrgRestartAssignmentsCronJob::getTitle ( )

Definition at line 52 of file class.ilPrgRestartAssignmentsCronJob.php.

References ILIAS\Repository\lng().

52  : string
53  {
54  return $this->lng->txt('prg_restart_assignments_temporal_progress_title');
55  }
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilPrgRestartAssignmentsCronJob::hasAutoActivation ( )

Definition at line 67 of file class.ilPrgRestartAssignmentsCronJob.php.

67  : bool
68  {
69  return true;
70  }

◆ hasFlexibleSchedule()

ilPrgRestartAssignmentsCronJob::hasFlexibleSchedule ( )

Definition at line 72 of file class.ilPrgRestartAssignmentsCronJob.php.

72  : bool
73  {
74  return true;
75  }

◆ log()

ilPrgRestartAssignmentsCronJob::log ( string  $msg)
protected

Definition at line 159 of file class.ilPrgRestartAssignmentsCronJob.php.

Referenced by __construct(), and run().

159  : void
160  {
161  $this->log->write($msg);
162  }
+ Here is the caller graph for this function:

◆ run()

ilPrgRestartAssignmentsCronJob::run ( )

Definition at line 87 of file class.ilPrgRestartAssignmentsCronJob.php.

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

Referenced by ilPrgRestartAssignmentsCronJobTest\testRestartAssignmentsEvents().

88  {
89  $result = new ilCronJobResult();
90  $result->setStatus(ilCronJobResult::STATUS_NO_ACTION);
91 
92  $programmes_to_reassign = $this->adapter->getRelevantProgrammeIds();
93  if (count($programmes_to_reassign) === 0) {
94  return $result;
95  }
96 
97  $today = $this->getNow();
98  $programmes_and_due = [];
99 
100  foreach ($programmes_to_reassign as $programme_obj_id => $days_offset) {
101  $interval = new DateInterval('P' . $days_offset . 'D');
102  $due = $today->add($interval);
103  $programmes_and_due[$programme_obj_id] = $due;
104  }
105 
106  $assignments = $this->assignment_repo->getAboutToExpire($programmes_and_due, false);
107 
108  if (count($assignments) === 0) {
109  return $result;
110  }
111 
112  foreach ($assignments as $ass) {
113  if ($ass->getRestartedAssignmentId() < 0) {
114  $prg = $this->getStudyProgramme($ass->getRootId());
115 
116  $restart_settings = $prg->getSettings()->getValidityOfQualificationSettings();
117  if ($restart_settings->getRestartRecheck()
118  && !$ass->isManuallyAssigned()
119  && !$prg->getApplicableMembershipSourceForUser($ass->getUserId(), null)
120  ) {
121  continue;
122  }
123 
124  $this->log(
125  sprintf(
126  'PRG, RestartAssignments: user %s\'s assignment %s is being restarted (Programme %s)',
127  $ass->getUserId(),
128  $ass->getId(),
129  $ass->getRootId()
130  )
131  );
132 
133  $restarted = $prg->assignUser($ass->getUserId(), self::ACTING_USR_ID, false);
134  $ass = $ass->withRestarted($restarted->getId(), $today);
135  $this->assignment_repo->store($ass);
136 
137  $this->adapter->actOnSingleAssignment($restarted);
138 
139  $result->setStatus(ilCronJobResult::STATUS_OK);
140  }
141  }
142 
143  return $result;
144  }
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 ilPrgRestartAssignmentsCronJob::$adapter
protected

◆ $assignment_repo

ilPRGAssignmentDBRepository ilPrgRestartAssignmentsCronJob::$assignment_repo
protected

Definition at line 35 of file class.ilPrgRestartAssignmentsCronJob.php.

◆ $lng

ilLanguage ilPrgRestartAssignmentsCronJob::$lng
protected

Definition at line 34 of file class.ilPrgRestartAssignmentsCronJob.php.

◆ $log

ilComponentLogger ilPrgRestartAssignmentsCronJob::$log
protected

Definition at line 33 of file class.ilPrgRestartAssignmentsCronJob.php.

◆ $prgs

array ilPrgRestartAssignmentsCronJob::$prgs = []
protected

Definition at line 38 of file class.ilPrgRestartAssignmentsCronJob.php.

◆ ACTING_USR_ID

const ilPrgRestartAssignmentsCronJob::ACTING_USR_ID = ilPRGAssignment::AUTO_ASSIGNED_BY_RESTART
private

Definition at line 31 of file class.ilPrgRestartAssignmentsCronJob.php.

◆ ID

const ilPrgRestartAssignmentsCronJob::ID = 'prg_restart_assignments_temporal_progress'
private

Definition at line 30 of file class.ilPrgRestartAssignmentsCronJob.php.


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