6declare(strict_types=1);
69 "ilStudyProgrammeUserAssignment::getStudyProgramme: "
70 .
"could not find ref_id for program '"
71 . $this->progress->getNodeId() .
"'."
83 return $this->progress->getAssignmentId();
91 return $this->progress->getId();
99 return $this->progress->getNodeId();
107 return $this->progress->getUserId();
115 return $this->progress->getStatus();
124 return $this->progress->getAmountOfPoints();
139 return $this->progress->getCurrentAmountOfPoints();
147 return $this->progress->getLastChange();
155 return $this->progress->getLastChangeBy();
163 return $this->progress->getCompletionBy();
171 return $this->progress->getAssignmentDate();
179 return $this->progress->getCompletionDate();
187 return $this->progress->getDeadline();
205 return $this->progress->getValidityOfQualification();
213 $this->progress->setValidityOfQualification($date);
218 $this->progress_repository->update($this->progress);
224 public function delete() :
void
226 $this->progress_repository->delete($this->progress);
244 "ilStudyProgrammeUserProgress::markAccredited: "
245 .
"Can't mark as accredited since program is outdated."
251 ->setCompletionBy($user_id)
252 ->setLastChangeBy($user_id)
253 ->setLastChange(
new DateTime())
254 ->setCompletionDate(
new DateTime())
257 $this->progress_repository->update(
$progress);
259 $assignment = $this->assignment_repository->read($this->
getAssignmentId());
260 if ((
int) $prg->getId() === $assignment->getRootId()) {
264 $this->events->userSuccessful($this);
280 throw new ilException(
"Expected status ACCREDITED.");
283 $this->progress_repository->update(
286 ->setCompletionBy(
null)
287 ->setCompletionDate(
null)
311 if (in_array($this->
getStatus(), $status)) {
312 throw new ilException(
"Can't mark as failed since program is passed.");
317 ->setLastChangeBy($a_user_id)
318 ->setCompletionDate(
null);
320 $this->progress_repository->update($this->progress);
342 throw new ilException(
"Can't mark as failed since program is passed.");
345 $this->progress_repository->update(
346 $this->progress->invalidate()
356 return $this->progress->isInvalidated();
394 $this->progress_repository->update(
397 ->setCompletionBy(
null)
398 ->setLastChangeBy($user_id)
417 $this->progress_repository->update(
420 ->setCompletionBy($user_id)
421 ->setLastChangeBy($user_id)
439 throw new ilException(
"Expected status IN_PROGRESS.");
442 $this->progress_repository->update(
445 ->setCompletionBy($user_id)
446 ->setLastChangeBy($user_id)
465 $this->progress_repository->update(
467 ->setAmountOfPoints($a_points)
468 ->setLastChangeBy($user_id)
488 $prg = $this->getStudyProgramme();
490 return $this->getAmountOfPoints();
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) {
499 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
504 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
508 return array_reduce($points,
function (
$a,
$b) {
521 $prg = $this->getStudyProgramme();
527 if ($this->getMaximumPossibleAmountOfPoints(
true) < $this->getAmountOfPoints()) {
532 $children_progress = $this->getChildrenProgress();
533 foreach ($children_progress as $progress) {
534 if ($progress->isRelevant() && !$progress->canBeCompleted()) {
547 return $this->getLastChangeBy() !==
null;
556 $status = $this->getStatus();
569 $status = $this->getStatus();
581 $deadline = $this->getDeadline();
588 $this->progress_repository->update(
621 if ($this->hasIndividualModifications()) {
629 $prg = $this->getStudyProgramme();
636 $this->progress_repository->update(
638 ->setAmountOfPoints($prg->getPoints())
642 $this->updateStatus();
654 $prg = $this->getStudyProgramme();
665 $add =
function (
$a,
$b) {
668 $get_points =
function ($child) {
669 if (!$child->isSuccessful()) {
672 return $child->getAmountOfPoints();
675 $achieved_points = array_reduce(array_map($get_points, $this->getChildrenProgress()), $add);
676 if (!$achieved_points) {
677 $achieved_points = 0;
680 $successful = $achieved_points >= $this->getAmountOfPoints() && $this->hasSuccessfullChildren();
681 $this->progress->setCurrentAmountOfPoints($achieved_points);
685 if (!$this->progress->getCompletionDate()) {
686 $this->progress->setCompletionDate(
new DateTime());
689 $assignment = $this->assignment_repository->read($this->getAssignmentId());
690 if ((
int) $prg->getId() === $assignment->getRootId()) {
691 $this->maybeLimitProgressValidity($prg, $assignment);
693 $this->events->userSuccessful($this);
696 $this->progress->setCompletionDate(
null);
699 $this->progress_repository->update(
703 $this->refreshLPStatus();
704 $this->updateParentStatus();
712 foreach ($this->getChildrenProgress() as $child) {
713 if ($child->isSuccessful()) {
726 foreach ($this->getParentProgresses() as $parent) {
727 $parent->updateStatus();
744 if ($this->isSuccessful() || !$this->isRelevant()) {
748 $prg = $this->getStudyProgramme();
751 "ilStudyProgrammeUserProgress::setLPCompleted: "
752 .
"The node '" . $prg->getId() .
"' is not in LP_COMPLETED mode."
756 if ($this->getUserId() != $usr_id) {
758 "ilStudyProgrammeUserProgress::setLPCompleted: "
759 .
"This progress does belong to user '" . $this->getUserId()
760 .
"' and not to user '$usr_id'"
764 if (!in_array($obj_id, $prg->getLPChildrenIds())) {
766 "ilStudyProgrammeUserProgress::setLPCompleted: "
767 .
"Object '$obj_id' is no child of node '" . $prg->getId() .
"'."
771 $this->progress_repository->update(
774 ->setCompletionBy($obj_id)
775 ->setCompletionDate(
new DateTime())
778 $this->refreshLPStatus();
780 $assignment = $this->assignment_repository->read($this->getAssignmentId());
781 if ((
int) $prg->getId() === $assignment->getRootId()) {
782 $this->maybeLimitProgressValidity($prg, $assignment);
785 $this->events->userSuccessful($this);
786 $this->updateParentStatus();
796 $qualification_date = $prg->getValidityOfQualificationSettings()->getQualificationDate();
798 if (!is_null($qualification_date)) {
799 $date = $qualification_date;
803 $date =
new DateTime();
804 $date->add(
new DateInterval(
'P' . $qualification_period .
'D'));
810 $this->progress_repository->update($this->progress->setValidityOfQualification($date));
814 $date->sub(
new DateInterval(
'P' . $restart_period .
'D'));
815 $this->assignment_repository->update($assignment->
setRestartDate($date));
828 if ($this->getStudyProgramme()->getId() == $this->assignment_repository->read($this->getAssignmentId())->getRootId()) {
832 $overall_parents = [];
833 $prg = $this->getStudyProgramme();
837 $overall_parents[] = $parent;
841 $overall_parents[] = $ref->getParent();
846 return $parent->getProgressForAssignment($this->progress->getAssignmentId());
861 $prg = $this->getStudyProgramme();
864 "ilStudyProgrammeUserProgress::getChildrenProgress: "
865 .
"There is some problem in the implementation. This "
866 .
"method should only be callled for nodes in points "
871 $ass_id = $this->progress->getAssignmentId();
873 return array_map(
function ($child) use ($ass_id) {
874 return $child->getProgressForAssignment($ass_id);
887 $prg = $this->getStudyProgramme();
889 $ass_id = $this->progress->getAssignmentId();
892 foreach ($children as $child) {
893 $prgrs = $child->getProgressForAssignment($ass_id);
894 if (!$prgrs->isSuccessful()) {
897 $names[] = $child->getTitle();
915 if ($node_id == $root_prg_id) {
916 $actions[] = self::ACTION_SHOW_INDIVIDUAL_PLAN;
917 $actions[] = self::ACTION_REMOVE_USER;
921 $actions[] = self::ACTION_UNMARK_ACCREDITED;
923 $actions[] = self::ACTION_MARK_ACCREDITED;
935 $this->getStudyProgramme()->getId(),
936 array($this->getUserId())
947 $this->progress_repository->update(
948 $this->progress->setLastChangeBy($user_id)
954 $this->events->userRiskyToFail($this);
960 public static function sendRiskyToFailMail(
int $progress_id,
int $usr_id) : void
965 $lng->loadLanguageModule(
"prg");
966 $lng->loadLanguageModule(
"mail");
971 $usr_progress = $usr_progress_db->getInstanceById($progress_id);
973 $prg = $usr_progress->getStudyProgramme();
976 $log->write(
"Send risky to fail mail is deactivated in study programme settings");
980 $subject =
$lng->txt(
"risky_to_fail_mail_subject");
984 $lng->txt(
"risky_to_fail_mail_body"),
985 $lng->txt(
"mail_salutation_" . $gender),
991 $mail =
new ilMail(ANONYMOUS_USER_ID);
1001 }
catch (Exception
$e) {
1006 $usr_progress_db->reminderSendFor($usr_progress->getId());
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
static _resetInfoCaches($a_obj_id)
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
shouldSendRiskyToFailMail()
static getInstanceByRefId($a_ref_id)
getChildren(bool $include_references=false)
Get all ilObjStudyProgrammes that are direct children of this object.
getParent()
Get the parent ilObjStudyProgramme of this object.
getValidityOfQualificationSettings()
static _lookupLogin($a_user_id)
lookup login
static _lookupGender($a_user_id)
Lookup gender.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _getAllReferences($a_id)
get all reference ids of object
getTitle()
get object title @access public
Class ilStudyProgrammeAssignment.
setRestartDate(DateTime $date=null)
Set the date, at which the user is to be reassigned to the programme.
Class ilStudyProgrammeProgress.
const STATUS_NOT_RELEVANT
setDeadline(DateTime $deadline=null)
Set the deadline of this progress.
const NO_VALIDITY_OF_QUALIFICATION_PERIOD
Represents the progress of a user at one node of a study programme.
setValidityOfQualification(DateTime $date=null)
Set validity of qualification.
getDeadline()
Get the deadline of this node.
getCompletionBy()
Get the id of the user or course that lead to completion of this node.
const ACTION_SHOW_INDIVIDUAL_PLAN
updateProgress(int $user_id)
Updates current progress.
__construct(ilStudyProgrammeProgress $progress, ilStudyProgrammeProgressRepository $progress_repository, ilStudyProgrammeAssignmentRepository $assignment_repository, ilStudyProgrammeEvents $events)
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to.
isFailed()
Check whether user as failed on this node.
recalculateFailedToDeadline()
Recalculates the status according to deadline.
informUserForRiskToFail()
getValidityOfQualification()
Get validity of qualification.
getMaximumPossibleAmountOfPoints(bool $only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node.
markAccredited(int $user_id)
Mark this progress as accredited.
getStatus()
Get the status of the progress.
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes.
markNotRelevant(int $user_id)
Set the node to be not relevant for the user.
getId()
Get the id of the progress.
markFailed(int $a_user_id)
Mark this progress as failed.
isSuccessfulExpired()
Check, whether a the course is passed and expired due to limited validity.
getNamesOfCompletedOrAccreditedChildren()
Get a list with the names of the children of this node that a were completed or accredited for the gi...
canBeCompleted()
Check whether the user can achieve enough points on the subnodes to be able to complete this node.
getNodeId()
Get the id of the program node the progress belongs to.
isAccredited()
Check whether the user was accredited on this node.
const ACTION_CHANGE_EXPIRE_DATE
unmarkAccredited()
Set the node to in progress.
const ACTION_MARK_ACCREDITED
getAssignmentId()
Get the assignment this progress belongs to.
maybeLimitProgressValidity(ilObjStudyProgramme $prg, ilStudyProgrammeAssignment $assignment)
isSuccessful()
Check whether the user was successful on this node.
setRequiredAmountOfPoints(int $a_points, int $user_id)
Set the amount of points the user is required to have to complete this node.
getCompletionDate()
Get the completion date of this node.
getAssignmentDate()
Get the assignment date of this node.
getCurrentAmountOfPoints()
Get the amount of points the user currently achieved.
setDeadline(DateTime $deadline=null)
Set the deadline of this node.
markNotFailed(int $user_id)
Set the node to in progress.
updateParentStatus()
Update the status of the parent of this node.
static getPossibleActions(int $node_id, int $root_prg_id, int $status)
Get a list with possible actions on a progress record.
getUserId()
Get the id of the user who is assigned.
const ACTION_CHANGE_DEADLINE
getAmountOfPoints()
Get the amount of points needed to complete the node.
hasIndividualModifications()
Check whether there are individual modifications for the user on this program.
getStudyProgramme()
Get the program node this progress belongs to.
const ACTION_UNMARK_ACCREDITED
invalidate()
Mark this progress as failed.
updateFromProgramNode()
Update the progress from its program node.
setLPCompleted(int $obj_id, int $usr_id)
Set this node to be completed due to a completed learning progress.
isRelevant()
Check whether this node is relevant for the user.
markRelevant(int $user_id)
Set the node to be relevant for the user.
getParentProgresses()
Get the progress on the parent node for the same assignment this progress belongs to.
getLastChange()
Get the timestamp when the last change was made on this progress.
getLastChangeBy()
Get the id of the user who did the last change on this progress.
Covers the persistence of settings belonging to a study programme (SP).
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples