6 declare(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)
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)
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) {
533 foreach ($children_progress as
$progress) {
534 if ($progress->isRelevant() && !$progress->canBeCompleted()) {
588 $this->progress_repository->update(
636 $this->progress_repository->update(
638 ->setAmountOfPoints($prg->getPoints())
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;
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()) {
693 $this->events->userSuccessful($this);
696 $this->progress->setCompletionDate(null);
699 $this->progress_repository->update(
713 if ($child->isSuccessful()) {
727 $parent->updateStatus();
751 "ilStudyProgrammeUserProgress::setLPCompleted: " 752 .
"The node '" . $prg->getId() .
"' is not in LP_COMPLETED mode." 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)
780 $assignment = $this->assignment_repository->read($this->
getAssignmentId());
781 if ((
int) $prg->getId() === $assignment->getRootId()) {
785 $this->events->userSuccessful($this);
798 if (!is_null($qualification_date)) {
799 $date = $qualification_date;
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 = [];
834 $parent = $prg->getParent();
837 $overall_parents[] = $parent;
840 foreach ($prg->getReferencesToSelf() as $ref) {
841 $overall_parents[] = $ref->getParent();
846 return $parent->getProgressForAssignment($this->progress->getAssignmentId());
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);
875 }, $prg->getChildren(
true));
888 $children = $prg->getChildren(
true);
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;
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 964 $log = $DIC[
'ilLog'];
965 $lng->loadLanguageModule(
"prg");
966 $lng->loadLanguageModule(
"mail");
971 $usr_progress = $usr_progress_db->getInstanceById($progress_id);
973 $prg = $usr_progress->getStudyProgramme();
975 if (!$prg->shouldSendRiskyToFailMail()) {
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);
1006 $usr_progress_db->reminderSendFor($usr_progress->getId());
setDeadline(DateTime $deadline=null)
Set the deadline of this node.
isSuccessfulExpired()
Check, whether a the course is passed and expired due to limited validity.
static _lookupLogin($a_user_id)
lookup login
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to...
getCurrentAmountOfPoints()
Get the amount of points the user currently achieved.
isRelevant()
Check whether this node is relevant for the user.
markNotRelevant(int $user_id)
Set the node to be not relevant for the user.
setValidityOfQualification(DateTime $date=null)
Set validity of qualification.
static _lookupFullname($a_user_id)
Lookup Full Name.
const NO_VALIDITY_OF_QUALIFICATION_PERIOD
updateProgress(int $user_id)
Updates current progress.
updateParentStatus()
Update the status of the parent of this node.
markNotFailed(int $user_id)
Set the node to in progress.
getStudyProgramme()
Get the program node this progress belongs to.
getAssignmentId()
Get the assignment this progress belongs to.
unmarkAccredited()
Set the node to in progress.
markRelevant(int $user_id)
Set the node to be relevant for the user.
invalidate()
Mark this progress as failed.
isSuccessful()
Check whether the user was successful on this node.
getId()
Get the id of the progress.
getStatus()
Get the status of the progress.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
getNodeId()
Get the id of the program node the progress belongs to.
isAccredited()
Check whether the user was accredited on this node.
static _lookupGender($a_user_id)
Lookup gender.
recalculateFailedToDeadline()
Recalculates the status according to deadline.
getAssignmentDate()
Get the assignment date of this node.
static _resetInfoCaches($a_obj_id)
static _getAllReferences($a_id)
get all reference ids of object
setLPCompleted(int $obj_id, int $usr_id)
Set this node to be completed due to a completed learning progress.
static getInstanceByRefId($a_ref_id)
canBeCompleted()
Check whether the user can achieve enough points on the subnodes to be able to complete this node...
const ACTION_SHOW_INDIVIDUAL_PLAN
getMaximumPossibleAmountOfPoints(bool $only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node...
setDeadline(DateTime $deadline=null)
Set the deadline of this progress.
const ACTION_UNMARK_ACCREDITED
getParentProgresses()
Get the progress on the parent node for the same assignment this progress belongs to...
getValidityOfQualification()
Get validity of qualification.
getNamesOfCompletedOrAccreditedChildren()
Get a list with the names of the children of this node that a were completed or accredited for the gi...
getLastChange()
Get the timestamp when the last change was made on this progress.
const ACTION_CHANGE_DEADLINE
Class ilStudyProgrammeAssignment.
getUserId()
Get the id of the user who is assigned.
isFailed()
Check whether user as failed on this node.
getAmountOfPoints()
Get the amount of points needed to complete the node.
const STATUS_NOT_RELEVANT
hasIndividualModifications()
Check whether there are individual modifications for the user on this program.
markAccredited(int $user_id)
Mark this progress as accredited.
getValidityOfQualificationSettings()
Class ilStudyProgrammeProgress.
getLastChangeBy()
Get the id of the user who did the last change on this progress.
setRequiredAmountOfPoints(int $a_points, int $user_id)
Set the amount of points the user is required to have to complete this node.
static getPossibleActions(int $node_id, int $root_prg_id, int $status)
Get a list with possible actions on a progress record.
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes...
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
getCompletionDate()
Get the completion date of this node.
maybeLimitProgressValidity(ilObjStudyProgramme $prg, ilStudyProgrammeAssignment $assignment)
updateFromProgramNode()
Update the progress from its program node.
getDeadline()
Get the deadline of this node.
markFailed(int $a_user_id)
Mark this progress as failed.
getCompletionBy()
Get the id of the user or course that lead to completion of this node.
__construct(ilStudyProgrammeProgress $progress, ilStudyProgrammeProgressRepository $progress_repository, ilStudyProgrammeAssignmentRepository $assignment_repository, ilStudyProgrammeEvents $events)
setRestartDate(DateTime $date=null)
Set the date, at which the user is to be reassigned to the programme.
const ACTION_MARK_ACCREDITED
const ACTION_CHANGE_EXPIRE_DATE
informUserForRiskToFail()
Represents the progress of a user at one node of a study programme.