19declare(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);
59 if (!$progress->isRelevant()) {
62 $node_settings = $settings_repo->get($progress->getNodeId());
63 $completion_mode = $node_settings->getLPMode();
65 switch ($completion_mode) {
72 $achieved_points = $progress->getAchievedPointsOfChildren();
76 $progress = $progress->withCurrentAmountOfPoints($achieved_points);
79 $required_points = $progress->getAmountOfPoints();
80 $successful = ($achieved_points >= $required_points);
82 if ($successful && !$progress->isSuccessful()) {
85 ->withCompletion($completing_crs_id, $this->
getNow());
87 if (!$progress->getValidityOfQualification()) {
88 $settings = $settings_repo->get($progress->getNodeId())->getValidityOfQualificationSettings();
94 if (!$successful && $progress->isSuccessful()
99 ->withCompletion(
null,
null)
100 ->withValidityOfQualification(
null);
113 while (!$zipper->isTop()) {
116 function ($pgs) use ($settings_repo) {
119 $deadline = $pgs->getDeadline();
120 if (!is_null($deadline)
121 && $deadline->format($format) <= $today->format($format)
136 $cdate = $progress->getCompletionDate();
146 $date = $cdate->add(
new DateInterval(
'P' . $period .
'D'));
152 ->withInvalidated(!$validity);
159 $period = $settings->getDeadlinePeriod();
164 $date = $date->add(
new DateInterval(
'P' . $period .
'D'));
174 $programme_status = $settings_repo->
get($pgs->getNodeId())->getAssessmentSettings()->getStatus();
190 ?
int $acting_usr_id =
null,
191 bool $recalculate =
true
197 if (is_null($acting_usr_id)) {
198 throw new Exception(
'no acting user.');
199 $acting_usr_id = $this->getLoggedInUserId();
204 if (!is_null($deadline)
205 && $deadline->format($format) < $today->format($format)
210 $node_settings = $settings_repo->
get($progress->
getNodeId());
211 $completion_mode = $node_settings->getLPMode();
219 if (is_null($deadline)
220 || $deadline->format($format) >= $today->format($format)
237 $settings = $settings_repo->
get($pgs->getNodeId());
244 ->withDeadline(
null);
250 ->withLastChange($acting_usr_id, $this->
getNow())
251 ->withIndividualModifications(
false);
267 $progress_path = $this->getProgressForNode($node_id)->getPath();
268 $zipper =
new Zipper($this->getProgressTree());
269 return $zipper = $zipper->toPath($progress_path);
274 $this->getEvents()->userSuccessful($this, $pgs->
getNodeId());
278 $this->getEvents()->validityChange($this, $pgs->
getNodeId());
282 $this->getEvents()->deadlineChange($this, $pgs->
getNodeId());
286 $this->getEvents()->scoreChange($this, $pgs->
getNodeId());
290 $this->getEvents()->userRevertSuccessful($this, $pgs->
getNodeId());
295 $zipper = $this->
getZipper($this->getRootId());
296 $zipper = $zipper->modifyAll(
299 return $this->withProgressTree($zipper->getRoot());
306 $zipper = $this->
getZipper($this->getRootId());
307 $zipper = $zipper->modifyAll(
308 function ($pgs) use ($acting_usr_id, $settings_repo):
ilPRGProgress {
314 return $this->withProgressTree($zipper->getRoot());
323 $zipper = $this->
getZipper($node_id)->modifyFocus(
324 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo):
ilPRGProgress {
325 if ($pgs->isRelevant()) {
337 return $this->withProgressTree($zipper->getRoot());
348 if ($zipper->isTop()) {
349 $err_collection->
add(
false,
'will_not_set_top_progress_to_irrelevant', $this->
getProgressIdString($node_id));
353 $zipper = $zipper->modifyFocus(
354 function ($pgs) use ($err_collection, $acting_usr_id):
ilPRGProgress {
356 $err_collection->add(false,
'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
360 $err_collection->add(false,
'will_not_modify_successful_progress', $this->getProgressIdString($pgs->getNodeId()));
365 $err_collection->
add(
true,
'set_to_irrelevant', $this->getProgressIdString($pgs->
getNodeId()));
371 return $this->withProgressTree($zipper->getRoot());
383 $zipper = $zipper->modifyFocus(
384 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo):
ilPRGProgress {
386 $err_collection->add(false,
'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
392 $err_collection->add(false,
'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
396 $err_collection->add(false,
'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
403 $this->notifyScoreChange($pgs);
406 $settings = $settings_repo->get($pgs->getNodeId())->getValidityOfQualificationSettings();
407 $pgs = $this->updateProgressValidityFromSettings($settings, $pgs);
410 $this->notifyProgressSuccess($pgs);
411 $err_collection->
add(
true,
'status_changed', $this->getProgressIdString($pgs->
getNodeId()));
417 return $this->withProgressTree($zipper->getRoot());
429 $zipper = $zipper->modifyFocus(
430 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo):
ilPRGProgress {
432 $err_collection->add(false,
'will_not_modify_irrelevant_progress', $this->getProgressIdString($pgs->getNodeId()));
438 $err_collection->add(false,
'status_unchanged', $this->getProgressIdString($pgs->getNodeId()));
445 $err_collection->add(false,
'status_transition_not_allowed', $this->getProgressIdString($pgs->getNodeId()));
452 $this->notifyScoreChange($pgs);
455 $pgs = $this->applyProgressDeadline($settings_repo, $pgs, $acting_usr_id);
457 $err_collection->add(false,
'status_changed_due_to_deadline', $this->getProgressIdString($pgs->getNodeId()));
459 $err_collection->add(true,
'status_changed', $this->getProgressIdString($pgs->getNodeId()));
461 $this->notifyProgressRevertSuccess($pgs);
467 return $this->withProgressTree($zipper->getRoot());
475 $zipper = $this->
getZipper($this->getRootId());
477 $zipper = $zipper->modifyAll(
478 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, &$leafs):
ilPRGProgress {
489 foreach ($leafs as
$path) {
492 return $this->withProgressTree($zipper->getRoot());
498 int $triggering_obj_id
500 $zipper = $this->
getZipper($node_id)->modifyFocus(
501 function ($pgs) use ($settings_repo, $triggering_obj_id):
ilPRGProgress {
502 $deadline = $pgs->getDeadline();
506 (is_null($deadline) || $deadline->format($format) >= $now->format($format))
508 $pgs = $pgs->
succeed($now, $triggering_obj_id)
511 $settings = $settings_repo->
get($pgs->
getNodeId())->getValidityOfQualificationSettings();
521 return $this->withProgressTree($zipper->getRoot());
529 $zipper = $this->
getZipper($this->getRootId());
532 $deadline = $this->
getNow();
533 $zipper = $zipper->modifyAll(
534 function ($pgs) use ($acting_usr_id, $deadline, &$touched):
ilPRGProgress {
543 $this->notifyProgressRevertSuccess($pgs);
544 return $pgs->
markFailed($this->getNow(), $acting_usr_id);
548 foreach ($touched as
$path) {
552 return $this->withProgressTree($zipper->getRoot());
560 ?DateTimeImmutable $deadline
562 $zipper = $this->
getZipper($node_id)->modifyFocus(
563 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $deadline):
ilPRGProgress {
564 if (!$pgs->isRelevant()) {
574 ->withLastChange($acting_usr_id, $this->
getNow())
575 ->withIndividualModifications(
true);
586 return $this->withProgressTree($zipper->getRoot());
594 ?DateTimeImmutable $validity_date
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()) {
609 ->withLastChange($acting_usr_id, $this->
getNow())
610 ->withIndividualModifications(
true)
611 ->withInvalidated(!$validity);
620 return $this->withProgressTree($zipper->getRoot());
630 $zipper = $this->
getZipper($node_id)->modifyFocus(
631 function ($pgs) use ($err_collection, $acting_usr_id, $settings_repo, $points):
ilPRGProgress {
632 if (!$pgs->isRelevant()) {
642 ->withLastChange($acting_usr_id, $this->
getNow())
643 ->withIndividualModifications(
true);
652 return $this->withProgressTree($zipper->getRoot());
658 $zipper = $this->
getZipper($this->getRootId());
662 $zipper = $zipper->modifyAll(
672 foreach ($touched as
$path) {
676 return $this->withProgressTree($zipper->getRoot());
Base class for ILIAS Exception handling.
static _getAllReferences(int $id)
get all reference ids for object ID
Holds information about multi-actions, mainly in context of member-assignemnts and status changes.
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()
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)
withValidityOfQualification(?\DateTimeImmutable $date=null)
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)
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)
applyProgressDeadline(ilStudyProgrammeSettingsRepository $settings_repo, ilPRGProgress $progress, ?int $acting_usr_id=null, bool $recalculate=true)
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)
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)
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)
Covers the persistence of settings belonging to a study programme (SP).
get(int $obj_id)
Load settings belonging to a SP-Object.
if(!file_exists('../ilias.ini.php'))