ILIAS  release_8 Revision v8.24
ilPRGAssignmentActions.php File Reference

Go to the source code of this file.

Functions

 getProgressIdString (int $node_id)
 
 getNow ()
 
 getRefIdFor (int $obj_id)
 
 getCourseReferencesInNode (int $node_obj_id)
 
 hasCompletedCourseChild (ilPRGProgress $pgs)
 
 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 213 of file ilPRGAssignmentActions.php.

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 }
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.
$format
Definition: metadata.php:235

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 649 of file ilPRGAssignmentActions.php.

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 }
add(bool $success, string $message, string $record_identitifer)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
updateParentProgresses(ilStudyProgrammeSettingsRepository $settings_repo, Zipper $zipper)
getZipper($node_id)

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 581 of file ilPRGAssignmentActions.php.

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 }

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 615 of file ilPRGAssignmentActions.php.

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 }

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

+ Here is the call graph for this function:

◆ getCourseReferencesInNode()

getCourseReferencesInNode ( int  $node_obj_id)
protected

Definition at line 55 of file ilPRGAssignmentActions.php.

55 : 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 }
static _lookupTargetRefId(int $a_obj_id)
static _lookupDeletedDate(int $ref_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
getRefIdFor(int $obj_id)

References $c, $DIC, ilObject\_exists(), ilObject\_lookupDeletedDate(), ilContainerReference\_lookupTargetRefId(), and getRefIdFor().

Referenced by hasCompletedCourseChild().

+ Here is the call graph for this function:
+ Here is the caller 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 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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getAllReferences(int $id)
get all reference ids for object ID

References ilObject\_getAllReferences().

Referenced by getCourseReferencesInNode(), ilObjStudyProgramme\getInstanceByObjId(), ilObjStudyProgramme\getObjIdsOfChildren(), 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 292 of file ilPRGAssignmentActions.php.

293 {
294 $progress_path = $this->getProgressForNode($node_id)->getPath();
295 $zipper = new Zipper($this->getProgressTree());
296 return $zipper = $zipper->toPath($progress_path);
297 }

Referenced by initAssignmentDates().

+ Here is the caller graph for this function:

◆ hasCompletedCourseChild()

hasCompletedCourseChild ( ilPRGProgress  $pgs)
protected

Definition at line 73 of file ilPRGAssignmentActions.php.

73 : ?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 }
static _lookupTargetId(int $a_obj_id)
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
getCourseReferencesInNode(int $node_obj_id)

References ilLPStatus\_hasUserCompleted(), ilContainerReference\_lookupTargetId(), getCourseReferencesInNode(), and ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ initAssignmentDates()

initAssignmentDates ( )

Definition at line 320 of file ilPRGAssignmentActions.php.

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

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

+ Here is the call graph for this function:

◆ invalidate()

invalidate ( ilStudyProgrammeSettingsRepository  $settings_repo)

Definition at line 681 of file ilPRGAssignmentActions.php.

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 }
$path
Definition: ltiservices.php:32

◆ markAccredited()

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

Definition at line 396 of file ilPRGAssignmentActions.php.

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

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 367 of file ilPRGAssignmentActions.php.

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 }
markNotRelevant(\DateTimeImmutable $date, int $acting_usr_id)
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 551 of file ilPRGAssignmentActions.php.

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 }

◆ markRelevant()

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

Definition at line 344 of file ilPRGAssignmentActions.php.

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 }
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 307 of file ilPRGAssignmentActions.php.

307 : void
308 {
309 $this->getEvents()->deadlineChange($this, $pgs->getNodeId());
310 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyProgressRevertSuccess()

notifyProgressRevertSuccess ( ilPRGProgress  $pgs)
protected

Definition at line 315 of file ilPRGAssignmentActions.php.

315 : void
316 {
317 $this->getEvents()->userRevertSuccessful($this, $pgs->getNodeId());
318 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyProgressSuccess()

notifyProgressSuccess ( ilPRGProgress  $pgs)
protected

Definition at line 299 of file ilPRGAssignmentActions.php.

299 : void
300 {
301 $this->getEvents()->userSuccessful($this, $pgs->getNodeId());
302 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyScoreChange()

notifyScoreChange ( ilPRGProgress  $pgs)
protected

Definition at line 311 of file ilPRGAssignmentActions.php.

311 : void
312 {
313 $this->getEvents()->scoreChange($this, $pgs->getNodeId());
314 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ notifyValidityChange()

notifyValidityChange ( ilPRGProgress  $pgs)
protected

Definition at line 303 of file ilPRGAssignmentActions.php.

303 : void
304 {
305 $this->getEvents()->validityChange($this, $pgs->getNodeId());
306 }

References ilPRGProgress\getNodeId().

+ Here is the call graph for this function:

◆ recalculateProgressStatus()

recalculateProgressStatus ( ilStudyProgrammeSettingsRepository  $settings_repo,
ilPRGProgress  $progress 
)
protected

Definition at line 84 of file ilPRGAssignmentActions.php.

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()
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 }
withCurrentAmountOfPoints(int $points_cur)
withStatus(int $status)
notifyValidityChange(ilPRGProgress $pgs)
notifyScoreChange(ilPRGProgress $pgs)
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 329 of file ilPRGAssignmentActions.php.

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 }
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 259 of file ilPRGAssignmentActions.php.

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 }
withValidityOfQualification(\DateTimeImmutable $date=null)
withAmountOfPoints(int $points)
updateProgressValidityFromSettings(ilStudyProgrammeValidityOfAchievedQualificationSettings $settings, ilPRGProgress $progress)
updateProgressDeadlineFromSettings(ilStudyProgrammeDeadlineSettings $settings, ilPRGProgress $progress)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

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 520 of file ilPRGAssignmentActions.php.

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 }

◆ unmarkAccredited()

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

Definition at line 443 of file ilPRGAssignmentActions.php.

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

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 134 of file ilPRGAssignmentActions.php.

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 }

References $format, 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 492 of file ilPRGAssignmentActions.php.

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 }
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 181 of file ilPRGAssignmentActions.php.

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 }
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 196 of file ilPRGAssignmentActions.php.

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 }

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 158 of file ilPRGAssignmentActions.php.

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 }

Referenced by resetProgressToSettings().

+ Here is the caller graph for this function:

Variable Documentation

◆ ilPRGAssignmentActions

trait ilPRGAssignmentActions
Initial value:
{
abstract public function getEvents(): StudyProgrammeEvents
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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.