5require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
29 $this->progress = $a_ids_or_model;
32 if (count($a_ids_or_model) != 3) {
33 throw new ilException(
"ilStudyProgrammeUserProgress::__construct: "
34 .
"expected array with 3 items.");
40 $this->progress = array_shift(
42 (
"assignment_id" => $a_ids_or_model[0]
43 ,
"prg_id" => $a_ids_or_model[1]
44 ,
"usr_id" => $a_ids_or_model[2]
47 if ($this->progress ===
null) {
48 throw new ilException(
"ilStudyProgrammeUserProgress::__construct: Could not find progress.");
61 static public function getInstance($a_assignment_id, $a_program_id, $a_user_id) {
72 $prgrs = ilStudyProgrammeProgress::find($a_prgrs_id);
73 if ($prgrs ===
null) {
74 throw new ilException(
"Unknown progress id $a_prgrs_id.");
88 (
"prg_id" => $a_program_id
89 ,
"usr_id" => $a_user_id
91 return array_values(array_map(
function($dat) {
108 (
"prg_id" => $a_program_id
109 ,
"assignment_id" => $a_assignment_id
111 if (count($progresses) == 0) {
112 require_once(
"Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
114 (
"ilStudyProgrammeUserProgress::getInstanceForAssignment: "
115 .
"Assignment '$a_assignment_id' does not belong to program "
133 (
"assignment_id" => $a_assignment_id
135 if (count($progresses) == 0) {
136 require_once(
"Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
138 (
"ilStudyProgrammeUserProgress::getInstancesForAssignment: "
139 .
"Can't find progresses for assignment '$a_assignment_id'.");
141 return array_map(
function($dat) {
154 (
"prg_id" => $a_program_id
156 return array_values(array_map(
function($dat) {
166 $lng->loadLanguageModule(
"prg");
169 return $lng->txt(
"prg_status_in_progress");
172 return $lng->txt(
"prg_status_completed");
175 return $lng->txt(
"prg_status_accredited");
178 return $lng->txt(
"prg_status_not_relevant");
180 throw new ilException(
"Unknown status: '$a_status'");
194 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
197 throw new ilException(
"ilStudyProgrammeUserAssignment::getStudyProgramme: "
198 .
"could not find ref_id for program '"
199 .$this->progress->getNodeId().
"'.");
210 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
220 return $this->progress->getId();
229 return $this->progress->getNodeId();
238 return $this->progress->getUserId();
247 return $this->progress->getStatus();
257 return $this->progress->getAmountOfPoints();
270 return $this->progress->getCurrentAmountOfPoints();
279 return $this->progress->getLastChange();
288 return $this->progress->getLastChangeBy();
297 return $this->progress->getCompletionBy();
303 public function delete() {
304 $this->progress->delete();
322 throw new ilException(
"ilStudyProgrammeUserProgress::markAccredited: "
323 .
"Can't mark as accredited since program is outdated.");
328 ->setCompletionBy($a_user_id)
331 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
348 throw new ilException(
"Expected status ACCREDITED.");
352 ->setCompletionBy(
null)
372 ->setCompletionBy($a_user_id)
373 ->setLastChangeBy($a_user_id)
391 throw new ilException(
"Expected status IN_PROGRESS.");
395 ->setCompletionBy($a_user_id)
396 ->setLastChangeBy($a_user_id)
414 $this->progress->setAmountOfPoints($a_points)
415 ->setLastChangeBy($a_user_id)
439 $children = $prg->getChildren();
440 $ass = $this->progress->getAssignmentId();
441 $points = array_map(
function($child) use ($ass, $only_relevant) {
442 $relevant = $child->getProgressForAssignment($ass)->
isRelevant();
454 return array_reduce($points,
function($a, $b) {
return $a + $b; }, 0);
476 foreach ($children_progress as
$progress) {
542 $this->progress->setAmountOfPoints($prg->getPoints())
566 $add =
function($a, $b) {
return $a + $b; };
567 $get_points =
function($child) {
568 if (!$child->isSuccessful()) {
571 return $child->getAmountOfPoints();
574 $achieved_points = array_reduce(array_map($get_points, $this->
getChildrenProgress()), $add);
575 if (!$achieved_points) {
576 $achieved_points = 0;
581 $this->progress->setCurrentAmountOfPoints($achieved_points);
584 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
590 $this->progress->update();
598 if($child->isSuccessful()) {
611 $parent->updateStatus();
632 throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: "
633 .
"The node '".$prg->getId().
"' is not in LP_COMPLETED mode.");
636 throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: "
637 .
"This progress does belong to user '".$this->
getUserId()
638 .
"' and not to user '$a_usr_id'");
640 if (!in_array($a_obj_id, $prg->getLPChildrenIds())) {
641 throw new ilException(
"ilStudyProgrammeUserProgress::setLPCompleted: "
642 .
"Object '$a_obj_id' is no child of node '".$prg->getId().
"'.");
646 ->setCompletionBy($a_obj_id)
649 require_once(
"Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
662 $parent = $prg->getParent();
671 return $parent->getProgressForAssignment($this->progress->getAssignmentId());
683 throw new ilException(
"ilStudyProgrammeUserProgress::getChildrenProgress: "
684 .
"There is some problem in the implementation. This "
685 .
"method should only be callled for nodes in points "
689 $ass_id = $this->progress->getAssignmentId();
690 return array_map(
function($child) use ($ass_id) {
691 return $child->getProgressForAssignment($ass_id);
692 }, $prg->getChildren());
704 $children = $prg->getChildren();
705 $ass_id = $this->progress->getAssignmentId();
707 foreach ($children as $child) {
708 $prgrs = $child->getProgressForAssignment($ass_id);
709 if (!$prgrs->isSuccessful()) {
712 $names[] = $child->getTitle();
731 if ($a_node_id == $a_root_prg_id) {
745 require_once(
"Services/Tracking/classes/class.ilLPStatusWrapper.php");
static where($where, $operator=NULL)
Base class for ILIAS Exception handling.
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.
static _getAllReferences($a_id)
get all reference ids of object
static userSuccessful(ilStudyProgrammeUserProgress $a_progress)
Exception is thrown when a progress for some programme node and assignment is missing.
Class ilStudyProgrammeProgress.
const STATUS_NOT_RELEVANT
static getInstance($a_id)
Get an instance.
Represents the progress of a user at one node of a study programme.
markNotRelevant($a_user_id)
Set the node to be not relevant for the user.
getCompletionBy()
Get the id of the user or course that lead to completion of this node.
const ACTION_SHOW_INDIVIDUAL_PLAN
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to.
static getInstance($a_assignment_id, $a_program_id, $a_user_id)
Get an instance.
markRelevant($a_user_id)
Set the node to be relevant for the user.
getMaximumPossibleAmountOfPoints($only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node.
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.
static statusToRepr($a_status)
Get a user readable representation of a status.
getId()
Get the id of the progress.
getNamesOfCompletedOrAccreditedChildren()
Get a list with the names of the children of this node that a were completed or accredited for the gi...
__construct($a_ids_or_model)
Throws when id does not refer to a study programme progress.
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.
static getInstancesForUser($a_program_id, $a_user_id)
Get the instances that user has on program.
isAccredited()
Check whether the user was accredited on this node.
unmarkAccredited()
Set the node to in progress.
const ACTION_MARK_ACCREDITED
isSuccessful()
Check whether the user was successful on this node.
setLPCompleted($a_obj_id, $a_usr_id)
Set this node to be completed due to a completed learning progress.
getCurrentAmountOfPoints()
Get the amount of points the user currently achieved.
static getInstanceForAssignment($a_program_id, $a_assignment_id)
Get the instance for the assignment on the program.
static getInstancesForAssignment($a_assignment_id)
Get the instance for an assignment.
static getPossibleActions($a_node_id, $a_root_prg_id, $a_status)
Get a list with possible actions on a progress record.
setRequiredAmountOfPoints($a_points, $a_user_id)
Set the amount of points the user is required to have to complete this node.
getAssignment()
Get the assignment this progress belongs to.
updateParentStatus()
Update the status of the parent of this node.
static getInstanceById($a_prgrs_id)
Get an instance by progress id.
getUserId()
Get the id of the user who is assigned.
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 where this progress belongs to was made.
static getInstancesForProgram($a_program_id)
Get the instances for a program node.
const ACTION_UNMARK_ACCREDITED
getParentProgress()
Get the progress on the parent node for the same assignment this progress belongs to.
markAccredited($a_user_id)
Mark this progress as accredited.
updateFromProgramNode()
Update the progress from its program node.
isRelevant()
Check whether this node is relevant for the user.
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.