3 declare(strict_types=1);
34 '%s, progress-id (%s/%s)',
35 $this->user_info->getFullname(),
49 if (count($refs) < 1) {
50 throw new ilException(
"Could not find ref_id for programme with obj_id $obj_id");
52 return (
int) array_shift($refs);
60 $children = $tree->getChildsByType($node_ref,
"crsr");
61 $children = array_filter(
78 return (
int)$child[
"obj_id"];
91 $node_settings = $settings_repo->
get($progress->
getNodeId());
92 $completion_mode = $node_settings->getLPMode();
94 switch ($completion_mode) {
109 $successful = ($achieved_points >= $required_points);
112 $progress = $progress
114 ->withCompletion($completing_crs_id, $this->
getNow());
122 $progress = $progress
124 ->withCompletion(null, null)
125 ->withValidityOfQualification(null);
138 while (!$zipper->
isTop()) {
141 function ($pgs) use ($settings_repo) {
144 $deadline = $pgs->getDeadline();
145 if (!is_null($deadline)
172 $date = $cdate->add(
new DateInterval(
'P' . $period .
'D'));
178 ->withInvalidated(!$validity);
190 $date = $date->add(
new DateInterval(
'P' . $period .
'D'));
200 $programme_status = $settings_repo->
get($pgs->
getNodeId())->getAssessmentSettings()->getStatus();
216 int $acting_usr_id = null,
217 bool $recalculate =
true 223 if (is_null($acting_usr_id)) {
225 $acting_usr_id = $this->getLoggedInUserId();
231 if (!is_null($deadline)
237 $node_settings = $settings_repo->
get($progress->
getNodeId());
238 $completion_mode = $node_settings->getLPMode();
246 if (is_null($deadline)
271 ->withDeadline(null);
277 ->withLastChange($acting_usr_id, $this->
getNow())
278 ->withIndividualModifications(
false);
294 $progress_path = $this->getProgressForNode($node_id)->getPath();
295 $zipper =
new Zipper($this->getProgressTree());
296 return $zipper = $zipper->toPath($progress_path);
301 $this->getEvents()->userSuccessful($this, $pgs->
getNodeId());
305 $this->getEvents()->validityChange($this, $pgs->
getNodeId());
309 $this->getEvents()->deadlineChange($this, $pgs->
getNodeId());
313 $this->getEvents()->scoreChange($this, $pgs->
getNodeId());
317 $this->getEvents()->userRevertSuccessful($this, $pgs->
getNodeId());
322 $zipper = $this->
getZipper($this->getRootId());
323 $zipper = $zipper->modifyAll(
324 fn ($pgs) => $pgs->withAssignmentDate($this->getNow())
326 return $this->withProgressTree($zipper->getRoot());
333 $zipper = $this->
getZipper($this->getRootId());
334 $zipper = $zipper->modifyAll(
335 function ($pgs) use ($acting_usr_id, $settings_repo):
ilPRGProgress {
341 return $this->withProgressTree($zipper->getRoot());
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()));
356 $pgs = $pgs->markRelevant($this->
getNow(), $acting_usr_id);
364 return $this->withProgressTree($zipper->getRoot());
375 if ($zipper->isTop()) {
376 $err_collection->
add(
false,
'will_not_set_top_progress_to_irrelevant', $this->
getProgressIdString($node_id));
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()));
386 $pgs = $pgs->markNotRelevant($this->
getNow(), $acting_usr_id);
393 return $this->withProgressTree($zipper->getRoot());
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()));
413 if ($pgs->getStatus() === $new_status) {
417 if (!$pgs->isTransitionAllowedTo($new_status)) {
418 $err_collection->
add(
false,
'status_transition_not_allowed', $this->
getProgressIdString($pgs->getNodeId()));
423 ->markAccredited($this->
getNow(), $acting_usr_id)
424 ->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
427 if (!$pgs->getValidityOfQualification()) {
428 $settings = $settings_repo->
get($pgs->getNodeId())->getValidityOfQualificationSettings();
439 return $this->withProgressTree($zipper->getRoot());
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()));
459 if ($pgs->getStatus() === $new_status) {
463 if (!$pgs->isTransitionAllowedTo($new_status)
467 $err_collection->
add(
false,
'status_transition_not_allowed', $this->
getProgressIdString($pgs->getNodeId()));
472 ->unmarkAccredited($this->
getNow(), $acting_usr_id)
473 ->withCurrentAmountOfPoints($pgs->getAchievedPointsOfChildren());
476 $old_status = $pgs->getStatus();
478 if ($pgs->getStatus() !== $old_status) {
479 $err_collection->
add(
false,
'status_changed_due_to_deadline', $this->
getProgressIdString($pgs->getNodeId()));
489 return $this->withProgressTree($zipper->getRoot());
497 $zipper = $this->
getZipper($this->getRootId());
499 $zipper = $zipper->modifyAll(
500 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, &$leafs):
ilPRGProgress {
504 if (!$pgs->getSubnodes()) {
505 $leafs[] = $pgs->getPath();
512 foreach ($leafs as
$path) {
516 return $this->withProgressTree($zipper->getRoot());
523 int $triggering_obj_id
525 $zipper = $this->
getZipper($node_id)->modifyFocus(
526 function ($pgs) use ($settings_repo, $triggering_obj_id):
ilPRGProgress {
530 if ($pgs->isInProgress() &&
531 (is_null($deadline) || $deadline->format(
$format) >= $now->format(
$format))
533 $pgs = $pgs->succeed($now, $triggering_obj_id)
534 ->withCurrentAmountOfPoints($pgs->getAmountOfPoints());
547 return $this->withProgressTree($zipper->getRoot());
555 $zipper = $this->
getZipper($this->getRootId());
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()
570 return $pgs->markFailed($this->
getNow(), $acting_usr_id);
574 foreach ($touched as
$path) {
578 return $this->withProgressTree($zipper->getRoot());
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()));
594 if ($pgs->isSuccessful()) {
595 $err_collection->
add(
false,
'will_not_modify_deadline_on_successful_progress', $this->
getProgressIdString($pgs->getNodeId()));
599 $pgs = $pgs->withDeadline($deadline)
600 ->withLastChange($acting_usr_id, $this->
getNow())
601 ->withIndividualModifications(
true);
603 if ($pgs->isInProgress()) {
612 return $this->withProgressTree($zipper->getRoot());
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()));
628 if (!$pgs->isSuccessful()) {
629 $err_collection->
add(
false,
'will_not_modify_validity_on_non_successful_progress', $this->
getProgressIdString($pgs->getNodeId()));
634 $pgs = $pgs->withValidityOfQualification($validity_date)
635 ->withLastChange($acting_usr_id, $this->
getNow())
636 ->withIndividualModifications(
true)
637 ->withInvalidated(!$validity);
646 return $this->withProgressTree($zipper->getRoot());
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()));
662 if ($pgs->isSuccessful()) {
663 $err_collection->
add(
false,
'will_not_modify_successful_progress', $this->
getProgressIdString($pgs->getNodeId()));
667 $pgs = $pgs->withAmountOfPoints($points)
668 ->withLastChange($acting_usr_id, $this->
getNow())
669 ->withIndividualModifications(
true);
678 return $this->withProgressTree($zipper->getRoot());
684 $zipper = $this->
getZipper($this->getRootId());
688 $zipper = $zipper->modifyAll(
690 if (!$pgs->isSuccessful() || $pgs->hasValidQualification($now)) {
694 return $pgs->invalidate();
698 foreach ($touched as
$path) {
702 return $this->withProgressTree($zipper->getRoot());
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)
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)
changeProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, ?DateTimeImmutable $deadline)
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)
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)
getAchievedPointsOfChildren()
add(bool $success, string $message, string $record_identitifer)
markNotFailed(\DateTimeImmutable $date, int $acting_usr_id)
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)
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...
markFailed(\DateTimeImmutable $date, int $acting_usr_id)
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)
const STATUS_NOT_RELEVANT
markProgressesFailedForExpiredDeadline(ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id)
notifyValidityChange(ilPRGProgress $pgs)
static _lookupTargetRefId(int $a_obj_id)
static _lookupTargetId(int $a_obj_id)
notifyDeadlineChange(ilPRGProgress $pgs)
const COMPLETED_BY_SUBNODES
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)