3declare(strict_types=1);
34 '%s, progress-id (%s/%s)',
35 $this->user_info->getFullname(),
41 protected function getNow(): DateTimeImmutable
43 return new DateTimeImmutable();
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"];
88 if (!$progress->isRelevant()) {
91 $node_settings = $settings_repo->get($progress->getNodeId());
92 $completion_mode = $node_settings->getLPMode();
94 switch ($completion_mode) {
101 $achieved_points = $progress->getAchievedPointsOfChildren();
105 $progress = $progress->withCurrentAmountOfPoints($achieved_points);
108 $required_points = $progress->getAmountOfPoints();
109 $successful = ($achieved_points >= $required_points);
111 if ($successful && !$progress->isSuccessful()) {
112 $progress = $progress
114 ->withCompletion($completing_crs_id, $this->
getNow());
119 if (!$successful && $progress->isSuccessful()
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)
162 $cdate = $progress->getCompletionDate();
168 $period =
$settings->getQualificationPeriod();
169 $date =
$settings->getQualificationDate();
172 $date = $cdate->add(
new DateInterval(
'P' . $period .
'D'));
178 ->withInvalidated(!$validity);
185 $period =
$settings->getDeadlinePeriod();
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)) {
224 throw new Exception(
'no acting user.');
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(
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(
352 if ($pgs->isRelevant()) {
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 {
383 $err_collection->add(false,
'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
387 $err_collection->
add(
true,
'set_to_irrelevant', $this->getProgressIdString($pgs->
getNodeId()));
393 return $this->withProgressTree($zipper->getRoot());
405 $zipper = $zipper->modifyFocus(
406 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo):
ilPRGProgress {
408 $err_collection->add(false,
'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
414 $err_collection->add(false,
'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
418 $err_collection->add(false,
'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
425 $this->notifyScoreChange($pgs);
428 $settings = $settings_repo->get($pgs->getNodeId())->getValidityOfQualificationSettings();
429 $pgs = $this->updateProgressValidityFromSettings($settings, $pgs);
432 $this->notifyProgressSuccess($pgs);
433 $err_collection->
add(
true,
'status_changed', $this->getProgressIdString($pgs->
getNodeId()));
439 return $this->withProgressTree($zipper->getRoot());
451 $zipper = $zipper->modifyFocus(
452 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo):
ilPRGProgress {
454 $err_collection->add(false,
'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
460 $err_collection->add(false,
'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
467 $err_collection->add(false,
'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
474 $this->notifyScoreChange($pgs);
477 $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id);
479 $err_collection->add(false,
'status_changed_due_to_deadline', $this->getProgressIdString($pgs->getNodeId()));
481 $err_collection->add(true,
'status_changed', $this->getProgressIdString($pgs->getNodeId()));
483 $this->notifyProgressRevertSuccess($pgs);
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 {
512 foreach ($leafs as
$path) {
516 return $this->withProgressTree($zipper->getRoot());
523 int $triggering_obj_id
525 $zipper = $this->
getZipper($node_id)->modifyFocus(
527 $deadline = $pgs->getDeadline();
531 (is_null($deadline) || $deadline->format(
$format) >= $now->format(
$format))
533 $pgs = $pgs->
succeed($now, $triggering_obj_id)
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 {
569 $this->notifyProgressRevertSuccess($pgs);
570 return $pgs->
markFailed($this->getNow(), $acting_usr_id);
574 foreach ($touched as
$path) {
578 return $this->withProgressTree($zipper->getRoot());
586 ?DateTimeImmutable $deadline
588 $zipper = $this->
getZipper($node_id)->modifyFocus(
590 if (!$pgs->isRelevant()) {
600 ->withLastChange($acting_usr_id, $this->
getNow())
601 ->withIndividualModifications(
true);
612 return $this->withProgressTree($zipper->getRoot());
620 ?DateTimeImmutable $validity_date
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()) {
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(
658 if (!$pgs->isRelevant()) {
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(
698 foreach ($touched as
$path) {
702 return $this->withProgressTree($zipper->getRoot());
static return function(ContainerConfigurator $containerConfigurator)
static _lookupTargetId(int $a_obj_id)
static _lookupTargetRefId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupDeletedDate(int $ref_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
add(bool $success, string $message, string $record_identitifer)
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
getAchievedPointsOfChildren()
withValidityOfQualification(\DateTimeImmutable $date=null)
withCurrentAmountOfPoints(int $points_cur)
markFailed(\DateTimeImmutable $date, int $acting_usr_id)
markAccredited(\DateTimeImmutable $date, int $acting_usr_id)
hasValidQualification(\DateTimeImmutable $now)
There may be no qualification at all (since the PRG is not passed), or the qualification is valid or ...
withAmountOfPoints(int $points)
const COMPLETED_BY_SUBNODES
succeed(\DateTimeImmutable $date, int $triggering_obj_id)
isTransitionAllowedTo(int $new_status)
unmarkAccredited(\DateTimeImmutable $date, int $acting_usr_id)
withDeadline(?\DateTimeImmutable $deadline=null)
withAssignmentDate(?\DateTimeImmutable $assignment_date)
const STATUS_NOT_RELEVANT
getValidityOfQualification()
markRelevant(\DateTimeImmutable $date, int $acting_usr_id)
markNotFailed(\DateTimeImmutable $date, int $acting_usr_id)
markNotRelevant(\DateTimeImmutable $date, int $acting_usr_id)
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...
resetProgresses(ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id)
trait ilPRGAssignmentActions
This trait is for (physical) separation of code only; it is actually just part of an ilPRGAssignment ...
updateParentProgresses(ilStudyProgrammeSettingsRepository $settings_repo, Zipper $zipper)
notifyValidityChange(ilPRGProgress $pgs)
changeProgressValidityDate(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, ?DateTimeImmutable $validity_date)
getProgressIdString(int $node_id)
recalculateProgressStatus(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress)
markRelevant(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
unmarkAccredited(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
notifyScoreChange(ilPRGProgress $pgs)
notifyDeadlineChange(ilPRGProgress $pgs)
markNotRelevant(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
hasCompletedCourseChild(ilPRGProgress $pgs)
notifyProgressRevertSuccess(ilPRGProgress $pgs)
resetProgressToSettings(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs, int $acting_usr_id)
succeed(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $triggering_obj_id)
updatePlanFromRepository(ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id, ilPRGMessageCollection $err_collection)
getCourseReferencesInNode(int $node_obj_id)
updateProgressRelevanceFromSettings(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $pgs)
markAccredited(ilStudyProgrammeSettingsRepository $settings_repo, ilStudyProgrammeEvents $events, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection)
updateProgressValidityFromSettings(ilStudyProgrammeValidityOfAchievedQualificationSettings $settings, ilPRGProgress $progress)
markProgressesFailedForExpiredDeadline(ilStudyProgrammeSettingsRepository $settings_repo, int $acting_usr_id)
notifyProgressSuccess(ilPRGProgress $pgs)
changeProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, ?DateTimeImmutable $deadline)
applyProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, int $acting_usr_id=null, bool $recalculate=true)
changeAmountOfPoints(ilStudyProgrammeSettingsRepository $settings_repo, int $node_id, int $acting_usr_id, ilPRGMessageCollection $err_collection, int $points)
invalidate(ilStudyProgrammeSettingsRepository $settings_repo)
updateProgressDeadlineFromSettings(ilStudyProgrammeDeadlineSettings $settings, ilPRGProgress $progress)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(int $obj_id)
Load settings belonging to a SP-Object.
while(!file_exists( 'ilias.ini.php'))
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.