ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPRGAssignmentActions.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
28 {
29  abstract public function getEvents(): StudyProgrammeEvents;
30 
31  protected function getProgressIdString(int $node_id): string
32  {
33  return sprintf(
34  '%s, progress-id (%s/%s)',
35  $this->user_info->getFullname(),
36  $this->getId(),
37  (string) $node_id
38  );
39  }
40 
41  protected function getNow(): DateTimeImmutable
42  {
43  return new DateTimeImmutable();
44  }
45 
46  protected function getRefIdFor(int $obj_id): int
47  {
48  $refs = ilObject::_getAllReferences($obj_id);
49  if (count($refs) < 1) {
50  throw new ilException("Could not find ref_id for programme with obj_id $obj_id");
51  }
52  return (int) array_shift($refs);
53  }
54 
55  protected function getCourseReferencesInNode(int $node_obj_id): array
56  {
57  global $DIC; //TODO!!
58  $tree = $DIC['tree']; //ilTree
59  $node_ref = $this->getRefIdFor($node_obj_id);
60  $children = $tree->getChildsByType($node_ref, "crsr");
61  $children = array_filter(
62  $children,
63  fn ($c) => ilObject::_exists((int)$c['ref_id'], true)
64  && is_null(ilObject::_lookupDeletedDate((int)$c['ref_id']))
65  && ! is_null(ilContainerReference::_lookupTargetRefId((int) $c['obj_id']))
67  (int) ilContainerReference::_lookupTargetRefId((int) $c['obj_id'])
68  ))
69  );
70  return $children;
71  }
72 
73  protected function hasCompletedCourseChild(ilPRGProgress $pgs): ?int
74  {
75  foreach ($this->getCourseReferencesInNode($pgs->getNodeId()) as $child) {
76  $crs_id = ilContainerReference::_lookupTargetId((int)$child["obj_id"]);
77  if (ilLPStatus::_hasUserCompleted($crs_id, $this->getUserId())) {
78  return (int)$child["obj_id"];
79  }
80  }
81  return null;
82  }
83 
84  protected function recalculateProgressStatus(
86  ilPRGProgress $progress
87  ): ilPRGProgress {
88  if (!$progress->isRelevant()) {
89  return $progress;
90  }
91  $node_settings = $settings_repo->get($progress->getNodeId());
92  $completion_mode = $node_settings->getLPMode();
93 
94  switch ($completion_mode) {
97  return $progress;
98  break;
100  $completing_crs_id = ilPRGProgress::COMPLETED_BY_SUBNODES;
101  $achieved_points = $progress->getAchievedPointsOfChildren();
102  break;
103  }
104 
105  $progress = $progress->withCurrentAmountOfPoints($achieved_points);
106  $this->notifyScoreChange($progress);
107 
108  $required_points = $progress->getAmountOfPoints();
109  $successful = ($achieved_points >= $required_points);
110 
111  if ($successful && !$progress->isSuccessful()) {
112  $progress = $progress
114  ->withCompletion($completing_crs_id, $this->getNow());
115 
116  $this->notifyProgressSuccess($progress);
117  }
118 
119  if (!$successful && $progress->isSuccessful()
120  && $progress->getStatus() !== ilPRGProgress::STATUS_ACCREDITED
121  ) {
122  $progress = $progress
124  ->withCompletion(null, null)
125  ->withValidityOfQualification(null);
126 
127  $this->notifyValidityChange($progress);
128  $this->notifyProgressRevertSuccess($progress);
129  }
130 
131  return $progress;
132  }
133 
134  protected function updateParentProgresses(
135  ilStudyProgrammeSettingsRepository $settings_repo,
136  Zipper $zipper
137  ): Zipper {
138  while (!$zipper->isTop()) {
139  $zipper = $zipper->toParent()
140  ->modifyFocus(
141  function ($pgs) use ($settings_repo) {
142  $today = $this->getNow();
144  $deadline = $pgs->getDeadline();
145  if (!is_null($deadline)
146  && $deadline->format($format) <= $today->format($format)
147  ) {
148  return $pgs;
149  }
150  return $this->recalculateProgressStatus($settings_repo, $pgs);
151  }
152  );
153  }
154  return $zipper;
155  }
156 
157 
160  ilPRGProgress $progress
161  ): ilPRGProgress {
162  $cdate = $progress->getCompletionDate();
163  if (!$cdate
164  || $progress->isSuccessful() === false
165  ) {
166  return $progress;
167  }
168  $period = $settings->getQualificationPeriod();
169  $date = $settings->getQualificationDate();
170 
171  if ($period) {
172  $date = $cdate->add(new DateInterval('P' . $period . 'D'));
173  }
174 
175  $validity = is_null($date) || $date->format(ilPRGProgress::DATE_FORMAT) >= $this->getNow()->format(ilPRGProgress::DATE_FORMAT);
176  $this->notifyValidityChange($progress);
177  return $progress->withValidityOfQualification($date)
178  ->withInvalidated(!$validity);
179  }
180 
183  ilPRGProgress $progress
184  ): ilPRGProgress {
185  $period = $settings->getDeadlinePeriod();
186  $date = $settings->getDeadlineDate();
187 
188  if ($period) {
189  $date = $progress->getAssignmentDate();
190  $date = $date->add(new DateInterval('P' . $period . 'D'));
191  }
192  $this->notifyDeadlineChange($progress);
193  return $progress->withDeadline($date);
194  }
195 
197  ilStudyProgrammeSettingsRepository $settings_repo,
198  ilPRGProgress $pgs
199  ): ilPRGProgress {
200  $programme_status = $settings_repo->get($pgs->getNodeId())->getAssessmentSettings()->getStatus();
201  $active = $programme_status === ilStudyProgrammeSettings::STATUS_ACTIVE;
202 
203  if ($active && !$pgs->isRelevant()) {
205  }
206  if (!$active && $pgs->isInProgress()) {
208  }
209  return $pgs;
210  }
211 
212 
213  protected function applyProgressDeadline(
214  ilStudyProgrammeSettingsRepository $settings_repo,
215  ilPRGProgress $progress,
216  int $acting_usr_id = null,
217  bool $recalculate = true
218  ): ilPRGProgress {
219  $today = $this->getNow();
221  $deadline = $progress->getDeadline();
222 
223  if (is_null($acting_usr_id)) {
224  throw new Exception('no acting user.');
225  $acting_usr_id = $this->getLoggedInUserId(); //TODO !
226  }
227 
228  switch ($progress->getStatus()) {
229 
231  if (!is_null($deadline)
232  && $deadline->format($format) < $today->format($format)
233  ) {
234  $progress = $progress->markFailed($this->getNow(), $acting_usr_id);
235  $this->notifyProgressRevertSuccess($progress);
236  } else {
237  $node_settings = $settings_repo->get($progress->getNodeId());
238  $completion_mode = $node_settings->getLPMode();
239  if ($recalculate || $completion_mode !== ilStudyProgrammeSettings::MODE_LP_COMPLETED) {
240  $progress = $this->recalculateProgressStatus($settings_repo, $progress);
241  }
242  }
243  break;
244 
246  if (is_null($deadline)
247  || $deadline->format($format) >= $today->format($format)
248  ) {
249  $progress = $progress->markNotFailed($this->getNow(), $acting_usr_id);
250  $this->notifyProgressRevertSuccess($progress);
251  }
252  break;
253  }
254 
255  return $progress;
256  }
257 
258 
259  protected function resetProgressToSettings(
260  ilStudyProgrammeSettingsRepository $settings_repo,
261  ilPRGProgress $pgs,
262  int $acting_usr_id
263  ): ilPRGProgress {
264  $settings = $settings_repo->get($pgs->getNodeId());
265  if ($pgs->isRelevant()) {
266  $pgs = $this->updateProgressValidityFromSettings($settings->getValidityOfQualificationSettings(), $pgs);
267  $pgs = $this->updateProgressDeadlineFromSettings($settings->getDeadlineSettings(), $pgs);
268  } else {
269  $pgs = $pgs
271  ->withDeadline(null);
272  $this->notifyValidityChange($pgs);
273  }
274 
275  $pgs = $pgs
276  ->withAmountOfPoints($settings->getAssessmentSettings()->getPoints())
277  ->withLastChange($acting_usr_id, $this->getNow())
278  ->withIndividualModifications(false);
279 
280  if ($pgs->isSuccessful()) {
281  $pgs = $pgs->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
282  $this->notifyScoreChange($pgs);
283  }
284 
285  return $pgs;
286  }
287 
288 
289 
290  // ------------------------- tree-manipulation -----------------------------
291 
292  protected function getZipper($node_id)
293  {
294  $progress_path = $this->getProgressForNode($node_id)->getPath();
295  $zipper = new Zipper($this->getProgressTree());
296  return $zipper = $zipper->toPath($progress_path);
297  }
298 
299  protected function notifyProgressSuccess(ilPRGProgress $pgs): void
300  {
301  $this->getEvents()->userSuccessful($this, $pgs->getNodeId());
302  }
303  protected function notifyValidityChange(ilPRGProgress $pgs): void
304  {
305  $this->getEvents()->validityChange($this, $pgs->getNodeId());
306  }
307  protected function notifyDeadlineChange(ilPRGProgress $pgs): void
308  {
309  $this->getEvents()->deadlineChange($this, $pgs->getNodeId());
310  }
311  protected function notifyScoreChange(ilPRGProgress $pgs): void
312  {
313  $this->getEvents()->scoreChange($this, $pgs->getNodeId());
314  }
315  protected function notifyProgressRevertSuccess(ilPRGProgress $pgs): void
316  {
317  $this->getEvents()->userRevertSuccessful($this, $pgs->getNodeId());
318  }
319 
320  public function initAssignmentDates(): self
321  {
322  $zipper = $this->getZipper($this->getRootId());
323  $zipper = $zipper->modifyAll(
324  fn ($pgs) => $pgs->withAssignmentDate($this->getNow())
325  );
326  return $this->withProgressTree($zipper->getRoot());
327  }
328 
329  public function resetProgresses(
330  ilStudyProgrammeSettingsRepository $settings_repo,
331  int $acting_usr_id
332  ): self {
333  $zipper = $this->getZipper($this->getRootId());
334  $zipper = $zipper->modifyAll(
335  function ($pgs) use ($acting_usr_id, $settings_repo): ilPRGProgress {
336  $pgs = $this->updateProgressRelevanceFromSettings($settings_repo, $pgs);
337  $pgs = $this->resetProgressToSettings($settings_repo, $pgs, $acting_usr_id);
338  return $pgs;
339  }
340  );
341  return $this->withProgressTree($zipper->getRoot());
342  }
343 
344  public function markRelevant(
345  ilStudyProgrammeSettingsRepository $settings_repo,
346  int $node_id,
347  int $acting_usr_id,
348  ilPRGMessageCollection $err_collection
349  ): self {
350  $zipper = $this->getZipper($node_id)->modifyFocus(
351  function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo): ilPRGProgress {
352  if ($pgs->isRelevant()) {
353  $err_collection->add(false, 'will_not_modify_relevant_progress', $this->getProgressIdString($pgs->getNodeId()));
354  return $pgs;
355  }
356  $pgs = $pgs->markRelevant($this->getNow(), $acting_usr_id);
357  $err_collection->add(true, 'set_to_relevant', $this->getProgressIdString($pgs->getNodeId()));
358  $pgs = $this->recalculateProgressStatus($settings_repo, $pgs);
359  return $pgs;
360  }
361  );
362 
363  $zipper = $this->updateParentProgresses($settings_repo, $zipper);
364  return $this->withProgressTree($zipper->getRoot());
365  }
366 
367  public function markNotRelevant(
368  ilStudyProgrammeSettingsRepository $settings_repo,
369  int $node_id,
370  int $acting_usr_id,
371  ilPRGMessageCollection $err_collection
372  ): self {
373  $zipper = $this->getZipper($node_id);
374 
375  if ($zipper->isTop()) {
376  $err_collection->add(false, 'will_not_set_top_progress_to_irrelevant', $this->getProgressIdString($node_id));
377  return $this;
378  }
379 
380  $zipper = $zipper->modifyFocus(
381  function ($pgs) use ($err_collection, $acting_usr_id): ilPRGProgress {
382  if (!$pgs->isRelevant()) {
383  $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
384  return $pgs;
385  }
386  $pgs = $pgs->markNotRelevant($this->getNow(), $acting_usr_id);
387  $err_collection->add(true, 'set_to_irrelevant', $this->getProgressIdString($pgs->getNodeId()));
388  return $pgs;
389  }
390  );
391 
392  $zipper = $this->updateParentProgresses($settings_repo, $zipper);
393  return $this->withProgressTree($zipper->getRoot());
394  }
395 
396  public function markAccredited(
397  ilStudyProgrammeSettingsRepository $settings_repo,
398  ilStudyProgrammeEvents $events, //TODO: remove.
399  int $node_id,
400  int $acting_usr_id,
401  ilPRGMessageCollection $err_collection
402  ): self {
403  $zipper = $this->getZipper($node_id);
404 
405  $zipper = $zipper->modifyFocus(
406  function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo): ilPRGProgress {
407  if (!$pgs->isRelevant()) {
408  $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
409  return $pgs;
410  }
411 
412  $new_status = ilPRGProgress::STATUS_ACCREDITED;
413  if ($pgs->getStatus() === $new_status) {
414  $err_collection->add(false, 'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
415  return $pgs;
416  }
417  if (!$pgs->isTransitionAllowedTo($new_status)) {
418  $err_collection->add(false, 'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
419  return $pgs;
420  }
421 
422  $pgs = $pgs
423  ->markAccredited($this->getNow(), $acting_usr_id)
424  ->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
425  $this->notifyScoreChange($pgs);
426 
427  if (!$pgs->getValidityOfQualification()) {
428  $settings = $settings_repo->get($pgs->getNodeId())->getValidityOfQualificationSettings();
429  $pgs = $this->updateProgressValidityFromSettings($settings, $pgs);
430  }
431 
432  $this->notifyProgressSuccess($pgs);
433  $err_collection->add(true, 'status_changed', $this->getProgressIdString($pgs->getNodeId()));
434  return $pgs;
435  }
436  );
437 
438  $zipper = $this->updateParentProgresses($settings_repo, $zipper);
439  return $this->withProgressTree($zipper->getRoot());
440  }
441 
442 
443  public function unmarkAccredited(
444  ilStudyProgrammeSettingsRepository $settings_repo,
445  int $node_id,
446  int $acting_usr_id,
447  ilPRGMessageCollection $err_collection
448  ): self {
449  $zipper = $this->getZipper($node_id);
450 
451  $zipper = $zipper->modifyFocus(
452  function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo): ilPRGProgress {
453  if (!$pgs->isRelevant()) {
454  $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
455  return $pgs;
456  }
457 
458  $new_status = ilPRGProgress::STATUS_IN_PROGRESS;
459  if ($pgs->getStatus() === $new_status) {
460  $err_collection->add(false, 'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
461  return $pgs;
462  }
463  if (!$pgs->isTransitionAllowedTo($new_status)
464  //special case: completion may not be revoked manually (but might be as a calculation-result of underlying progresses)
465  || $pgs->getStatus() === ilPRGProgress::STATUS_COMPLETED
466  ) {
467  $err_collection->add(false, 'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
468  return $pgs;
469  }
470 
471  $pgs = $pgs
472  ->unmarkAccredited($this->getNow(), $acting_usr_id)
473  ->withCurrentAmountOfPoints($pgs->getAchievedPointsOfChildren());
474  $this->notifyScoreChange($pgs);
475 
476  $old_status = $pgs->getStatus();
477  $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id);
478  if ($pgs->getStatus() !== $old_status) {
479  $err_collection->add(false, 'status_changed_due_to_deadline', $this->getProgressIdString($pgs->getNodeId()));
480  } else {
481  $err_collection->add(true, 'status_changed', $this->getProgressIdString($pgs->getNodeId()));
482  }
483  $this->notifyProgressRevertSuccess($pgs);
484  return $pgs;
485  }
486  );
487 
488  $zipper = $this->updateParentProgresses($settings_repo, $zipper);
489  return $this->withProgressTree($zipper->getRoot());
490  }
491 
492  public function updatePlanFromRepository(
493  ilStudyProgrammeSettingsRepository $settings_repo,
494  int $acting_usr_id,
495  ilPRGMessageCollection $err_collection
496  ): self {
497  $zipper = $this->getZipper($this->getRootId());
498  $leafs = [];
499  $zipper = $zipper->modifyAll(
500  function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, &$leafs): ilPRGProgress {
501  $pgs = $this->updateProgressRelevanceFromSettings($settings_repo, $pgs);
502  $pgs = $this->resetProgressToSettings($settings_repo, $pgs, $acting_usr_id);
503  $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id, false);
504  if (!$pgs->getSubnodes()) {
505  $leafs[] = $pgs->getPath();
506  }
507 
508  return $pgs;
509  }
510  );
511 
512  foreach ($leafs as $path) {
513  $zipper = $this->updateParentProgresses($settings_repo, $zipper->toPath($path));
514  }
515 
516  return $this->withProgressTree($zipper->getRoot());
517  }
518 
519 
520  public function succeed(
521  ilStudyProgrammeSettingsRepository $settings_repo,
522  int $node_id,
523  int $triggering_obj_id
524  ): self {
525  $zipper = $this->getZipper($node_id)->modifyFocus(
526  function ($pgs) use ($settings_repo, $triggering_obj_id): ilPRGProgress {
527  $deadline = $pgs->getDeadline();
529  $now = $this->getNow();
530  if ($pgs->isInProgress() &&
531  (is_null($deadline) || $deadline->format($format) >= $now->format($format))
532  ) {
533  $pgs = $pgs->succeed($now, $triggering_obj_id)
534  ->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
535  $this->notifyScoreChange($pgs);
536 
537  $settings = $settings_repo->get($pgs->getNodeId());
538  $pgs = $this->updateProgressValidityFromSettings($settings->getValidityOfQualificationSettings(), $pgs);
539  }
540 
541  $this->notifyProgressSuccess($pgs);
542  return $pgs;
543  }
544  );
545 
546  $zipper = $this->updateParentProgresses($settings_repo, $zipper);
547  return $this->withProgressTree($zipper->getRoot());
548  }
549 
550 
552  ilStudyProgrammeSettingsRepository $settings_repo,
553  int $acting_usr_id
554  ): self {
555  $zipper = $this->getZipper($this->getRootId());
556  $touched = [];
557 
558  $deadline = $this->getNow();
559  $zipper = $zipper->modifyAll(
560  function ($pgs) use ($acting_usr_id, $deadline, &$touched): ilPRGProgress {
561  if (is_null($pgs->getDeadline())
562  || !$pgs->isInProgress()
563  || $pgs->getDeadline()->format(ilPRGProgress::DATE_FORMAT) >= $deadline->format(ilPRGProgress::DATE_FORMAT)
564  ) {
565  return $pgs;
566  }
567 
568  $touched[] = $pgs->getPath();
569  $this->notifyProgressRevertSuccess($pgs);
570  return $pgs->markFailed($this->getNow(), $acting_usr_id);
571  }
572  );
573 
574  foreach ($touched as $path) {
575  $zipper = $this->updateParentProgresses($settings_repo, $zipper->toPath($path));
576  }
577 
578  return $this->withProgressTree($zipper->getRoot());
579  }
580 
581  public function changeProgressDeadline(
582  ilStudyProgrammeSettingsRepository $settings_repo,
583  int $node_id,
584  int $acting_usr_id,
585  ilPRGMessageCollection $err_collection,
586  ?DateTimeImmutable $deadline
587  ): self {
588  $zipper = $this->getZipper($node_id)->modifyFocus(
589  function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $deadline): ilPRGProgress {
590  if (!$pgs->isRelevant()) {
591  $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
592  return $pgs;
593  }
594  if ($pgs->isSuccessful()) {
595  $err_collection->add(false, 'will_not_modify_deadline_on_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
596  return $pgs;
597  }
598 
599  $pgs = $pgs->withDeadline($deadline)
600  ->withLastChange($acting_usr_id, $this->getNow())
601  ->withIndividualModifications(true);
602  $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id);
603  if ($pgs->isInProgress()) {
604  $this->notifyDeadlineChange($pgs);
605  }
606  $err_collection->add(true, 'deadline_updated', $this->getProgressIdString($pgs->getNodeId()));
607  return $pgs;
608  }
609  );
610 
611  $zipper = $this->updateParentProgresses($settings_repo, $zipper);
612  return $this->withProgressTree($zipper->getRoot());
613  }
614 
615  public function changeProgressValidityDate(
616  ilStudyProgrammeSettingsRepository $settings_repo,
617  int $node_id,
618  int $acting_usr_id,
619  ilPRGMessageCollection $err_collection,
620  ?DateTimeImmutable $validity_date
621  ): self {
622  $zipper = $this->getZipper($node_id)->modifyFocus(
623  function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $validity_date): ilPRGProgress {
624  if (!$pgs->isRelevant()) {
625  $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
626  return $pgs;
627  }
628  if (!$pgs->isSuccessful()) {
629  $err_collection->add(false, 'will_not_modify_validity_on_non_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
630  return $pgs;
631  }
632 
633  $validity = is_null($validity_date) || $validity_date->format(ilPRGProgress::DATE_FORMAT) >= $this->getNow()->format(ilPRGProgress::DATE_FORMAT);
634  $pgs = $pgs->withValidityOfQualification($validity_date)
635  ->withLastChange($acting_usr_id, $this->getNow())
636  ->withIndividualModifications(true)
637  ->withInvalidated(!$validity);
638 
639  $this->notifyValidityChange($pgs);
640  $err_collection->add(true, 'validity_updated', $this->getProgressIdString($pgs->getNodeId()));
641  return $pgs;
642  }
643  );
644 
645  //$zipper = $this->updateParentProgresses($settings_repo, $zipper);
646  return $this->withProgressTree($zipper->getRoot());
647  }
648 
649  public function changeAmountOfPoints(
650  ilStudyProgrammeSettingsRepository $settings_repo,
651  int $node_id,
652  int $acting_usr_id,
653  ilPRGMessageCollection $err_collection,
654  int $points
655  ): self {
656  $zipper = $this->getZipper($node_id)->modifyFocus(
657  function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $points): ilPRGProgress {
658  if (!$pgs->isRelevant()) {
659  $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
660  return $pgs;
661  }
662  if ($pgs->isSuccessful()) {
663  $err_collection->add(false, 'will_not_modify_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
664  return $pgs;
665  }
666 
667  $pgs = $pgs->withAmountOfPoints($points)
668  ->withLastChange($acting_usr_id, $this->getNow())
669  ->withIndividualModifications(true);
670 
671  $err_collection->add(true, 'required_points_updated', $this->getProgressIdString($pgs->getNodeId()));
672  $pgs = $this->recalculateProgressStatus($settings_repo, $pgs);
673  return $pgs;
674  }
675  );
676 
677  $zipper = $this->updateParentProgresses($settings_repo, $zipper);
678  return $this->withProgressTree($zipper->getRoot());
679  }
680 
681  public function invalidate(
683  ): self {
684  $zipper = $this->getZipper($this->getRootId());
685  $touched = [];
686  $now = $this->getNow();
687 
688  $zipper = $zipper->modifyAll(
689  function ($pgs) use ($now, &$touched): ilPRGProgress {
690  if (!$pgs->isSuccessful() || $pgs->hasValidQualification($now)) {
691  return $pgs;
692  }
693  $touched[] = $pgs->getPath();
694  return $pgs->invalidate();
695  }
696  );
697 
698  foreach ($touched as $path) {
699  $zipper = $this->updateParentProgresses($settings_repo, $zipper->toPath($path));
700  }
701 
702  return $this->withProgressTree($zipper->getRoot());
703  }
704 }
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
unmarkAccredited(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
notifyProgressRevertSuccess(ilPRGProgress $pgs)
notifyScoreChange(ilPRGProgress $pgs)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
markNotRelevant(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
resetProgressToSettings(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs, int $acting_usr_id)
markAccredited(ilStudyProgrammeSettingsRepository $settings_repo, ilStudyProgrammeEvents $events, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
$c
Definition: cli.php:38
changeProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, ?DateTimeImmutable $deadline)
withStatus(int $status)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
succeed(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $triggering_obj_id)
getRefIdFor(int $obj_id)
withDeadline(?\DateTimeImmutable $deadline=null)
recalculateProgressStatus(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress)
notifyProgressSuccess(ilPRGProgress $pgs)
static _getAllReferences(int $id)
get all reference ids for object ID
withCurrentAmountOfPoints(int $points_cur)
get(int $obj_id)
Load settings belonging to a SP-Object.
updateProgressDeadlineFromSettings(ilStudyProgrammeDeadlineSettings $settings, ilPRGProgress $progress)
applyProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, int $acting_usr_id=null, bool $recalculate=true)
invalidate(ilStudyProgrammeSettingsRepository $settings_repo)
add(bool $success, string $message, string $record_identitifer)
markNotFailed(\DateTimeImmutable $date, int $acting_usr_id)
$path
Definition: ltiservices.php:32
updateParentProgresses(ilStudyProgrammeSettingsRepository $settings_repo, Zipper $zipper)
changeProgressValidityDate(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, ?DateTimeImmutable $validity_date)
getProgressIdString(int $node_id)
global $DIC
Definition: feed.php:28
withAmountOfPoints(int $points)
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
updateProgressRelevanceFromSettings(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs)
updatePlanFromRepository(ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id, ilPRGMessageCollection $err_collection)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
getCourseReferencesInNode(int $node_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getZipper($node_id)
markFailed(\DateTimeImmutable $date, int $acting_usr_id)
$format
Definition: metadata.php:235
hasCompletedCourseChild(ilPRGProgress $pgs)
resetProgresses(ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id)
changeAmountOfPoints(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, int $points)
markProgressesFailedForExpiredDeadline(ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id)
notifyValidityChange(ilPRGProgress $pgs)
static _lookupTargetRefId(int $a_obj_id)
static _lookupTargetId(int $a_obj_id)
initAssignmentDates()
notifyDeadlineChange(ilPRGProgress $pgs)
static _lookupDeletedDate(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withValidityOfQualification(\DateTimeImmutable $date=null)
updateProgressValidityFromSettings(ilStudyProgrammeValidityOfAchievedQualificationSettings $settings, ilPRGProgress $progress)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
markRelevant(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)