5 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
31 $this->progress = $a_ids_or_model;
33 if (count($a_ids_or_model) != 3) {
34 throw new ilException(
"ilStudyProgrammeUserProgress::__construct: " 35 .
"expected array with 3 items.");
41 $this->progress = array_shift(
43 ,
"prg_id" => $a_ids_or_model[1]
44 ,
"usr_id" => $a_ids_or_model[2]
48 if ($this->progress === null) {
49 throw new ilException(
"ilStudyProgrammeUserProgress::__construct: Could not find progress.");
65 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
68 throw new ilException(
"ilStudyProgrammeUserAssignment::getStudyProgramme: " 69 .
"could not find ref_id for program '" 70 . $this->progress->getNodeId() .
"'.");
82 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
93 return $this->progress->getId();
103 return $this->progress->getNodeId();
113 return $this->progress->getUserId();
123 return $this->progress->getStatus();
134 return $this->progress->getAmountOfPoints();
148 return $this->progress->getCurrentAmountOfPoints();
158 return $this->progress->getLastChange();
168 return $this->progress->getLastChangeBy();
178 return $this->progress->getCompletionBy();
188 return $this->progress->getDeadline();
198 return $this->progress->setDeadline($deadline);
204 public function delete()
206 $this->progress->delete();
225 throw new ilException(
"ilStudyProgrammeUserProgress::markAccredited: " 226 .
"Can't mark as accredited since program is outdated.");
231 ->setCompletionBy($a_user_id)
234 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
252 throw new ilException(
"Expected status ACCREDITED.");
256 ->setCompletionBy(null)
281 if (in_array($this->
getStatus(), $status)) {
282 throw new ilException(
"Can't mark as failed since program is passed.");
286 ->setLastChangeBy($a_user_id)
309 ->setCompletionBy(null)
310 ->setLastChangeBy($a_user_id)
330 ->setCompletionBy($a_user_id)
331 ->setLastChangeBy($a_user_id)
350 throw new ilException(
"Expected status IN_PROGRESS.");
354 ->setCompletionBy($a_user_id)
355 ->setLastChangeBy($a_user_id)
374 $this->progress->setAmountOfPoints($a_points)
375 ->setLastChangeBy($a_user_id)
400 $children = $prg->getChildren();
401 $ass = $this->progress->getAssignmentId();
402 $points = array_map(
function ($child) use ($ass, $only_relevant) {
403 $relevant = $child->getProgressForAssignment($ass)->isRelevant();
404 if ($only_relevant) {
406 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
411 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
415 return array_reduce($points,
function ($a, $b) {
440 foreach ($children_progress as
$progress) {
441 if ($progress->isRelevant() && !$progress->canBeCompleted()) {
492 $today = date(
"Y-m-d");
494 if ($deadline && $deadline->get(
IL_CAL_DATE) < $today) {
539 $this->progress->setAmountOfPoints($prg->getPoints())
565 $add =
function ($a, $b) {
568 $get_points =
function ($child) {
569 if (!$child->isSuccessful()) {
572 return $child->getAmountOfPoints();
575 $achieved_points = array_reduce(array_map($get_points, $this->
getChildrenProgress()), $add);
576 if (!$achieved_points) {
577 $achieved_points = 0;
582 $this->progress->setCurrentAmountOfPoints($achieved_points);
585 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
591 $this->progress->update();
599 if ($child->isSuccessful()) {
613 $parent->updateStatus();
635 throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: " 636 .
"The node '" . $prg->getId() .
"' is not in LP_COMPLETED mode.");
639 throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: " 640 .
"This progress does belong to user '" . $this->
getUserId()
641 .
"' and not to user '$a_usr_id'");
643 if (!in_array($a_obj_id, $prg->getLPChildrenIds())) {
644 throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: " 645 .
"Object '$a_obj_id' is no child of node '" . $prg->getId() .
"'.");
649 ->setCompletionBy($a_obj_id)
652 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
666 $parent = $prg->getParent();
675 return $parent->getProgressForAssignment($this->progress->getAssignmentId());
688 throw new ilException(
"ilStudyProgrammeUserProgress::getChildrenProgress: " 689 .
"There is some problem in the implementation. This " 690 .
"method should only be callled for nodes in points " 694 $ass_id = $this->progress->getAssignmentId();
695 return array_map(
function ($child) use ($ass_id) {
696 return $child->getProgressForAssignment($ass_id);
697 }, $prg->getChildren());
710 $children = $prg->getChildren();
711 $ass_id = $this->progress->getAssignmentId();
713 foreach ($children as $child) {
714 $prgrs = $child->getProgressForAssignment($ass_id);
715 if (!$prgrs->isSuccessful()) {
718 $names[] = $child->getTitle();
737 if ($a_node_id == $a_root_prg_id) {
738 $actions[] = self::ACTION_SHOW_INDIVIDUAL_PLAN;
739 $actions[] = self::ACTION_REMOVE_USER;
742 $actions[] = self::ACTION_UNMARK_ACCREDITED;
744 $actions[] = self::ACTION_MARK_ACCREDITED;
751 require_once(
"Services/Tracking/classes/class.ilLPStatusWrapper.php");
764 $this->progress->setLastChangeBy($user_id)
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to...
static userSuccessful(ilStudyProgrammeUserProgress $a_progress)
getCurrentAmountOfPoints()
Get the amount of points the user currently achieved.
isRelevant()
Check whether this node is relevant for the user.
updateParentStatus()
Update the status of the parent of this node.
setRequiredAmountOfPoints($a_points, $a_user_id)
Set the amount of points the user is required to have to complete this node.
getStudyProgramme()
Get the program node where this progress belongs to was made.
unmarkAccredited()
Set the node to in progress.
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.
recalculateFailedToDeadline()
Recalculates the status according to deadline.
static where($where, $operator=null)
getAssignment()
Get the assignment this progress belongs to.
getParentProgress()
Get the progress on the parent node for the same assignment this progress belongs to...
static _getAllReferences($a_id)
get all reference ids of object
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.
canBeCompleted()
Check whether the user can achieve enough points on the subnodes to be able to complete this node...
const ACTION_SHOW_INDIVIDUAL_PLAN
markNotRelevant($a_user_id)
Set the node to be not relevant for the user.
const ACTION_UNMARK_ACCREDITED
markAccredited($a_user_id)
Mark this progress as accredited.
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.
static getPossibleActions($a_node_id, $a_root_prg_id, $a_status)
Get a list with possible actions on a progress record.
markNotFailed()
Set the node to in progress.
getUserId()
Get the id of the user who is assigned.
isFailed()
Check wether 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.
markFailed($a_user_id)
Mark this progress as failed.
Class ilStudyProgrammeProgress.
update($pash, $contents, Config $config)
getLastChangeBy()
Get the id of the user who did the last change on this progress.
setLPCompleted($a_obj_id, $a_usr_id)
Set this node to be completed due to a completed learning progress.
updateProgress($user_id)
Updates current progress.
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes...
getMaximumPossibleAmountOfPoints($only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node...
static getInstance($a_id)
Get an instance.
markRelevant($a_user_id)
Set the node to be relevant for the user.
updateFromProgramNode()
Update the progress from its program node.
getDeadline()
Get the deadline of this node.
getCompletionBy()
Get the id of the user or course that lead to completion of this node.
setDeadline($deadline)
Set the deadline of this node.
const ACTION_MARK_ACCREDITED
__construct($a_ids_or_model)
Throws when id does not refer to a study programme progress.
Represents the progress of a user at one node of a study programme.