ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilStudyProgrammeUserProgress Class Reference

Represents the progress of a user at one node of a study programme. More...

+ Collaboration diagram for ilStudyProgrammeUserProgress:

Public Member Functions

 __construct (ilStudyProgrammeProgress $progress, ilStudyProgrammeProgressRepository $progress_repository, ilStudyProgrammeAssignmentRepository $assignment_repository, ilStudyProgrammeEvents $events)
 
 getStudyProgramme ()
 Get the program node this progress belongs to. More...
 
 getAssignmentId ()
 Get the assignment this progress belongs to. More...
 
 getId ()
 Get the id of the progress. More...
 
 getNodeId ()
 Get the id of the program node the progress belongs to. More...
 
 getUserId ()
 Get the id of the user who is assigned. More...
 
 getStatus ()
 Get the status of the progress. More...
 
 getAmountOfPoints ()
 Get the amount of points needed to complete the node. More...
 
 getCurrentAmountOfPoints ()
 Get the amount of points the user currently achieved. More...
 
 getLastChange ()
 Get the timestamp when the last change was made on this progress. More...
 
 getLastChangeBy ()
 Get the id of the user who did the last change on this progress. More...
 
 getCompletionBy ()
 Get the id of the user or course that lead to completion of this node. More...
 
 getAssignmentDate ()
 Get the assignment date of this node. More...
 
 getCompletionDate ()
 Get the completion date of this node. More...
 
 getDeadline ()
 Get the deadline of this node. More...
 
 setDeadline (DateTime $deadline=null)
 Set the deadline of this node. More...
 
 getValidityOfQualification ()
 Get validity of qualification. More...
 
 setValidityOfQualification (DateTime $date=null)
 Set validity of qualification. More...
 
 storeProgress ()
 
 delete ()
 Delete the assignment from database. More...
 
 markAccredited (int $user_id)
 Mark this progress as accredited. More...
 
 unmarkAccredited ()
 Set the node to in progress. More...
 
 markFailed (int $a_user_id)
 Mark this progress as failed. More...
 
 invalidate ()
 Mark this progress as failed. More...
 
 isInvalidated ()
 
 isSuccessfulExpired ()
 Check, whether a the course is passed and expired due to limited validity. More...
 
 markNotFailed (int $user_id)
 Set the node to in progress. More...
 
 markNotRelevant (int $user_id)
 Set the node to be not relevant for the user. More...
 
 markRelevant (int $user_id)
 Set the node to be relevant for the user. More...
 
 setRequiredAmountOfPoints (int $a_points, int $user_id)
 Set the amount of points the user is required to have to complete this node. More...
 
 getMaximumPossibleAmountOfPoints (bool $only_relevant=false)
 Get the maximum possible amount of points a user can achieve for the completion of this node. More...
 
 canBeCompleted ()
 Check whether the user can achieve enough points on the subnodes to be able to complete this node. More...
 
 hasIndividualModifications ()
 Check whether there are individual modifications for the user on this program. More...
 
 isSuccessful ()
 Check whether the user was successful on this node. More...
 
 isFailed ()
 Check whether user as failed on this node. More...
 
 recalculateFailedToDeadline ()
 Recalculates the status according to deadline. More...
 
 isAccredited ()
 Check whether the user was accredited on this node. More...
 
 isRelevant ()
 Check whether this node is relevant for the user. More...
 
 updateFromProgramNode ()
 Update the progress from its program node. More...
 
 setLPCompleted (int $obj_id, int $usr_id)
 Set this node to be completed due to a completed learning progress. More...
 
 getChildrenProgress ()
 Get the progresses on the child nodes of this node for the same assignment this progress belongs to. More...
 
 getNamesOfCompletedOrAccreditedChildren ()
 Get a list with the names of the children of this node that a were completed or accredited for the given assignment. More...
 
 updateProgress (int $user_id)
 Updates current progress. More...
 
 informUserForRiskToFail ()
 
 hasSuccessStatus ()
 

Static Public Member Functions

static getPossibleActions (int $node_id, int $root_prg_id, int $status)
 Get a list with possible actions on a progress record. More...
 

Data Fields

const ACTION_MARK_ACCREDITED = "mark_accredited"
 
const ACTION_UNMARK_ACCREDITED = "unmark_accredited"
 
const ACTION_SHOW_INDIVIDUAL_PLAN = "show_individual_plan"
 
const ACTION_REMOVE_USER = "remove_user"
 
const ACTION_CHANGE_EXPIRE_DATE = "change_expire_date"
 
const ACTION_CHANGE_DEADLINE = "change_deadline"
 

Protected Member Functions

 updateStatus ()
 Updates the status of this progress based on the status of the progress on the sub nodes. More...
 
 hasSuccessfullChildren ()
 
 updateParentStatus ()
 Update the status of the parent of this node. More...
 
 maybeLimitProgressValidity (ilObjStudyProgramme $prg, ilStudyProgrammeAssignment $assignment)
 
 getParentProgresses ()
 Get the progress on the parent node for the same assignment this progress belongs to. More...
 
 refreshLPStatus ()
 

Protected Attributes

 $progress
 
 $progress_repository
 
 $assignment_repository
 
 $events
 

Detailed Description

Represents the progress of a user at one node of a study programme.

A user could have multiple progress' on one node, since he could also have multiple assignments to one node.

Definition at line 14 of file class.ilStudyProgrammeUserProgress.php.

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeUserProgress::__construct ( ilStudyProgrammeProgress  $progress,
ilStudyProgrammeProgressRepository  $progress_repository,
ilStudyProgrammeAssignmentRepository  $assignment_repository,
ilStudyProgrammeEvents  $events 
)

Member Function Documentation

◆ canBeCompleted()

ilStudyProgrammeUserProgress::canBeCompleted ( )

Check whether the user can achieve enough points on the subnodes to be able to complete this node.

Exceptions
ilException

Definition at line 519 of file class.ilStudyProgrammeUserProgress.php.

519 : bool
520 {
521 $prg = $this->getStudyProgramme();
522
523 if ($prg->getLPMode() == ilStudyProgrammeSettings::MODE_LP_COMPLETED) {
524 return true;
525 }
526
527 if ($this->getMaximumPossibleAmountOfPoints(true) < $this->getAmountOfPoints()) {
528 // Fast track
529 return false;
530 }
531
532 $children_progress = $this->getChildrenProgress();
533 foreach ($children_progress as $progress) {
534 if ($progress->isRelevant() && !$progress->canBeCompleted()) {
535 return false;
536 }
537 }
538
539 return true;
540 }
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to.
getMaximumPossibleAmountOfPoints(bool $only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node.
getAmountOfPoints()
Get the amount of points needed to complete the node.
getStudyProgramme()
Get the program node this progress belongs to.

References ilStudyProgrammeSettings\MODE_LP_COMPLETED.

Referenced by ilStudyProgrammeIndividualPlanProgressListGUI\buildProgressStatus().

+ Here is the caller graph for this function:

◆ delete()

ilStudyProgrammeUserProgress::delete ( )

Delete the assignment from database.

Definition at line 224 of file class.ilStudyProgrammeUserProgress.php.

224 : void
225 {
226 $this->progress_repository->delete($this->progress);
227 }

◆ getAmountOfPoints()

ilStudyProgrammeUserProgress::getAmountOfPoints ( )

Get the amount of points needed to complete the node.

This is the amount of points yielded for the completion of the node above as well.

Definition at line 122 of file class.ilStudyProgrammeUserProgress.php.

122 : int
123 {
124 return $this->progress->getAmountOfPoints();
125 }

Referenced by ilStudyProgrammeProgressListGUI\buildProgressBar(), ilStudyProgrammeProgressListGUI\buildProgressStatus(), ilStudyProgrammeProgressListGUI\buildToolTip(), and getCurrentAmountOfPoints().

+ Here is the caller graph for this function:

◆ getAssignmentDate()

ilStudyProgrammeUserProgress::getAssignmentDate ( )

Get the assignment date of this node.

Definition at line 169 of file class.ilStudyProgrammeUserProgress.php.

169 : DateTime
170 {
171 return $this->progress->getAssignmentDate();
172 }

◆ getAssignmentId()

ilStudyProgrammeUserProgress::getAssignmentId ( )

Get the assignment this progress belongs to.

Definition at line 81 of file class.ilStudyProgrammeUserProgress.php.

81 : int
82 {
83 return $this->progress->getAssignmentId();
84 }

Referenced by markAccredited(), ilStudyProgrammeEvents\userRiskyToFail(), and ilStudyProgrammeEvents\userSuccessful().

+ Here is the caller graph for this function:

◆ getChildrenProgress()

ilStudyProgrammeUserProgress::getChildrenProgress ( )

Get the progresses on the child nodes of this node for the same assignment this progress belongs to.

Exceptions
ilException
Returns
ilStudyProgrammeUserProgress[]

Definition at line 859 of file class.ilStudyProgrammeUserProgress.php.

859 : array
860 {
861 $prg = $this->getStudyProgramme();
862 if ($prg->getLPMode() == ilStudyProgrammeSettings::MODE_LP_COMPLETED) {
863 throw new ilException(
864 "ilStudyProgrammeUserProgress::getChildrenProgress: "
865 . "There is some problem in the implementation. This "
866 . "method should only be callled for nodes in points "
867 . "mode."
868 );
869 }
870
871 $ass_id = $this->progress->getAssignmentId();
872
873 return array_map(function ($child) use ($ass_id) {
874 return $child->getProgressForAssignment($ass_id);
875 }, $prg->getChildren(true));
876 }
Base class for ILIAS Exception handling.

References ilObjStudyProgramme\getChildren(), ilObjStudyProgramme\getLPMode(), and ilStudyProgrammeSettings\MODE_LP_COMPLETED.

+ Here is the call graph for this function:

◆ getCompletionBy()

ilStudyProgrammeUserProgress::getCompletionBy ( )

Get the id of the user or course that lead to completion of this node.

Definition at line 161 of file class.ilStudyProgrammeUserProgress.php.

162 {
163 return $this->progress->getCompletionBy();
164 }

◆ getCompletionDate()

ilStudyProgrammeUserProgress::getCompletionDate ( )

Get the completion date of this node.

Definition at line 177 of file class.ilStudyProgrammeUserProgress.php.

177 : ?DateTime
178 {
179 return $this->progress->getCompletionDate();
180 }

◆ getCurrentAmountOfPoints()

ilStudyProgrammeUserProgress::getCurrentAmountOfPoints ( )

Get the amount of points the user currently achieved.

Definition at line 130 of file class.ilStudyProgrammeUserProgress.php.

130 : int
131 {
132 if (
133 $this->isAccredited() ||
134 ($this->isSuccessful() && $this->getStudyProgramme()->hasLPChildren())
135 ) {
136 return $this->getAmountOfPoints();
137 }
138
139 return $this->progress->getCurrentAmountOfPoints();
140 }
isAccredited()
Check whether the user was accredited on this node.
isSuccessful()
Check whether the user was successful on this node.

References getAmountOfPoints(), getStudyProgramme(), isAccredited(), and isSuccessful().

Referenced by ilStudyProgrammeProgressListGUI\buildProgressBar(), ilStudyProgrammeProgressListGUI\buildProgressStatus(), and ilStudyProgrammeProgressListGUI\buildToolTip().

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

◆ getDeadline()

ilStudyProgrammeUserProgress::getDeadline ( )

Get the deadline of this node.

Definition at line 185 of file class.ilStudyProgrammeUserProgress.php.

186 {
187 return $this->progress->getDeadline();
188 }

◆ getId()

ilStudyProgrammeUserProgress::getId ( )

Get the id of the progress.

Definition at line 89 of file class.ilStudyProgrammeUserProgress.php.

89 : int
90 {
91 return $this->progress->getId();
92 }

Referenced by ilStudyProgrammeProgressListGUI\buildProgressBar(), ilStudyProgrammeProgressListGUI\getTitleAndIconTarget(), ilObjStudyProgrammeIndividualPlanGUI\updateDeadline(), and ilStudyProgrammeEvents\userRiskyToFail().

+ Here is the caller graph for this function:

◆ getLastChange()

ilStudyProgrammeUserProgress::getLastChange ( )

Get the timestamp when the last change was made on this progress.

Definition at line 145 of file class.ilStudyProgrammeUserProgress.php.

145 : DateTime
146 {
147 return $this->progress->getLastChange();
148 }

◆ getLastChangeBy()

ilStudyProgrammeUserProgress::getLastChangeBy ( )

Get the id of the user who did the last change on this progress.

Definition at line 153 of file class.ilStudyProgrammeUserProgress.php.

153 : ?int
154 {
155 return $this->progress->getLastChangeBy();
156 }

◆ getMaximumPossibleAmountOfPoints()

ilStudyProgrammeUserProgress::getMaximumPossibleAmountOfPoints ( bool  $only_relevant = false)

Get the maximum possible amount of points a user can achieve for the completion of this node.

If the program node runs in LP-mode this will be equal getAmountOfPoints.

TODO: Maybe caching this value would be a good idea.

Exceptions
ilException

Definition at line 486 of file class.ilStudyProgrammeUserProgress.php.

486 : int
487 {
488 $prg = $this->getStudyProgramme();
489 if ($prg->getLPMode() == ilStudyProgrammeSettings::MODE_LP_COMPLETED) {
490 return $this->getAmountOfPoints();
491 }
492
493 $children = $prg->getChildren();
494 $ass = $this->progress->getAssignmentId();
495 $points = array_map(function ($child) use ($ass, $only_relevant) {
496 $relevant = $child->getProgressForAssignment($ass)->isRelevant();
497 if ($only_relevant) {
498 if ($relevant) {
499 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
500 } else {
501 return 0;
502 }
503 } else {
504 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
505 }
506 }, $children);
507
508 return array_reduce($points, function ($a, $b) {
509 return $a + $b;
510 }, 0);
511 }
isRelevant()
Check whether this node is relevant for the user.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, and ilStudyProgrammeSettings\MODE_LP_COMPLETED.

Referenced by ilStudyProgrammeProgressListGUI\buildProgressBar(), and ilStudyProgrammeProgressListGUI\buildProgressStatus().

+ Here is the caller graph for this function:

◆ getNamesOfCompletedOrAccreditedChildren()

ilStudyProgrammeUserProgress::getNamesOfCompletedOrAccreditedChildren ( )

Get a list with the names of the children of this node that a were completed or accredited for the given assignment.

Exceptions
ilException
Returns
string[]

Definition at line 885 of file class.ilStudyProgrammeUserProgress.php.

885 : array
886 {
887 $prg = $this->getStudyProgramme();
888 $children = $prg->getChildren(true);
889 $ass_id = $this->progress->getAssignmentId();
890 $names = array();
891
892 foreach ($children as $child) {
893 $prgrs = $child->getProgressForAssignment($ass_id);
894 if (!$prgrs->isSuccessful()) {
895 continue;
896 }
897 $names[] = $child->getTitle();
898 }
899
900 return $names;
901 }

References ilObjStudyProgramme\getChildren().

+ Here is the call graph for this function:

◆ getNodeId()

ilStudyProgrammeUserProgress::getNodeId ( )

Get the id of the program node the progress belongs to.

Definition at line 97 of file class.ilStudyProgrammeUserProgress.php.

97 : int
98 {
99 return $this->progress->getNodeId();
100 }

◆ getParentProgresses()

ilStudyProgrammeUserProgress::getParentProgresses ( )
protected

Get the progress on the parent node for the same assignment this progress belongs to.

Exceptions
ilException
Returns
ilStudyProgrammeUserProgress[]

Definition at line 826 of file class.ilStudyProgrammeUserProgress.php.

826 : array
827 {
828 if ($this->getStudyProgramme()->getId() == $this->assignment_repository->read($this->getAssignmentId())->getRootId()) {
829 return [];
830 }
831
832 $overall_parents = [];
833 $prg = $this->getStudyProgramme();
834 $parent = $prg->getParent();
835
836 if ($parent) {
837 $overall_parents[] = $parent;
838 }
839
840 foreach ($prg->getReferencesToSelf() as $ref) {
841 $overall_parents[] = $ref->getParent();
842 }
843
844 return array_map(
845 function ($parent) {
846 return $parent->getProgressForAssignment($this->progress->getAssignmentId());
847 },
848 $overall_parents
849 );
850 }

References ilObjStudyProgramme\getParent(), and ilObjStudyProgramme\getReferencesToSelf().

+ Here is the call graph for this function:

◆ getPossibleActions()

static ilStudyProgrammeUserProgress::getPossibleActions ( int  $node_id,
int  $root_prg_id,
int  $status 
)
static

Get a list with possible actions on a progress record.

Returns
string[]

Definition at line 908 of file class.ilStudyProgrammeUserProgress.php.

912 : array {
913 $actions = array();
914
915 if ($node_id == $root_prg_id) {
917 $actions[] = self::ACTION_REMOVE_USER;
918 }
919
923 $actions[] = self::ACTION_MARK_ACCREDITED;
924 }
925
926 return $actions;
927 }

Referenced by ilStudyProgrammeUserProgressTest\testPossibleActions().

+ Here is the caller graph for this function:

◆ getStatus()

ilStudyProgrammeUserProgress::getStatus ( )

Get the status of the progress.

Definition at line 113 of file class.ilStudyProgrammeUserProgress.php.

113 : int
114 {
115 return $this->progress->getStatus();
116 }

Referenced by invalidate(), markAccredited(), and markFailed().

+ Here is the caller graph for this function:

◆ getStudyProgramme()

ilStudyProgrammeUserProgress::getStudyProgramme ( )

Get the program node this progress belongs to.

Throws when the according program has no ref id.

TODO: I'm quite sure, this will profit from caching.

Exceptions
ilException

Definition at line 64 of file class.ilStudyProgrammeUserProgress.php.

65 {
66 $refs = ilObject::_getAllReferences($this->progress->getNodeId());
67 if (!count($refs)) {
68 throw new ilException(
69 "ilStudyProgrammeUserAssignment::getStudyProgramme: "
70 . "could not find ref_id for program '"
71 . $this->progress->getNodeId() . "'."
72 )
73 ;
74 }
75 return ilObjStudyProgramme::getInstanceByRefId(array_shift($refs));
76 }
static getInstanceByRefId($a_ref_id)
static _getAllReferences($a_id)
get all reference ids of object

References ilObject\_getAllReferences(), and ilObjStudyProgramme\getInstanceByRefId().

Referenced by ilStudyProgrammeProgressListGUI\buildProgressStatus(), getCurrentAmountOfPoints(), markAccredited(), ilStudyProgrammeExpandableProgressListGUI\shouldShowSubProgress(), and ilStudyProgrammeEvents\userSuccessful().

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

◆ getUserId()

ilStudyProgrammeUserProgress::getUserId ( )

Get the id of the user who is assigned.

Definition at line 105 of file class.ilStudyProgrammeUserProgress.php.

105 : int
106 {
107 return $this->progress->getUserId();
108 }

◆ getValidityOfQualification()

ilStudyProgrammeUserProgress::getValidityOfQualification ( )

Get validity of qualification.

Returns
DateTime | null

Definition at line 203 of file class.ilStudyProgrammeUserProgress.php.

203 : ?DateTime
204 {
205 return $this->progress->getValidityOfQualification();
206 }

Referenced by isSuccessfulExpired().

+ Here is the caller graph for this function:

◆ hasIndividualModifications()

ilStudyProgrammeUserProgress::hasIndividualModifications ( )

Check whether there are individual modifications for the user on this program.

Definition at line 545 of file class.ilStudyProgrammeUserProgress.php.

545 : bool
546 {
547 return $this->getLastChangeBy() !== null;
548 }
getLastChangeBy()
Get the id of the user who did the last change on this progress.

◆ hasSuccessfullChildren()

ilStudyProgrammeUserProgress::hasSuccessfullChildren ( )
protected
Exceptions
ilException

Definition at line 710 of file class.ilStudyProgrammeUserProgress.php.

710 : bool
711 {
712 foreach ($this->getChildrenProgress() as $child) {
713 if ($child->isSuccessful()) {
714 return true;
715 }
716 }
717
718 return false;
719 }

◆ hasSuccessStatus()

ilStudyProgrammeUserProgress::hasSuccessStatus ( )

◆ informUserForRiskToFail()

ilStudyProgrammeUserProgress::informUserForRiskToFail ( )

Definition at line 952 of file class.ilStudyProgrammeUserProgress.php.

952 : void
953 {
954 $this->events->userRiskyToFail($this);
955 }

◆ invalidate()

ilStudyProgrammeUserProgress::invalidate ( )

Mark this progress as failed.

Throws when status is not STATUS_COMPLETED, STATUS_ACCREDITED, STATUS_NOT_RELEVANT.

Exceptions
ilException

Definition at line 333 of file class.ilStudyProgrammeUserProgress.php.

334 {
335 $status = array(
339 );
340
341 if (in_array($this->getStatus(), $status) && !$this->isSuccessfulExpired()) {
342 throw new ilException("Can't mark as failed since program is passed.");
343 }
344
345 $this->progress_repository->update(
346 $this->progress->invalidate()
347 );
348
349 $this->refreshLPStatus();
350
351 return $this;
352 }
Represents the progress of a user at one node of a study programme.
isSuccessfulExpired()
Check, whether a the course is passed and expired due to limited validity.

References getStatus(), isSuccessfulExpired(), refreshLPStatus(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

+ Here is the call graph for this function:

◆ isAccredited()

ilStudyProgrammeUserProgress::isAccredited ( )

Check whether the user was accredited on this node.

Definition at line 598 of file class.ilStudyProgrammeUserProgress.php.

598 : bool
599 {
601 }

References ilStudyProgrammeProgress\STATUS_ACCREDITED.

Referenced by getCurrentAmountOfPoints().

+ Here is the caller graph for this function:

◆ isFailed()

ilStudyProgrammeUserProgress::isFailed ( )

Check whether user as failed on this node.

Definition at line 567 of file class.ilStudyProgrammeUserProgress.php.

567 : bool
568 {
569 $status = $this->getStatus();
570
572 }

References ilStudyProgrammeProgress\STATUS_FAILED.

◆ isInvalidated()

ilStudyProgrammeUserProgress::isInvalidated ( )

Definition at line 354 of file class.ilStudyProgrammeUserProgress.php.

354 : bool
355 {
356 return $this->progress->isInvalidated();
357 }

◆ isRelevant()

ilStudyProgrammeUserProgress::isRelevant ( )

Check whether this node is relevant for the user.

Definition at line 606 of file class.ilStudyProgrammeUserProgress.php.

606 : bool
607 {
609 }

References ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

Referenced by ilStudyProgrammeExpandableProgressListGUI\shouldShowSubProgress().

+ Here is the caller graph for this function:

◆ isSuccessful()

ilStudyProgrammeUserProgress::isSuccessful ( )

Check whether the user was successful on this node.

This is the case, when the node was accredited or completed.

Definition at line 554 of file class.ilStudyProgrammeUserProgress.php.

554 : bool
555 {
556 $status = $this->getStatus();
557
558 return
561 ;
562 }

References ilStudyProgrammeProgress\STATUS_ACCREDITED, and ilStudyProgrammeProgress\STATUS_COMPLETED.

Referenced by ilStudyProgrammeProgressListGUI\buildProgressBar(), ilStudyProgrammeIndividualPlanProgressListGUI\buildProgressStatus(), getCurrentAmountOfPoints(), and isSuccessfulExpired().

+ Here is the caller graph for this function:

◆ isSuccessfulExpired()

ilStudyProgrammeUserProgress::isSuccessfulExpired ( )

Check, whether a the course is passed and expired due to limited validity.

Definition at line 362 of file class.ilStudyProgrammeUserProgress.php.

362 : bool
363 {
364 if ($this->getValidityOfQualification() === null) {
365 return false;
366 }
367
368 if (!$this->isSuccessful()) {
369 return false;
370 }
371
372 if (
373 $this->getValidityOfQualification()->format('Y-m-d') < (new DateTime())->format('Y-m-d')
374 ) {
375 return true;
376 }
377
378 return false;
379 }
getValidityOfQualification()
Get validity of qualification.

References getValidityOfQualification(), and isSuccessful().

Referenced by invalidate().

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

◆ markAccredited()

ilStudyProgrammeUserProgress::markAccredited ( int  $user_id)

Mark this progress as accredited.

Throws when status is not IN_PROGRESS. Throws when program node is outdated and current status is NOT_RELEVANT.

Exceptions
ilException

Definition at line 238 of file class.ilStudyProgrammeUserProgress.php.

239 {
240 $prg = $this->getStudyProgramme();
242 if ($prg->getStatus() == ilStudyProgrammeSettings::STATUS_OUTDATED) {
243 throw new ilException(
244 "ilStudyProgrammeUserProgress::markAccredited: "
245 . "Can't mark as accredited since program is outdated."
246 );
247 }
248 }
249 $progress = $this->progress
251 ->setCompletionBy($user_id)
252 ->setLastChangeBy($user_id)
253 ->setLastChange(new DateTime())
254 ->setCompletionDate(new DateTime())
255 ;
256
257 $this->progress_repository->update($progress);
258
259 $assignment = $this->assignment_repository->read($this->getAssignmentId());
260 if ((int) $prg->getId() === $assignment->getRootId()) {
261 $this->maybeLimitProgressValidity($prg, $assignment);
262 }
263
264 $this->events->userSuccessful($this);
265 $this->updateParentStatus();
266
267 return $this;
268 }
getAssignmentId()
Get the assignment this progress belongs to.
maybeLimitProgressValidity(ilObjStudyProgramme $prg, ilStudyProgrammeAssignment $assignment)
updateParentStatus()
Update the status of the parent of this node.

References $progress, getAssignmentId(), getStatus(), getStudyProgramme(), maybeLimitProgressValidity(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, ilStudyProgrammeSettings\STATUS_OUTDATED, and updateParentStatus().

+ Here is the call graph for this function:

◆ markFailed()

ilStudyProgrammeUserProgress::markFailed ( int  $a_user_id)

Mark this progress as failed.

Throws when status is not STATUS_COMPLETED, STATUS_ACCREDITED, STATUS_NOT_RELEVANT.

Exceptions
ilException

Definition at line 303 of file class.ilStudyProgrammeUserProgress.php.

304 {
305 $status = array(
309 );
310
311 if (in_array($this->getStatus(), $status)) {
312 throw new ilException("Can't mark as failed since program is passed.");
313 }
314
315 $this->progress
317 ->setLastChangeBy($a_user_id)
318 ->setCompletionDate(null);
319
320 $this->progress_repository->update($this->progress);
321 $this->refreshLPStatus();
322
323 return $this;
324 }

References getStatus(), refreshLPStatus(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_FAILED, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

+ Here is the call graph for this function:

◆ markNotFailed()

ilStudyProgrammeUserProgress::markNotFailed ( int  $user_id)

Set the node to in progress.

Throws when status is not FAILED.

Exceptions
ilException

Definition at line 388 of file class.ilStudyProgrammeUserProgress.php.

389 {
390 if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_FAILED) {
391 throw new ilException("Expected status FAILED.");
392 }
393
394 $this->progress_repository->update(
395 $this->progress
397 ->setCompletionBy(null)
398 ->setLastChangeBy($user_id)
399 );
400
401 $this->refreshLPStatus();
402
403 return $this;
404 }

References refreshLPStatus(), ilStudyProgrammeProgress\STATUS_FAILED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

+ Here is the call graph for this function:

◆ markNotRelevant()

ilStudyProgrammeUserProgress::markNotRelevant ( int  $user_id)

Set the node to be not relevant for the user.

Throws when status is COMPLETED.

Exceptions
ilException
Parameters
int$user_idThe user who marks the node as not relevant.
Returns
$this

Definition at line 415 of file class.ilStudyProgrammeUserProgress.php.

416 {
417 $this->progress_repository->update(
418 $this->progress
420 ->setCompletionBy($user_id)
421 ->setLastChangeBy($user_id)
422 );
423
424 $this->updateStatus();
425
426 return $this;
427 }
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes.

References ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and updateStatus().

+ Here is the call graph for this function:

◆ markRelevant()

ilStudyProgrammeUserProgress::markRelevant ( int  $user_id)

Set the node to be relevant for the user.

Throws when status is not NOT_RELEVANT.

Exceptions
ilException

Definition at line 436 of file class.ilStudyProgrammeUserProgress.php.

437 {
438 if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_NOT_RELEVANT) {
439 throw new ilException("Expected status IN_PROGRESS.");
440 }
441
442 $this->progress_repository->update(
443 $this->progress
445 ->setCompletionBy($user_id)
446 ->setLastChangeBy($user_id)
447 );
448
449 $this->updateStatus();
450
451 return $this;
452 }

References ilStudyProgrammeProgress\STATUS_IN_PROGRESS, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and updateStatus().

+ Here is the call graph for this function:

◆ maybeLimitProgressValidity()

ilStudyProgrammeUserProgress::maybeLimitProgressValidity ( ilObjStudyProgramme  $prg,
ilStudyProgrammeAssignment  $assignment 
)
protected
Exceptions
Exception

Definition at line 792 of file class.ilStudyProgrammeUserProgress.php.

795 : void {
796 $qualification_date = $prg->getValidityOfQualificationSettings()->getQualificationDate();
797 $qualification_period = $prg->getValidityOfQualificationSettings()->getQualificationPeriod();
798 if (!is_null($qualification_date)) {
799 $date = $qualification_date;
800 } elseif (
802 ) {
803 $date = new DateTime();
804 $date->add(new DateInterval('P' . $qualification_period . 'D'));
805 } else {
806 // nothing to do
807 return;
808 }
809
810 $this->progress_repository->update($this->progress->setValidityOfQualification($date));
811
812 $restart_period = $prg->getValidityOfQualificationSettings()->getRestartPeriod();
813 if (ilStudyProgrammeSettings::NO_RESTART !== $restart_period) {
814 $date->sub(new DateInterval('P' . $restart_period . 'D'));
815 $this->assignment_repository->update($assignment->setRestartDate($date));
816 }
817 }
setRestartDate(DateTime $date=null)
Set the date, at which the user is to be reassigned to the programme.

Referenced by markAccredited().

+ Here is the caller graph for this function:

◆ recalculateFailedToDeadline()

ilStudyProgrammeUserProgress::recalculateFailedToDeadline ( )

Recalculates the status according to deadline.

Exceptions
ilException

Definition at line 579 of file class.ilStudyProgrammeUserProgress.php.

579 : void
580 {
581 $deadline = $this->getDeadline();
583
584 if ($deadline
585 && $deadline->format(ilStudyProgrammeProgress::DATE_FORMAT) < $today
586 && $this->progress->getStatus() === ilStudyProgrammeProgress::STATUS_IN_PROGRESS
587 ) {
588 $this->progress_repository->update(
589 $this->progress
591 );
592 }
593 }
getDeadline()
Get the deadline of this node.

References ilStudyProgrammeProgress\DATE_FORMAT, ilStudyProgrammeProgress\STATUS_FAILED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

◆ refreshLPStatus()

ilStudyProgrammeUserProgress::refreshLPStatus ( )
protected

Definition at line 929 of file class.ilStudyProgrammeUserProgress.php.

929 : void
930 {
931 // thanks to some caching within ilLPStatusWrapper
932 // the status may not be read properly otherwise ...
933 ilLPStatusWrapper::_resetInfoCaches($this->progress->getNodeId());
935 $this->getStudyProgramme()->getId(),
936 array($this->getUserId())
937 );
938 }
static _resetInfoCaches($a_obj_id)
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
getUserId()
Get the id of the user who is assigned.

References ilLPStatusWrapper\_refreshStatus(), and ilLPStatusWrapper\_resetInfoCaches().

Referenced by invalidate(), markFailed(), markNotFailed(), and unmarkAccredited().

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

◆ setDeadline()

ilStudyProgrammeUserProgress::setDeadline ( DateTime  $deadline = null)

Set the deadline of this node.

Definition at line 193 of file class.ilStudyProgrammeUserProgress.php.

194 {
195 return $this->progress->setDeadline($deadline);
196 }
Class ilStudyProgrammeProgress.
setDeadline(DateTime $deadline=null)
Set the deadline of this progress.

References ilStudyProgrammeProgress\setDeadline().

Referenced by ilObjStudyProgrammeIndividualPlanGUI\updateDeadline().

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

◆ setLPCompleted()

ilStudyProgrammeUserProgress::setLPCompleted ( int  $obj_id,
int  $usr_id 
)

Set this node to be completed due to a completed learning progress.

Will only set the progress if this node is relevant and not successful.

Throws when this node is not in LP-Mode. Throws when object that was completed is no child of the node or user does not belong to this progress.

Exceptions
ilException
Returns
bool | void

Definition at line 742 of file class.ilStudyProgrammeUserProgress.php.

743 {
744 if ($this->isSuccessful() || !$this->isRelevant()) {
745 return true;
746 }
747
748 $prg = $this->getStudyProgramme();
749 if ($prg->getLPMode() != ilStudyProgrammeSettings::MODE_LP_COMPLETED) {
750 throw new ilException(
751 "ilStudyProgrammeUserProgress::setLPCompleted: "
752 . "The node '" . $prg->getId() . "' is not in LP_COMPLETED mode."
753 );
754 }
755
756 if ($this->getUserId() != $usr_id) {
757 throw new ilException(
758 "ilStudyProgrammeUserProgress::setLPCompleted: "
759 . "This progress does belong to user '" . $this->getUserId()
760 . "' and not to user '$usr_id'"
761 );
762 }
763
764 if (!in_array($obj_id, $prg->getLPChildrenIds())) {
765 throw new ilException(
766 "ilStudyProgrammeUserProgress::setLPCompleted: "
767 . "Object '$obj_id' is no child of node '" . $prg->getId() . "'."
768 );
769 }
770
771 $this->progress_repository->update(
772 $this->progress
774 ->setCompletionBy($obj_id)
775 ->setCompletionDate(new DateTime())
776 );
777
778 $this->refreshLPStatus();
779
780 $assignment = $this->assignment_repository->read($this->getAssignmentId());
781 if ((int) $prg->getId() === $assignment->getRootId()) {
782 $this->maybeLimitProgressValidity($prg, $assignment);
783 }
784
785 $this->events->userSuccessful($this);
786 $this->updateParentStatus();
787 }

References ilStudyProgrammeSettings\MODE_LP_COMPLETED, and ilStudyProgrammeProgress\STATUS_COMPLETED.

◆ setRequiredAmountOfPoints()

ilStudyProgrammeUserProgress::setRequiredAmountOfPoints ( int  $a_points,
int  $user_id 
)

Set the amount of points the user is required to have to complete this node.

Throws when status is completed.

Exceptions
ilException

Definition at line 461 of file class.ilStudyProgrammeUserProgress.php.

465 $this->progress_repository->update(
466 $this->progress
467 ->setAmountOfPoints($a_points)
468 ->setLastChangeBy($user_id)
469 );
470
471 $this->updateStatus();
472
473 return $this;
474 }

◆ setValidityOfQualification()

ilStudyProgrammeUserProgress::setValidityOfQualification ( DateTime  $date = null)

Set validity of qualification.

Definition at line 211 of file class.ilStudyProgrammeUserProgress.php.

211 : void
212 {
213 $this->progress->setValidityOfQualification($date);
214 }

◆ storeProgress()

ilStudyProgrammeUserProgress::storeProgress ( )

Definition at line 216 of file class.ilStudyProgrammeUserProgress.php.

216 : void
217 {
218 $this->progress_repository->update($this->progress);
219 }

◆ unmarkAccredited()

ilStudyProgrammeUserProgress::unmarkAccredited ( )

Set the node to in progress.

Throws when status is not ACCREDITED.

Exceptions
ilException

Definition at line 277 of file class.ilStudyProgrammeUserProgress.php.

278 {
279 if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_ACCREDITED) {
280 throw new ilException("Expected status ACCREDITED.");
281 }
282
283 $this->progress_repository->update(
284 $this->progress
286 ->setCompletionBy(null)
287 ->setCompletionDate(null)
288 );
289
290 $this->refreshLPStatus();
291 $this->updateParentStatus();
292
293 return $this;
294 }

References refreshLPStatus(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and updateParentStatus().

+ Here is the call graph for this function:

◆ updateFromProgramNode()

ilStudyProgrammeUserProgress::updateFromProgramNode ( )

Update the progress from its program node.

Will only update when the node does not have individual modifications and is not completed. Return false, when update could not be performed and true otherwise.

Exceptions
ilException
Returns
bool | void

Definition at line 619 of file class.ilStudyProgrammeUserProgress.php.

620 {
621 if ($this->hasIndividualModifications()) {
622 return false;
623 }
624
626 return false;
627 }
628
629 $prg = $this->getStudyProgramme();
630
632 if ($prg->getStatus() == ilStudyProgrammeSettings::STATUS_ACTIVE) {
634 }
635
636 $this->progress_repository->update(
637 $this->progress
638 ->setAmountOfPoints($prg->getPoints())
639 ->setStatus($status)
640 );
641
642 $this->updateStatus();
643 }
hasIndividualModifications()
Check whether there are individual modifications for the user on this program.

References ilStudyProgrammeSettings\STATUS_ACTIVE, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

◆ updateParentStatus()

ilStudyProgrammeUserProgress::updateParentStatus ( )
protected

Update the status of the parent of this node.

Definition at line 724 of file class.ilStudyProgrammeUserProgress.php.

724 : void
725 {
726 foreach ($this->getParentProgresses() as $parent) {
727 $parent->updateStatus();
728 }
729 }
getParentProgresses()
Get the progress on the parent node for the same assignment this progress belongs to.

Referenced by markAccredited(), and unmarkAccredited().

+ Here is the caller graph for this function:

◆ updateProgress()

ilStudyProgrammeUserProgress::updateProgress ( int  $user_id)

Updates current progress.

Exceptions
ilException

Definition at line 945 of file class.ilStudyProgrammeUserProgress.php.

945 : void
946 {
947 $this->progress_repository->update(
948 $this->progress->setLastChangeBy($user_id)
949 );
950 }

Referenced by ilObjStudyProgrammeIndividualPlanGUI\updateDeadline().

+ Here is the caller graph for this function:

◆ updateStatus()

ilStudyProgrammeUserProgress::updateStatus ( )
protected

Updates the status of this progress based on the status of the progress on the sub nodes.

Then update the status of the parent.

Exceptions
ilException
Returns
int | void

Definition at line 652 of file class.ilStudyProgrammeUserProgress.php.

653 {
654 $prg = $this->getStudyProgramme();
655 if (
656 ($prg->getLPMode() == ilStudyProgrammeSettings::MODE_LP_COMPLETED &&
657 $this->getStatus() != ilStudyProgrammeProgress::STATUS_ACCREDITED) ||
659 ) {
660 // Nothing to do here, as the status will be set by LP.
661 // OR current status is NOT RELEVANT
662 return;
663 }
664
665 $add = function ($a, $b) {
666 return $a + $b;
667 };
668 $get_points = function ($child) {
669 if (!$child->isSuccessful()) {
670 return 0;
671 }
672 return $child->getAmountOfPoints();
673 };
674
675 $achieved_points = array_reduce(array_map($get_points, $this->getChildrenProgress()), $add);
676 if (!$achieved_points) {
677 $achieved_points = 0;
678 }
679
680 $successful = $achieved_points >= $this->getAmountOfPoints() && $this->hasSuccessfullChildren();
681 $this->progress->setCurrentAmountOfPoints($achieved_points);
682
683 if ($successful) {
684 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_COMPLETED);
685 if (!$this->progress->getCompletionDate()) {
686 $this->progress->setCompletionDate(new DateTime());
687 }
688
689 $assignment = $this->assignment_repository->read($this->getAssignmentId());
690 if ((int) $prg->getId() === $assignment->getRootId()) {
691 $this->maybeLimitProgressValidity($prg, $assignment);
692 }
693 $this->events->userSuccessful($this);
694 } else {
695 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_IN_PROGRESS);
696 $this->progress->setCompletionDate(null);
697 }
698
699 $this->progress_repository->update(
700 $this->progress
701 );
702
703 $this->refreshLPStatus();
704 $this->updateParentStatus();
705 }

References Vendor\Package\$a, Vendor\Package\$b, ilStudyProgrammeSettings\MODE_LP_COMPLETED, ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

Referenced by markNotRelevant(), and markRelevant().

+ Here is the caller graph for this function:

Field Documentation

◆ $assignment_repository

ilStudyProgrammeUserProgress::$assignment_repository
protected

Definition at line 36 of file class.ilStudyProgrammeUserProgress.php.

Referenced by __construct().

◆ $events

ilStudyProgrammeUserProgress::$events
protected

Definition at line 41 of file class.ilStudyProgrammeUserProgress.php.

Referenced by __construct().

◆ $progress

ilStudyProgrammeUserProgress::$progress
protected

Definition at line 26 of file class.ilStudyProgrammeUserProgress.php.

Referenced by __construct(), and markAccredited().

◆ $progress_repository

ilStudyProgrammeUserProgress::$progress_repository
protected

Definition at line 31 of file class.ilStudyProgrammeUserProgress.php.

Referenced by __construct().

◆ ACTION_CHANGE_DEADLINE

const ilStudyProgrammeUserProgress::ACTION_CHANGE_DEADLINE = "change_deadline"

Definition at line 21 of file class.ilStudyProgrammeUserProgress.php.

◆ ACTION_CHANGE_EXPIRE_DATE

const ilStudyProgrammeUserProgress::ACTION_CHANGE_EXPIRE_DATE = "change_expire_date"

Definition at line 20 of file class.ilStudyProgrammeUserProgress.php.

◆ ACTION_MARK_ACCREDITED

const ilStudyProgrammeUserProgress::ACTION_MARK_ACCREDITED = "mark_accredited"

◆ ACTION_REMOVE_USER

const ilStudyProgrammeUserProgress::ACTION_REMOVE_USER = "remove_user"

◆ ACTION_SHOW_INDIVIDUAL_PLAN

const ilStudyProgrammeUserProgress::ACTION_SHOW_INDIVIDUAL_PLAN = "show_individual_plan"

◆ ACTION_UNMARK_ACCREDITED

const ilStudyProgrammeUserProgress::ACTION_UNMARK_ACCREDITED = "unmark_accredited"

The documentation for this class was generated from the following file: