ILIAS  release_7 Revision v7.30-3-g800a261c036
ilPrgRestartAssignmentsCronJob Class Reference

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

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

Public Member Functions

 __construct ()
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $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...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Data Fields

const ID = 'prg_restart_assignments_temporal_progress'
 
const ACTING_USR_ID = -1
 
- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Protected Member Functions

 getNow ()
 
 getSettingsRepository ()
 
 getProgressRepository ()
 
 getAssignmentRepository ()
 
 getEvents ()
 
 log (string $msg)
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Protected Attributes

 $user_assignments_db
 
 $log
 
 $lng
 

Detailed Description

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

This will result in a new/additional assignment

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

Constructor & Destructor Documentation

◆ __construct()

ilPrgRestartAssignmentsCronJob::__construct ( )

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

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

33  {
34  global $DIC;
35  $this->log = $DIC['ilLog'];
36  $this->lng = $DIC['lng'];
37  $this->lng->loadLanguageModule('prg');
38 
39  $this->dic = ilStudyProgrammeDIC::dic();
40  }
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ getAssignmentRepository()

ilPrgRestartAssignmentsCronJob::getAssignmentRepository ( )
protected

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

Referenced by run().

199  {
200  return $this->dic['ilStudyProgrammeUserAssignmentDB'];
201  }
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleType ( )

Get schedule type.

Returns
int

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

98  {
99  return self::SCHEDULE_TYPE_IN_DAYS;
100  }

◆ getDefaultScheduleValue()

ilPrgRestartAssignmentsCronJob::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

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

108  {
109  return 1;
110  }

◆ getDescription()

ilPrgRestartAssignmentsCronJob::getDescription ( )

Get description.

Returns
string

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

59  {
60  return $this->lng->txt('prg_restart_assignments_temporal_progress_desc');
61  }

◆ getEvents()

ilPrgRestartAssignmentsCronJob::getEvents ( )
protected

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

Referenced by run().

204  {
205  return $this->dic['ilStudyProgrammeEvents'];
206  }
+ Here is the caller graph for this function:

◆ getId()

ilPrgRestartAssignmentsCronJob::getId ( )

Get id.

Returns
string

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

68  {
69  return self::ID;
70  }

◆ getNow()

ilPrgRestartAssignmentsCronJob::getNow ( )
protected

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

Referenced by run().

183  : \DateTimeImmutable
184  {
185  return new DateTimeImmutable();
186  }
+ Here is the caller graph for this function:

◆ getProgressRepository()

ilPrgRestartAssignmentsCronJob::getProgressRepository ( )
protected

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

Referenced by run().

194  {
195  return $this->dic['ilStudyProgrammeUserProgressDB'];
196  }
+ Here is the caller graph for this function:

◆ getSettingsRepository()

ilPrgRestartAssignmentsCronJob::getSettingsRepository ( )
protected

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

Referenced by run().

189  {
190  return $this->dic['model.Settings.ilStudyProgrammeSettingsRepository'];
191  }
+ Here is the caller graph for this function:

◆ getTitle()

ilPrgRestartAssignmentsCronJob::getTitle ( )

Get title.

Returns
string

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

49  {
50  return $this->lng->txt('prg_restart_assignments_temporal_progress_title');
51  }

◆ hasAutoActivation()

ilPrgRestartAssignmentsCronJob::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

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

78  {
79  return true;
80  }

◆ hasFlexibleSchedule()

ilPrgRestartAssignmentsCronJob::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

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

88  {
89  return true;
90  }

◆ log()

ilPrgRestartAssignmentsCronJob::log ( string  $msg)
protected

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

Referenced by __construct(), and run().

208  : void
209  {
210  $this->log->write($msg);
211  }
+ Here is the caller graph for this function:

◆ run()

ilPrgRestartAssignmentsCronJob::run ( )
Returns
ilCronJobResult

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

References $result, getAssignmentRepository(), getEvents(), ilObjStudyProgramme\getInstanceByObjId(), getNow(), getProgressRepository(), getSettingsRepository(), log(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

116  {
117  $result = new ilCronJobResult();
119 
120  $programmes_to_reassign = $this->getSettingsRepository()
121  ->getProgrammeIdsWithReassignmentForExpiringValidity();
122 
123  if (count($programmes_to_reassign) == 0) {
124  return $result;
125  }
126 
127  $today = $this->getNow();
128  $programmes_and_due = [];
129 
130  foreach ($programmes_to_reassign as $programme_obj_id => $days_offset) {
131  $interval = new DateInterval('P' . $days_offset . 'D');
132  $due = $today->add($interval);
133  $programmes_and_due[$programme_obj_id] = $due;
134  }
135 
136  //TODO: expire for assignment, not progress!!!
137  $progresses = $this->getProgressRepository()
138  ->getAboutToExpire($programmes_and_due, false);
139 
140  if (count($progresses) == 0) {
141  return $result;
142  }
143 
144  $events = $this->getEvents();
145  $assignment_repo = $this->getAssignmentRepository();
146  foreach ($progresses as $progress) {
147  $ass = $assignment_repo->get($progress->getAssignmentId());
148  if ($ass->getRestartedAssignmentId() < 0) {
149  if ($ass->getRootId() != $progress->getNodeId()) {
150  $this->log(
151  sprintf(
152  'PRG, RestartAssignments: progress %s is not root of assignment %s. skipping.',
153  $progress->getId(),
154  $ass->getId()
155  )
156  );
157  continue;
158  }
159 
160  $this->log(
161  sprintf(
162  'PRG, RestartAssignments: user %s\'s assignment %s is being restarted (Programme %s)',
163  $progress->getUserId(),
164  $ass->getId(),
165  $progress->getNodeId()
166  )
167  );
168 
169  $prg = ilObjStudyProgramme::getInstanceByObjId($ass->getRootId());
170  $restarted = $prg->assignUser($ass->getUserId(), self::ACTING_USR_ID);
171  $ass = $ass->withRestarted($restarted->getId(), $today);
172 
173  $assignment_repo->update($ass);
174 
175  $events->userReAssigned($restarted);
177  }
178  }
179 
180  return $result;
181  }
$result
Cron job result data container.
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilPrgRestartAssignmentsCronJob::$lng
protected

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

◆ $log

ilPrgRestartAssignmentsCronJob::$log
protected

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

◆ $user_assignments_db

ilPrgRestartAssignmentsCronJob::$user_assignments_db
protected

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

◆ ACTING_USR_ID

const ilPrgRestartAssignmentsCronJob::ACTING_USR_ID = -1

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

◆ ID

const ilPrgRestartAssignmentsCronJob::ID = 'prg_restart_assignments_temporal_progress'

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


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