19 declare(strict_types=1);
31 private const ID =
'prg_restart_assignments_temporal_progress';
44 $this->
log = $DIC[
'ilLog'];
45 $this->
lng = $DIC[
'lng'];
46 $this->
lng->loadLanguageModule(
'prg');
49 $this->assignment_repo =
$dic[
'repo.assignment'];
50 $this->adapter =
$dic[
'cron.restart'];
55 return $this->
lng->txt(
'prg_restart_assignments_temporal_progress_title');
60 return $this->
lng->txt(
'prg_restart_assignments_temporal_progress_desc');
80 return JobScheduleType::IN_DAYS;
91 $result->setStatus(JobResult::STATUS_NO_ACTION);
93 $programmes_to_reassign = $this->adapter->getRelevantProgrammeIds();
94 if (count($programmes_to_reassign) === 0) {
99 $programmes_and_due = [];
101 foreach ($programmes_to_reassign as $programme_obj_id => $days_offset) {
103 $due = $today->add($interval);
104 $programmes_and_due[$programme_obj_id] = $due;
107 $assignments = $this->assignment_repo->getAboutToExpire($programmes_and_due,
false);
109 if (count($assignments) === 0) {
113 foreach ($assignments as $ass) {
114 if ($ass->getRestartedAssignmentId() < 0) {
117 $restart_settings = $prg->getSettings()->getValidityOfQualificationSettings();
118 if ($restart_settings->getRestartRecheck()
119 && !$ass->isManuallyAssigned()
120 && !$prg->getApplicableMembershipSourceForUser($ass->getUserId(),
null)
127 'PRG, RestartAssignments: user %s\'s assignment %s is being restarted (Programme %s)',
134 $restarted = $prg->assignUser($ass->getUserId(), self::ACTING_USR_ID,
false);
135 $ass = $ass->withRestarted($restarted->getId(), $today);
136 $this->assignment_repo->store($ass);
138 $this->adapter->actOnSingleAssignment($restarted);
140 $result->setStatus(JobResult::STATUS_OK);
149 if (!array_key_exists($prg_obj_id, $this->prgs)) {
152 return $this->prgs[$prg_obj_id];
160 protected function log(
string $msg): void
162 $this->
log->write($msg);
ilPRGAssignmentDBRepository $assignment_repo
ilPrgCronJobAdapter $adapter
Component logger with individual log levels by component id.
getStudyProgramme(int $prg_obj_id)
getDefaultScheduleValue()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const AUTO_ASSIGNED_BY_RESTART
Re-assign users (according to restart-date).
static getInstanceByObjId(int $obj_id)
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...