ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilPRGAssignmentActions.php File Reference

Go to the source code of this file.

Functions

 getProgressIdString (int $node_id)
 
 getNow ()
 
 getRefIdFor (int $obj_id)
 
 recalculateProgressStatus (ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress)
 
 updateParentProgresses (ilStudyProgrammeSettingsRepository $settings_repo, Zipper $zipper)
 
 updateProgressValidityFromSettings (ilStudyProgrammeValidityOfAchievedQualificationSettings $settings, ilPRGProgress $progress)
 
 updateProgressDeadlineFromSettings (ilStudyProgrammeDeadlineSettings $settings, ilPRGProgress $progress)
 
 updateProgressRelevanceFromSettings (ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs)
 
 applyProgressDeadline (ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, ?int $acting_usr_id=null, bool $recalculate=true)
 
 resetProgressToSettings (ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs, int $acting_usr_id)
 
 getZipper ($node_id)
 
 notifyProgressSuccess (ilPRGProgress $pgs)
 
 notifyValidityChange (ilPRGProgress $pgs)
 
 notifyDeadlineChange (ilPRGProgress $pgs)
 
 notifyScoreChange (ilPRGProgress $pgs)
 
 notifyProgressRevertSuccess (ilPRGProgress $pgs)
 
 initAssignmentDates ()
 
 resetProgresses (ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id)
 
 markRelevant (ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
 
 markNotRelevant (ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
 
 markAccredited (ilStudyProgrammeSettingsRepository $settings_repo, ilStudyProgrammeEvents $events, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
 
 unmarkAccredited (ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
 
 updatePlanFromRepository (ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id, ilPRGMessageCollection $err_collection)
 
 succeed (ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $triggering_obj_id)
 
 markProgressesFailedForExpiredDeadline (ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id)
 
 changeProgressDeadline (ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, ?DateTimeImmutable $deadline)
 
 changeProgressValidityDate (ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, ?DateTimeImmutable $validity_date)
 
 changeAmountOfPoints (ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, int $points)
 
 invalidate (ilStudyProgrammeSettingsRepository $settings_repo)
 

Variables

trait ilPRGAssignmentActions
 This trait is for (physical) separation of code only; it is actually just part of an ilPRGAssignment and MUST not be used anywhere else. More...
 

Function Documentation

◆ applyProgressDeadline()

applyProgressDeadline ( ilStudyProgrammeSettingsRepository  $settings_repo,
ilPRGProgress  $progress,
?int  $acting_usr_id = null,
bool  $recalculate = true 
)
protected

Definition at line 187 of file ilPRGAssignmentActions.php.

192 : ilPRGProgress {
193 $today = $this->getNow();
195 $deadline = $progress->getDeadline();
196
197 if (is_null($acting_usr_id)) {
198 throw new Exception('no acting user.');
199 $acting_usr_id = $this->getLoggedInUserId(); //TODO !
200 }
201
202 switch ($progress->getStatus()) {
204 if (!is_null($deadline)
205 && $deadline->format($format) < $today->format($format)
206 ) {
207 $progress = $progress->markFailed($this->getNow(), $acting_usr_id);
208 $this->notifyProgressRevertSuccess($progress);
209 } else {
210 $node_settings = $settings_repo->get($progress->getNodeId());
211 $completion_mode = $node_settings->getLPMode();
212 if ($recalculate || $completion_mode !== ilStudyProgrammeSettings::MODE_LP_COMPLETED) {
213 $progress = $this->recalculateProgressStatus($settings_repo, $progress);
214 }
215 }
216 break;
217
219 if (is_null($deadline)
220 || $deadline->format($format) >= $today->format($format)
221 ) {
222 $progress = $progress->markNotFailed($this->getNow(), $acting_usr_id);
223 $this->notifyProgressRevertSuccess($progress);
224 }
225 break;
226 }
227
228 return $progress;
229 }
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
markFailed(\DateTimeImmutable $date, int $acting_usr_id)
markNotFailed(\DateTimeImmutable $date, int $acting_usr_id)
recalculateProgressStatus(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress)
notifyProgressRevertSuccess(ilPRGProgress $pgs)
get(int $obj_id)
Load settings belonging to a SP-Object.

Referenced by updatePlanFromRepository().

+ Here is the caller graph for this function:

◆ changeAmountOfPoints()

changeAmountOfPoints ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $node_id,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection,
int  $points 
)

Definition at line 623 of file ilPRGAssignmentActions.php.

629 : self {
630 $zipper = $this->getZipper($node_id)->modifyFocus(
631 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $points): ilPRGProgress {
632 if (!$pgs->isRelevant()) {
633 $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
634 return $pgs;
635 }
636 if ($pgs->isSuccessful()) {
637 $err_collection->add(false, 'will_not_modify_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
638 return $pgs;
639 }
640
641 $pgs = $pgs->withAmountOfPoints($points)
642 ->withLastChange($acting_usr_id, $this->getNow())
643 ->withIndividualModifications(true);
644
645 $err_collection->add(true, 'required_points_updated', $this->getProgressIdString($pgs->getNodeId()));
646 $pgs = $this->recalculateProgressStatus($settings_repo, $pgs);
647 return $pgs;
648 }
649 );
650
651 $zipper = $this->updateParentProgresses($settings_repo, $zipper);
652 return $this->withProgressTree($zipper->getRoot());
653 }
add(bool $success, string $message, string $record_identitifer)
updateParentProgresses(ilStudyProgrammeSettingsRepository $settings_repo, Zipper $zipper)
getZipper($node_id)
if(!file_exists('../ilias.ini.php'))

References ilPRGMessageCollection\add(), ilPRGProgress\getNodeId(), and getProgressIdString().

+ Here is the call graph for this function:

◆ changeProgressDeadline()

changeProgressDeadline ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $node_id,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection,
?DateTimeImmutable  $deadline 
)

Definition at line 555 of file ilPRGAssignmentActions.php.

561 : self {
562 $zipper = $this->getZipper($node_id)->modifyFocus(
563 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $deadline): ilPRGProgress {
564 if (!$pgs->isRelevant()) {
565 $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
566 return $pgs;
567 }
568 if ($pgs->isSuccessful()) {
569 $err_collection->add(false, 'will_not_modify_deadline_on_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
570 return $pgs;
571 }
572
573 $pgs = $pgs->withDeadline($deadline)
574 ->withLastChange($acting_usr_id, $this->getNow())
575 ->withIndividualModifications(true);
576 $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id);
577 if ($pgs->isInProgress()) {
578 $this->notifyDeadlineChange($pgs);
579 }
580 $err_collection->add(true, 'deadline_updated', $this->getProgressIdString($pgs->getNodeId()));
581 return $pgs;
582 }
583 );
584
585 $zipper = $this->updateParentProgresses($settings_repo, $zipper);
586 return $this->withProgressTree($zipper->getRoot());
587 }

References ilPRGMessageCollection\add(), ilPRGProgress\getNodeId(), and getProgressIdString().

+ Here is the call graph for this function:

◆ changeProgressValidityDate()

changeProgressValidityDate ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $node_id,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection,
?DateTimeImmutable  $validity_date 
)

Definition at line 589 of file ilPRGAssignmentActions.php.

595 : self {
596 $zipper = $this->getZipper($node_id)->modifyFocus(
597 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $validity_date): ilPRGProgress {
598 if (!$pgs->isRelevant()) {
599 $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
600 return $pgs;
601 }
602 if (!$pgs->isSuccessful()) {
603 $err_collection->add(false, 'will_not_modify_validity_on_non_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
604 return $pgs;
605 }
606
607 $validity = is_null($validity_date) || $validity_date->format(ilPRGProgress::DATE_FORMAT) >= $this->getNow()->format(ilPRGProgress::DATE_FORMAT);
608 $pgs = $pgs->withValidityOfQualification($validity_date)
609 ->withLastChange($acting_usr_id, $this->getNow())
610 ->withIndividualModifications(true)
611 ->withInvalidated(!$validity);
612
613 $this->notifyValidityChange($pgs);
614 $err_collection->add(true, 'validity_updated', $this->getProgressIdString($pgs->getNodeId()));
615 return $pgs;
616 }
617 );
618
619 //$zipper = $this->updateParentProgresses($settings_repo, $zipper);
620 return $this->withProgressTree($zipper->getRoot());
621 }

References ilPRGMessageCollection\add(), ilPRGProgress\getNodeId(), and getProgressIdString().

+ Here is the call graph for this function:

◆ getNow()

getNow ( )
protected

Definition at line 41 of file ilPRGAssignmentActions.php.

41 : DateTimeImmutable
42 {
43 return new DateTimeImmutable();
44 }

Referenced by ILIAS\Glossary\Flashcard\FlashcardManager\getNonTodayUserTermsForBox(), ILIAS\Glossary\Flashcard\FlashcardManager\getTodayUserTermsForBox(), and updateParentProgresses().

+ Here is the caller graph for this function:

◆ getProgressIdString()

getProgressIdString ( int  $node_id)
protected

Definition at line 31 of file ilPRGAssignmentActions.php.

31 : 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 }

Referenced by changeAmountOfPoints(), changeProgressDeadline(), changeProgressValidityDate(), markNotRelevant(), and markRelevant().

+ Here is the caller graph for this function:

◆ getRefIdFor()

getRefIdFor ( int  $obj_id)
protected

Definition at line 46 of file ilPRGAssignmentActions.php.

46 : 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 }
Base class for ILIAS Exception handling.
static _getAllReferences(int $id)
get all reference ids for object ID

References ilObject\_getAllReferences().

Referenced by ilObjStudyProgramme\getInstanceByObjId(), and ilObjStudyProgramme\getPrgInstanceByObjId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getZipper()

getZipper (   $node_id)
protected

Definition at line 265 of file ilPRGAssignmentActions.php.

266 {
267 $progress_path = $this->getProgressForNode($node_id)->getPath();
268 $zipper = new Zipper($this->getProgressTree());
269 return $zipper = $zipper->toPath($progress_path);
270 }

Referenced by initAssignmentDates().

+ Here is the caller graph for this function:

◆ initAssignmentDates()

initAssignmentDates ( )

Definition at line 293 of file ilPRGAssignmentActions.php.

293 : self
294 {
295 $zipper = $this->getZipper($this->getRootId());
296 $zipper = $zipper->modifyAll(
297 fn($pgs) => $pgs->withAssignmentDate($this->getNow())
298 );
299 return $this->withProgressTree($zipper->getRoot());
300 }

References getZipper(), and ilPRGProgress\withAssignmentDate().

+ Here is the call graph for this function:

◆ invalidate()

invalidate ( ilStudyProgrammeSettingsRepository  $settings_repo)

Definition at line 655 of file ilPRGAssignmentActions.php.

657 : self {
658 $zipper = $this->getZipper($this->getRootId());
659 $touched = [];
660 $now = $this->getNow();
661
662 $zipper = $zipper->modifyAll(
663 function ($pgs) use ($now, &$touched): ilPRGProgress {
664 if (!$pgs->isSuccessful() || $pgs->hasValidQualification($now)) {
665 return $pgs;
666 }
667 $touched[] = $pgs->getPath();
668 return $pgs->invalidate();
669 }
670 );
671
672 foreach ($touched as $path) {
673 $zipper = $this->updateParentProgresses($settings_repo, $zipper->toPath($path));
674 }
675
676 return $this->withProgressTree($zipper->getRoot());
677 }
$path
Definition: ltiservices.php:30

◆ markAccredited()

markAccredited ( ilStudyProgrammeSettingsRepository  $settings_repo,
ilStudyProgrammeEvents  $events,
int  $node_id,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection 
)

Definition at line 374 of file ilPRGAssignmentActions.php.

380 : self {
381 $zipper = $this->getZipper($node_id);
382
383 $zipper = $zipper->modifyFocus(
384 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo): ilPRGProgress {
385 if (!$pgs->isRelevant()) {
386 $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
387 return $pgs;
388 }
389
391 if ($pgs->getStatus() === $new_status) {
392 $err_collection->add(false, 'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
393 return $pgs;
394 }
395 if (!$pgs->isTransitionAllowedTo($new_status)) {
396 $err_collection->add(false, 'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
397 return $pgs;
398 }
399
400 $pgs = $pgs
401 ->markAccredited($this->getNow(), $acting_usr_id)
402 ->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
403 $this->notifyScoreChange($pgs);
404
405 if (!$pgs->getValidityOfQualification()) {
406 $settings = $settings_repo->get($pgs->getNodeId())->getValidityOfQualificationSettings();
407 $pgs = $this->updateProgressValidityFromSettings($settings, $pgs);
408 }
409
410 $this->notifyProgressSuccess($pgs);
411 $err_collection->add(true, 'status_changed', $this->getProgressIdString($pgs->getNodeId()));
412 return $pgs;
413 }
414 );
415
416 $zipper = $this->updateParentProgresses($settings_repo, $zipper);
417 return $this->withProgressTree($zipper->getRoot());
418 }

References ilPRGMessageCollection\add(), ilPRGProgress\getAmountOfPoints(), ilPRGProgress\getNodeId(), ilPRGProgress\getStatus(), ilPRGProgress\getValidityOfQualification(), if, ilPRGProgress\isRelevant(), ilPRGProgress\isTransitionAllowedTo(), ilPRGProgress\markAccredited(), and ilPRGProgress\STATUS_ACCREDITED.

+ Here is the call graph for this function:

◆ markNotRelevant()

markNotRelevant ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $node_id,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection 
)

Definition at line 340 of file ilPRGAssignmentActions.php.

345 : self {
346 $zipper = $this->getZipper($node_id);
347
348 if ($zipper->isTop()) {
349 $err_collection->add(false, 'will_not_set_top_progress_to_irrelevant', $this->getProgressIdString($node_id));
350 return $this;
351 }
352
353 $zipper = $zipper->modifyFocus(
354 function ($pgs) use ($err_collection, $acting_usr_id): ilPRGProgress {
355 if (!$pgs->isRelevant()) {
356 $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
357 return $pgs;
358 }
359 if ($pgs->getStatus() === ilPRGProgress::STATUS_COMPLETED) {
360 $err_collection->add(false, 'will_not_modify_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
361 return $pgs;
362 }
363
364 $pgs = $pgs->markNotRelevant($this->getNow(), $acting_usr_id);
365 $err_collection->add(true, 'set_to_irrelevant', $this->getProgressIdString($pgs->getNodeId()));
366 return $pgs;
367 }
368 );
369
370 $zipper = $this->updateParentProgresses($settings_repo, $zipper);
371 return $this->withProgressTree($zipper->getRoot());
372 }
getProgressIdString(int $node_id)

References ilPRGMessageCollection\add(), and getProgressIdString().

+ Here is the call graph for this function:

◆ markProgressesFailedForExpiredDeadline()

markProgressesFailedForExpiredDeadline ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $acting_usr_id 
)

Definition at line 525 of file ilPRGAssignmentActions.php.

528 : self {
529 $zipper = $this->getZipper($this->getRootId());
530 $touched = [];
531
532 $deadline = $this->getNow();
533 $zipper = $zipper->modifyAll(
534 function ($pgs) use ($acting_usr_id, $deadline, &$touched): ilPRGProgress {
535 if (is_null($pgs->getDeadline())
536 || !$pgs->isInProgress()
537 || $pgs->getDeadline()->format(ilPRGProgress::DATE_FORMAT) >= $deadline->format(ilPRGProgress::DATE_FORMAT)
538 ) {
539 return $pgs;
540 }
541
542 $touched[] = $pgs->getPath();
543 $this->notifyProgressRevertSuccess($pgs);
544 return $pgs->markFailed($this->getNow(), $acting_usr_id);
545 }
546 );
547
548 foreach ($touched as $path) {
549 $zipper = $this->updateParentProgresses($settings_repo, $zipper->toPath($path));
550 }
551
552 return $this->withProgressTree($zipper->getRoot());
553 }

◆ markRelevant()

markRelevant ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $node_id,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection 
)

Definition at line 317 of file ilPRGAssignmentActions.php.

322 : self {
323 $zipper = $this->getZipper($node_id)->modifyFocus(
324 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo): ilPRGProgress {
325 if ($pgs->isRelevant()) {
326 $err_collection->add(false, 'will_not_modify_relevant_progress', $this->getProgressIdString($pgs->getNodeId()));
327 return $pgs;
328 }
329 $pgs = $pgs->markRelevant($this->getNow(), $acting_usr_id);
330 $err_collection->add(true, 'set_to_relevant', $this->getProgressIdString($pgs->getNodeId()));
331 $pgs = $this->recalculateProgressStatus($settings_repo, $pgs);
332 return $pgs;
333 }
334 );
335
336 $zipper = $this->updateParentProgresses($settings_repo, $zipper);
337 return $this->withProgressTree($zipper->getRoot());
338 }
markRelevant(\DateTimeImmutable $date, int $acting_usr_id)

References ilPRGMessageCollection\add(), ilPRGProgress\getNodeId(), and getProgressIdString().

+ Here is the call graph for this function:

◆ notifyDeadlineChange()

notifyDeadlineChange ( ilPRGProgress  $pgs)
protected

Definition at line 280 of file ilPRGAssignmentActions.php.

280 : void
281 {
282 $this->getEvents()->deadlineChange($this, $pgs->getNodeId());
283 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyProgressRevertSuccess()

notifyProgressRevertSuccess ( ilPRGProgress  $pgs)
protected

Definition at line 288 of file ilPRGAssignmentActions.php.

288 : void
289 {
290 $this->getEvents()->userRevertSuccessful($this, $pgs->getNodeId());
291 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyProgressSuccess()

notifyProgressSuccess ( ilPRGProgress  $pgs)
protected

Definition at line 272 of file ilPRGAssignmentActions.php.

272 : void
273 {
274 $this->getEvents()->userSuccessful($this, $pgs->getNodeId());
275 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyScoreChange()

notifyScoreChange ( ilPRGProgress  $pgs)
protected

Definition at line 284 of file ilPRGAssignmentActions.php.

284 : void
285 {
286 $this->getEvents()->scoreChange($this, $pgs->getNodeId());
287 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyValidityChange()

notifyValidityChange ( ilPRGProgress  $pgs)
protected

Definition at line 276 of file ilPRGAssignmentActions.php.

276 : void
277 {
278 $this->getEvents()->validityChange($this, $pgs->getNodeId());
279 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ recalculateProgressStatus()

recalculateProgressStatus ( ilStudyProgrammeSettingsRepository  $settings_repo,
ilPRGProgress  $progress 
)
protected

Definition at line 55 of file ilPRGAssignmentActions.php.

59 if (!$progress->isRelevant()) {
60 return $progress;
61 }
62 $node_settings = $settings_repo->get($progress->getNodeId());
63 $completion_mode = $node_settings->getLPMode();
64
65 switch ($completion_mode) {
68 return $progress;
69 break;
71 $completing_crs_id = ilPRGProgress::COMPLETED_BY_SUBNODES;
72 $achieved_points = $progress->getAchievedPointsOfChildren();
73 break;
74 }
75
76 $progress = $progress->withCurrentAmountOfPoints($achieved_points);
77 $this->notifyScoreChange($progress);
78
79 $required_points = $progress->getAmountOfPoints();
80 $successful = ($achieved_points >= $required_points);
81
82 if ($successful && !$progress->isSuccessful()) {
83 $progress = $progress
85 ->withCompletion($completing_crs_id, $this->getNow());
86
87 if (!$progress->getValidityOfQualification()) {
88 $settings = $settings_repo->get($progress->getNodeId())->getValidityOfQualificationSettings();
89 $progress = $this->updateProgressValidityFromSettings($settings, $progress);
90 }
91 $this->notifyProgressSuccess($progress);
92 }
93
94 if (!$successful && $progress->isSuccessful()
96 ) {
97 $progress = $progress
99 ->withCompletion(null, null)
100 ->withValidityOfQualification(null);
101
102 $this->notifyValidityChange($progress);
103 $this->notifyProgressRevertSuccess($progress);
104 }
105
106 return $progress;
107 }
withCurrentAmountOfPoints(int $points_cur)
withStatus(int $status)
notifyValidityChange(ilPRGProgress $pgs)
notifyScoreChange(ilPRGProgress $pgs)
updateProgressValidityFromSettings(ilStudyProgrammeValidityOfAchievedQualificationSettings $settings, ilPRGProgress $progress)
notifyProgressSuccess(ilPRGProgress $pgs)

Referenced by updateParentProgresses().

+ Here is the caller graph for this function:

◆ resetProgresses()

resetProgresses ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $acting_usr_id 
)

Definition at line 302 of file ilPRGAssignmentActions.php.

305 : self {
306 $zipper = $this->getZipper($this->getRootId());
307 $zipper = $zipper->modifyAll(
308 function ($pgs) use ($acting_usr_id, $settings_repo): ilPRGProgress {
309 $pgs = $this->updateProgressRelevanceFromSettings($settings_repo, $pgs);
310 $pgs = $this->resetProgressToSettings($settings_repo, $pgs, $acting_usr_id);
311 return $pgs;
312 }
313 );
314 return $this->withProgressTree($zipper->getRoot());
315 }
resetProgressToSettings(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs, int $acting_usr_id)
updateProgressRelevanceFromSettings(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs)

References resetProgressToSettings(), and updateProgressRelevanceFromSettings().

+ Here is the call graph for this function:

◆ resetProgressToSettings()

resetProgressToSettings ( ilStudyProgrammeSettingsRepository  $settings_repo,
ilPRGProgress  $pgs,
int  $acting_usr_id 
)
protected

Definition at line 232 of file ilPRGAssignmentActions.php.

236 : ilPRGProgress {
237 $settings = $settings_repo->get($pgs->getNodeId());
238 if ($pgs->isRelevant()) {
239 $pgs = $this->updateProgressValidityFromSettings($settings->getValidityOfQualificationSettings(), $pgs);
240 $pgs = $this->updateProgressDeadlineFromSettings($settings->getDeadlineSettings(), $pgs);
241 } else {
242 $pgs = $pgs
244 ->withDeadline(null);
245 $this->notifyValidityChange($pgs);
246 }
247
248 $pgs = $pgs
249 ->withAmountOfPoints($settings->getAssessmentSettings()->getPoints())
250 ->withLastChange($acting_usr_id, $this->getNow())
251 ->withIndividualModifications(false);
252
253 if ($pgs->isSuccessful()) {
254 $pgs = $pgs->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
255 $this->notifyScoreChange($pgs);
256 }
257
258 return $pgs;
259 }
withAmountOfPoints(int $points)
withValidityOfQualification(?\DateTimeImmutable $date=null)
updateProgressDeadlineFromSettings(ilStudyProgrammeDeadlineSettings $settings, ilPRGProgress $progress)

References updateProgressDeadlineFromSettings(), and updateProgressValidityFromSettings().

Referenced by resetProgresses(), and updatePlanFromRepository().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ succeed()

succeed ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $node_id,
int  $triggering_obj_id 
)

Definition at line 495 of file ilPRGAssignmentActions.php.

499 : self {
500 $zipper = $this->getZipper($node_id)->modifyFocus(
501 function ($pgs) use ($settings_repo, $triggering_obj_id): ilPRGProgress {
502 $deadline = $pgs->getDeadline();
504 $now = $this->getNow();
505 if ($pgs->isInProgress() &&
506 (is_null($deadline) || $deadline->format($format) >= $now->format($format))
507 ) {
508 $pgs = $pgs->succeed($now, $triggering_obj_id)
509 ->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
510 $this->notifyScoreChange($pgs);
511 $settings = $settings_repo->get($pgs->getNodeId())->getValidityOfQualificationSettings();
512 $pgs = $this->updateProgressValidityFromSettings($settings, $pgs);
513 }
514
515 $this->notifyProgressSuccess($pgs);
516 return $pgs;
517 }
518 );
519
520 $zipper = $this->updateParentProgresses($settings_repo, $zipper);
521 return $this->withProgressTree($zipper->getRoot());
522 }

◆ unmarkAccredited()

unmarkAccredited ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $node_id,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection 
)

Definition at line 421 of file ilPRGAssignmentActions.php.

426 : self {
427 $zipper = $this->getZipper($node_id);
428
429 $zipper = $zipper->modifyFocus(
430 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo): ilPRGProgress {
431 if (!$pgs->isRelevant()) {
432 $err_collection->add(false, 'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
433 return $pgs;
434 }
435
437 if ($pgs->getStatus() === $new_status) {
438 $err_collection->add(false, 'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
439 return $pgs;
440 }
441 if (!$pgs->isTransitionAllowedTo($new_status)
442 //special case: completion may not be revoked manually (but might be as a calculation-result of underlying progresses)
443 || $pgs->getStatus() === ilPRGProgress::STATUS_COMPLETED
444 ) {
445 $err_collection->add(false, 'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
446 return $pgs;
447 }
448
449 $pgs = $pgs
450 ->unmarkAccredited($this->getNow(), $acting_usr_id)
451 ->withCurrentAmountOfPoints($pgs->getAchievedPointsOfChildren());
452 $this->notifyScoreChange($pgs);
453
454 $old_status = $pgs->getStatus();
455 $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id);
456 if ($pgs->getStatus() !== $old_status) {
457 $err_collection->add(false, 'status_changed_due_to_deadline', $this->getProgressIdString($pgs->getNodeId()));
458 } else {
459 $err_collection->add(true, 'status_changed', $this->getProgressIdString($pgs->getNodeId()));
460 }
461 $this->notifyProgressRevertSuccess($pgs);
462 return $pgs;
463 }
464 );
465
466 $zipper = $this->updateParentProgresses($settings_repo, $zipper);
467 return $this->withProgressTree($zipper->getRoot());
468 }

References ilPRGProgress\getAchievedPointsOfChildren(), ilPRGProgress\getStatus(), if, ilPRGProgress\isRelevant(), ilPRGProgress\isTransitionAllowedTo(), ilPRGProgress\STATUS_COMPLETED, ilPRGProgress\STATUS_IN_PROGRESS, and ilPRGProgress\unmarkAccredited().

+ Here is the call graph for this function:

◆ updateParentProgresses()

updateParentProgresses ( ilStudyProgrammeSettingsRepository  $settings_repo,
Zipper  $zipper 
)
protected

Definition at line 109 of file ilPRGAssignmentActions.php.

112 : Zipper {
113 while (!$zipper->isTop()) {
114 $zipper = $zipper->toParent()
115 ->modifyFocus(
116 function ($pgs) use ($settings_repo) {
117 $today = $this->getNow();
119 $deadline = $pgs->getDeadline();
120 if (!is_null($deadline)
121 && $deadline->format($format) <= $today->format($format)
122 ) {
123 return $pgs;
124 }
125 return $this->recalculateProgressStatus($settings_repo, $pgs);
126 }
127 );
128 }
129 return $zipper;
130 }

References ilPRGProgress\DATE_FORMAT, getNow(), recalculateProgressStatus(), and ILIAS\StudyProgramme\Assignment\Zipper\toParent().

+ Here is the call graph for this function:

◆ updatePlanFromRepository()

updatePlanFromRepository ( ilStudyProgrammeSettingsRepository  $settings_repo,
int  $acting_usr_id,
ilPRGMessageCollection  $err_collection 
)

Definition at line 470 of file ilPRGAssignmentActions.php.

474 : self {
475 $zipper = $this->getZipper($this->getRootId());
476 $leafs = [];
477 $zipper = $zipper->modifyAll(
478 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, &$leafs): ilPRGProgress {
479 $pgs = $this->updateProgressRelevanceFromSettings($settings_repo, $pgs);
480 $pgs = $this->resetProgressToSettings($settings_repo, $pgs, $acting_usr_id);
481 $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id, false);
482 if (!$pgs->getSubnodes()) {
483 $leafs[] = $pgs->getPath();
484 }
485 return $pgs;
486 }
487 );
488
489 foreach ($leafs as $path) {
490 $zipper = $this->updateParentProgresses($settings_repo, $zipper->toPath($path));
491 }
492 return $this->withProgressTree($zipper->getRoot());
493 }
applyProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, ?int $acting_usr_id=null, bool $recalculate=true)

References applyProgressDeadline(), ILIAS\StudyProgramme\Assignment\Node\getPath(), ILIAS\StudyProgramme\Assignment\Node\getSubnodes(), resetProgressToSettings(), and updateProgressRelevanceFromSettings().

+ Here is the call graph for this function:

◆ updateProgressDeadlineFromSettings()

updateProgressDeadlineFromSettings ( ilStudyProgrammeDeadlineSettings  $settings,
ilPRGProgress  $progress 
)
protected

Definition at line 155 of file ilPRGAssignmentActions.php.

158 : ilPRGProgress {
159 $period = $settings->getDeadlinePeriod();
160 $date = $settings->getDeadlineDate();
161
162 if ($period) {
163 $date = $progress->getAssignmentDate();
164 $date = $date->add(new DateInterval('P' . $period . 'D'));
165 }
166 $this->notifyDeadlineChange($progress);
167 return $progress->withDeadline($date);
168 }
withDeadline(?\DateTimeImmutable $deadline=null)
notifyDeadlineChange(ilPRGProgress $pgs)

References ilPRGProgress\getAssignmentDate().

Referenced by resetProgressToSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateProgressRelevanceFromSettings()

updateProgressRelevanceFromSettings ( ilStudyProgrammeSettingsRepository  $settings_repo,
ilPRGProgress  $pgs 
)
protected

Definition at line 170 of file ilPRGAssignmentActions.php.

173 : ilPRGProgress {
174 $programme_status = $settings_repo->get($pgs->getNodeId())->getAssessmentSettings()->getStatus();
175 $active = $programme_status === ilStudyProgrammeSettings::STATUS_ACTIVE;
176
177 if ($active && !$pgs->isRelevant()) {
179 }
180 if (!$active && $pgs->isInProgress()) {
182 }
183 return $pgs;
184 }

References ilPRGProgress\STATUS_IN_PROGRESS, and ilPRGProgress\withStatus().

Referenced by resetProgresses(), and updatePlanFromRepository().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateProgressValidityFromSettings()

updateProgressValidityFromSettings ( ilStudyProgrammeValidityOfAchievedQualificationSettings  $settings,
ilPRGProgress  $progress 
)
protected

Definition at line 132 of file ilPRGAssignmentActions.php.

135 : ilPRGProgress {
136 $cdate = $progress->getCompletionDate();
137 if (!$cdate
138 || $progress->isSuccessful() === false
139 ) {
140 return $progress;
141 }
142 $period = $settings->getQualificationPeriod();
143 $date = $settings->getQualificationDate();
144
145 if ($period) {
146 $date = $cdate->add(new DateInterval('P' . $period . 'D'));
147 }
148
149 $validity = is_null($date) || $date->format(ilPRGProgress::DATE_FORMAT) >= $this->getNow()->format(ilPRGProgress::DATE_FORMAT);
150 $this->notifyValidityChange($progress);
151 return $progress->withValidityOfQualification($date)
152 ->withInvalidated(!$validity);
153 }

Referenced by resetProgressToSettings().

+ Here is the caller graph for this function:

Variable Documentation

◆ ilPRGAssignmentActions

trait ilPRGAssignmentActions
Initial value:
{
abstract public function getEvents(): StudyProgrammeEvents

This trait is for (physical) separation of code only; it is actually just part of an ilPRGAssignment and MUST not be used anywhere else.

Definition at line 27 of file ilPRGAssignmentActions.php.