ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ($a_ids_or_model)
 Throws when id does not refer to a study programme progress. More...
 
 getStudyProgramme ()
 Get the program node where this progress belongs to was made. More...
 
 getAssignment ()
 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...
 
 delete ()
 Delete the assignment from database. More...
 
 markAccredited ($a_user_id)
 Mark this progress as accredited. More...
 
 unmarkAccredited ()
 Set the node to in progress. More...
 
 markNotRelevant ($a_user_id)
 Set the node to be not relevant for the user. More...
 
 markRelevant ($a_user_id)
 Set the node to be relevant for the user. More...
 
 setRequiredAmountOfPoints ($a_points, $a_user_id)
 Set the amount of points the user is required to have to complete this node. More...
 
 getMaximumPossibleAmountOfPoints ($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...
 
 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 ($a_obj_id, $a_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...
 

Static Public Member Functions

static getInstance ($a_assignment_id, $a_program_id, $a_user_id)
 Get an instance. More...
 
static getInstanceById ($a_prgrs_id)
 Get an instance by progress id. More...
 
static getInstancesForUser ($a_program_id, $a_user_id)
 Get the instances that user has on program. More...
 
static getInstanceForAssignment ($a_program_id, $a_assignment_id)
 Get the instance for the assignment on the program. More...
 
static getInstancesForAssignment ($a_assignment_id)
 Get the instance for an assignment. More...
 
static getInstancesForProgram ($a_program_id)
 Get the instances for a program node. More...
 
static statusToRepr ($a_status)
 Get a user readable representation of a status. More...
 
static getPossibleActions ($a_node_id, $a_root_prg_id, $a_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"
 

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...
 
 getParentProgress ()
 Get the progress on the parent node for the same assignment this progress belongs to. More...
 
 refreshLPStatus ()
 

Protected Attributes

 $progress
 

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.

Author
: Richard Klees richa.nosp@m.rd.k.nosp@m.lees@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

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

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeUserProgress::__construct (   $a_ids_or_model)

Throws when id does not refer to a study programme progress.

Expects an array [assignment_id, program_node_id, user_id] or an ilStudyProgress as first parameter.

Exceptions
ilException
Parameters
int[]  |  ilStudyProgrammeAssignment$a_ids_or_model

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

27 {
28 if ($a_ids_or_model instanceof ilStudyProgrammeProgress) {
29 $this->progress = $a_ids_or_model;
30 }
31 else {
32 if (count($a_ids_or_model) != 3) {
33 throw new ilException("ilStudyProgrammeUserProgress::__construct: "
34 ."expected array with 3 items.");
35 }
36
37 // TODO: ActiveRecord won't be caching the model objects, since
38 // we are not using find. Maybe we should do this ourselves??
39 // Or should we instead cache in getInstance?
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]
45 ))->get());
46 }
47 if ($this->progress === null) {
48 throw new ilException("ilStudyProgrammeUserProgress::__construct: Could not find progress.");
49 }
50 }
static where($where, $operator=null)
Base class for ILIAS Exception handling.
Class ilStudyProgrammeProgress.

References ActiveRecord\where().

+ Here is the call graph for this function:

Member Function Documentation

◆ canBeCompleted()

ilStudyProgrammeUserProgress::canBeCompleted ( )

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

Returns
bool

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

464 {
465 $prg = $this->getStudyProgramme();
466
467 if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
468 return true;
469 }
470
471 if ($this->getMaximumPossibleAmountOfPoints(true) < $this->getAmountOfPoints()) {
472 // Fast track
473 return false;
474 }
475
476 $children_progress = $this->getChildrenProgress();
477 foreach ($children_progress as $progress) {
478 if ($progress->isRelevant() && !$progress->canBeCompleted()) {
479 return false;
480 }
481 }
482 return true;
483 }
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to.
getMaximumPossibleAmountOfPoints($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 where this progress belongs to was made.

References $progress, getAmountOfPoints(), getChildrenProgress(), getMaximumPossibleAmountOfPoints(), getStudyProgramme(), and ilStudyProgramme\MODE_LP_COMPLETED.

Referenced by ilStudyProgrammeIndividualPlanProgressListGUI\buildProgressStatus().

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

◆ delete()

ilStudyProgrammeUserProgress::delete ( )

Delete the assignment from database.

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

304 {
305 $this->progress->delete();
306 }

◆ 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.

Returns
int

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

257 {
258 return $this->progress->getAmountOfPoints();
259 }

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

+ Here is the caller graph for this function:

◆ getAssignment()

ilStudyProgrammeUserProgress::getAssignment ( )

Get the assignment this progress belongs to.

Returns
ilStudyProgrammeUserAssignment

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

210 {
211 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
212 return ilStudyProgrammeUserAssignment::getInstance($this->progress->getAssignmentId());
213 }

References ilStudyProgrammeUserAssignment\getInstance().

Referenced by getParentProgress(), and ilStudyProgrammeEvents\userSuccessful().

+ Here is the call graph for this function:
+ 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.

Returns
ilStudyProgrammeUserProgress[]

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

681 {
682 $prg = $this->getStudyProgramme();
683 if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
684 throw new ilException("ilStudyProgrammeUserProgress::getChildrenProgress: "
685 ."There is some problem in the implementation. This "
686 ."method should only be callled for nodes in points "
687 ."mode.");
688 }
689
690 $ass_id = $this->progress->getAssignmentId();
691 return array_map(function($child) use ($ass_id) {
692 return $child->getProgressForAssignment($ass_id);
693 }, $prg->getChildren());
694 }

References getStudyProgramme(), and ilStudyProgramme\MODE_LP_COMPLETED.

Referenced by canBeCompleted(), hasSuccessfullChildren(), and updateStatus().

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

◆ getCompletionBy()

ilStudyProgrammeUserProgress::getCompletionBy ( )

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

Returns
int | null

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

297 {
298 return $this->progress->getCompletionBy();
299 }

◆ getCurrentAmountOfPoints()

ilStudyProgrammeUserProgress::getCurrentAmountOfPoints ( )

Get the amount of points the user currently achieved.

Returns
int

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

266 {
267 if ( $this->isAccredited()
268 || ($this->isSuccessful() && $this->getStudyProgramme()->hasLPChildren())) {
269 return $this->getAmountOfPoints();
270 }
271 return $this->progress->getCurrentAmountOfPoints();
272 }
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:

◆ getId()

ilStudyProgrammeUserProgress::getId ( )

Get the id of the progress.

Returns
int

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

220 {
221 return $this->progress->getId();
222 }

Referenced by getParentProgress(), ilStudyProgrammeProgressListGUI\getTitleAndIconTarget(), and refreshLPStatus().

+ Here is the caller graph for this function:

◆ getInstance()

static ilStudyProgrammeUserProgress::getInstance (   $a_assignment_id,
  $a_program_id,
  $a_user_id 
)
static

Get an instance.

Just wraps constructor.

Exceptions
ilException
Parameters
int$a_assignment_id
int$a_program_id
int$a_user_id
Returns
ilStudyProgrammeUserProgress

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

61 {
62 return new ilStudyProgrammeUserProgress(array($a_assignment_id, $a_program_id, $a_user_id));
63 }
Represents the progress of a user at one node of a study programme.

Referenced by ilStudyProgrammeIndividualPlanTableGUI\fetchData().

+ Here is the caller graph for this function:

◆ getInstanceById()

static ilStudyProgrammeUserProgress::getInstanceById (   $a_prgrs_id)
static

Get an instance by progress id.

Parameters
int$a_prgrs_id
Returns
ilStudyProgrammeUserProgress

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

71 {
72 $prgrs = ilStudyProgrammeProgress::find($a_prgrs_id);
73 if ($prgrs === null) {
74 throw new ilException("Unknown progress id $a_prgrs_id.");
75 }
76 return new ilStudyProgrammeUserProgress($prgrs);
77 }

Referenced by ilObjStudyProgrammeMembersGUI\getProgressObject(), ilObjStudyProgrammeIndividualPlanGUI\updateRequiredPoints(), and ilObjStudyProgrammeIndividualPlanGUI\updateStatus().

+ Here is the caller graph for this function:

◆ getInstanceForAssignment()

static ilStudyProgrammeUserProgress::getInstanceForAssignment (   $a_program_id,
  $a_assignment_id 
)
static

Get the instance for the assignment on the program.

Throws when the node does not belong to the assignment.

Exceptions
ilException
Parameters
int$a_program_id
int$a_user_id
Returns
ilStudyProgrammeUserProgress

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

106 {
107 $progresses = ilStudyProgrammeProgress::where(array
108 ( "prg_id" => $a_program_id
109 , "assignment_id" => $a_assignment_id
110 ))->get();
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 "
116 ."'$a_program_id'");
117 }
118 return new ilStudyProgrammeUserProgress(array_shift($progresses));
119 }
Exception is thrown when a progress for some programme node and assignment is missing.

References ActiveRecord\where().

Referenced by ilStudyProgrammeMembersTableGUI\fetchData(), and ilObjStudyProgramme\getProgressForAssignment().

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

◆ getInstancesForAssignment()

static ilStudyProgrammeUserProgress::getInstancesForAssignment (   $a_assignment_id)
static

Get the instance for an assignment.

Throws when the node does not belong to the assignment.

Exceptions
ilException
Parameters
int$a_program_id
int$a_user_id
Returns
ilStudyProgrammeUserProgress

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

131 {
132 $progresses = ilStudyProgrammeProgress::where(array
133 ( "assignment_id" => $a_assignment_id
134 ))->get();
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'.");
140 }
141 return array_map(function($dat) {
142 return new ilStudyProgrammeUserProgress($dat);
143 }, $progresses);
144 }

References ActiveRecord\where().

Referenced by ilStudyProgrammeUserAssignment\delete().

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

◆ getInstancesForProgram()

static ilStudyProgrammeUserProgress::getInstancesForProgram (   $a_program_id)
static

Get the instances for a program node.

Parameters
int$a_program_id
Returns
ilStudyProgrammeUserProgress[]

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

152 {
153 $progresses = ilStudyProgrammeProgress::where(array
154 ( "prg_id" => $a_program_id
155 ))->get();
156 return array_values(array_map(function($dat) {
157 return new ilStudyProgrammeUserProgress($dat);
158 }, $progresses));
159 }

References ActiveRecord\where().

Referenced by ilObjStudyProgramme\getProgresses().

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

◆ getInstancesForUser()

static ilStudyProgrammeUserProgress::getInstancesForUser (   $a_program_id,
  $a_user_id 
)
static

Get the instances that user has on program.

Parameters
int$a_program_id
int$a_user_id
Returns
ilStudyProgrammeUserProgress[]

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

86 {
87 $progresses = ilStudyProgrammeProgress::where(array
88 ( "prg_id" => $a_program_id
89 , "usr_id" => $a_user_id
90 ))->get();
91 return array_values(array_map(function($dat) {
92 return new ilStudyProgrammeUserProgress($dat);
93 }, $progresses));
94 }

References ActiveRecord\where().

Referenced by ilObjStudyProgramme\getProgressesOf().

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

◆ getLastChange()

ilStudyProgrammeUserProgress::getLastChange ( )

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

Returns
ilDateTime

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

279 {
280 return $this->progress->getLastChange();
281 }

◆ getLastChangeBy()

ilStudyProgrammeUserProgress::getLastChangeBy ( )

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

Returns
int

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

288 {
289 return $this->progress->getLastChangeBy();
290 }

Referenced by hasIndividualModifications().

+ Here is the caller graph for this function:

◆ getMaximumPossibleAmountOfPoints()

ilStudyProgrammeUserProgress::getMaximumPossibleAmountOfPoints (   $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.

Parameters
$only_relevantboolean true if check is nesserary the progress is relevant
Returns
int

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

435 {
436 $prg = $this->getStudyProgramme();
437 if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
438 return $this->getAmountOfPoints();
439 }
440 $children = $prg->getChildren();
441 $ass = $this->progress->getAssignmentId();
442 $points = array_map(function($child) use ($ass, $only_relevant) {
443 $relevant = $child->getProgressForAssignment($ass)->isRelevant();
444 if($only_relevant) {
445 if($relevant) {
446 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
447 } else {
448 return 0;
449 }
450 } else {
451 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
452 }
453 }, $children);
454
455 return array_reduce($points, function($a, $b) { return $a + $b; }, 0);
456 }
isRelevant()
Check whether this node is relevant for the user.

References getAmountOfPoints(), getStudyProgramme(), isRelevant(), and ilStudyProgramme\MODE_LP_COMPLETED.

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

+ Here is the call graph for this function:
+ 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.

Parameters
int$a_assignment_id
Returns
string[]

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

703 {
704 $prg = $this->getStudyProgramme();
705 $children = $prg->getChildren();
706 $ass_id = $this->progress->getAssignmentId();
707 $names = array();
708 foreach ($children as $child) {
709 $prgrs = $child->getProgressForAssignment($ass_id);
710 if (!$prgrs->isSuccessful()) {
711 continue;
712 }
713 $names[] = $child->getTitle();
714 }
715 return $names;
716 }

References $names, and getStudyProgramme().

+ Here is the call graph for this function:

◆ getNodeId()

ilStudyProgrammeUserProgress::getNodeId ( )

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

Returns
int

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

229 {
230 return $this->progress->getNodeId();
231 }

◆ getParentProgress()

ilStudyProgrammeUserProgress::getParentProgress ( )
protected

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

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

661 {
662 $prg = $this->getStudyProgramme();
663 $parent = $prg->getParent();
664 if (!$parent) {
665 return null;
666 }
667
668 if($this->getStudyProgramme()->getId() == $this->getAssignment()->getStudyProgramme()->getId()) {
669 return null;
670 }
671
672 return $parent->getProgressForAssignment($this->progress->getAssignmentId());
673 }
getAssignment()
Get the assignment this progress belongs to.

References getAssignment(), getId(), and getStudyProgramme().

Referenced by updateParentStatus().

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

◆ getPossibleActions()

static ilStudyProgrammeUserProgress::getPossibleActions (   $a_node_id,
  $a_root_prg_id,
  $a_status 
)
static

Get a list with possible actions on a progress record.

Parameters
int$a_node_idobject_id!
int$a_belongsobject_id!
int$a_status

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

References ACTION_MARK_ACCREDITED, ACTION_REMOVE_USER, ACTION_SHOW_INDIVIDUAL_PLAN, ACTION_UNMARK_ACCREDITED, ilStudyProgrammeProgress\STATUS_ACCREDITED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

Referenced by ilStudyProgrammeMembersTableGUI\fetchData().

+ Here is the caller graph for this function:

◆ getStatus()

ilStudyProgrammeUserProgress::getStatus ( )

Get the status of the progress.

Returns
ilStudyProgrammeProgress::$STATUS

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

247 {
248 return $this->progress->getStatus();
249 }

Referenced by isAccredited(), isRelevant(), isSuccessful(), markAccredited(), updateFromProgramNode(), and updateStatus().

+ Here is the caller graph for this function:

◆ getStudyProgramme()

ilStudyProgrammeUserProgress::getStudyProgramme ( )

Get the program node where this progress belongs to was made.

Throws when program this assignment is about has no ref id.

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

Exceptions
ilException
Returns
ilObjStudyProgramme

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

194 {
195 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
196 $refs = ilObject::_getAllReferences($this->progress->getNodeId());
197 if (!count($refs)) {
198 throw new ilException("ilStudyProgrammeUserAssignment::getStudyProgramme: "
199 ."could not find ref_id for program '"
200 .$this->progress->getNodeId()."'.");
201 }
202 return ilObjStudyProgramme::getInstanceByRefId(array_shift($refs));
203 }
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.
static _getAllReferences($a_id)
get all reference ids of object

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

Referenced by ilStudyProgrammeProgressListGUI\buildProgressStatus(), canBeCompleted(), getChildrenProgress(), getCurrentAmountOfPoints(), getMaximumPossibleAmountOfPoints(), getNamesOfCompletedOrAccreditedChildren(), getParentProgress(), markAccredited(), refreshLPStatus(), setLPCompleted(), ilStudyProgrammeExpandableProgressListGUI\shouldShowSubProgress(), updateFromProgramNode(), updateStatus(), 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.

Returns
int

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

238 {
239 return $this->progress->getUserId();
240 }

Referenced by refreshLPStatus(), and setLPCompleted().

+ Here is the caller graph for this function:

◆ hasIndividualModifications()

ilStudyProgrammeUserProgress::hasIndividualModifications ( )

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

Returns
bool

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

490 {
491 return $this->getLastChangeBy() !== null;
492 }
getLastChangeBy()
Get the id of the user who did the last change on this progress.

References getLastChangeBy().

Referenced by updateFromProgramNode().

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

◆ hasSuccessfullChildren()

ilStudyProgrammeUserProgress::hasSuccessfullChildren ( )
protected

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

597 {
598 foreach($this->getChildrenProgress() as $child) {
599 if($child->isSuccessful()) {
600 return true;
601 }
602 }
603 return false;
604 }

References getChildrenProgress().

Referenced by updateStatus().

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

◆ isAccredited()

ilStudyProgrammeUserProgress::isAccredited ( )

Check whether the user was accredited on this node.

Returns
bool

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

512 {
513 $status = $this->getStatus();
514
516 }
getStatus()
Get the status of the progress.

References getStatus(), and ilStudyProgrammeProgress\STATUS_ACCREDITED.

Referenced by getCurrentAmountOfPoints().

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

◆ isRelevant()

ilStudyProgrammeUserProgress::isRelevant ( )

Check whether this node is relevant for the user.

Returns
bool

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

References getStatus(), and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

Referenced by getMaximumPossibleAmountOfPoints(), setLPCompleted(), and ilStudyProgrammeExpandableProgressListGUI\shouldShowSubProgress().

+ Here is the call graph for this function:
+ 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.

Returns
bool

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

500 {
501 $status = $this->getStatus();
502
505 }

References getStatus(), ilStudyProgrammeProgress\STATUS_ACCREDITED, and ilStudyProgrammeProgress\STATUS_COMPLETED.

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

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

◆ markAccredited()

ilStudyProgrammeUserProgress::markAccredited (   $a_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
Parameters
int$a_user_idThe user who performed the operation.
Returns
$this

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

319 {
321 $prg = $this->getStudyProgramme();
322 if ($prg->getStatus() == ilStudyProgramme::STATUS_OUTDATED) {
323 throw new ilException("ilStudyProgrammeUserProgress::markAccredited: "
324 ."Can't mark as accredited since program is outdated.");
325 }
326 }
327
328 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_ACCREDITED)
329 ->setCompletionBy($a_user_id)
330 ->update();
331
332 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
334
335 $this->updateParentStatus();
336 return $this;
337 }
static userSuccessful(ilStudyProgrammeUserProgress $a_progress)
updateParentStatus()
Update the status of the parent of this node.

References getStatus(), getStudyProgramme(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, ilStudyProgramme\STATUS_OUTDATED, updateParentStatus(), and ilStudyProgrammeEvents\userSuccessful().

+ Here is the call graph for this function:

◆ markNotRelevant()

ilStudyProgrammeUserProgress::markNotRelevant (   $a_user_id)

Set the node to be not relevant for the user.

Throws when status is COMPLETED.

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

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

371 {
372 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT)
373 ->setCompletionBy($a_user_id)
374 ->setLastChangeBy($a_user_id)
375 ->update();
376
377 $this->updateStatus();
378 return $this;
379 }
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 (   $a_user_id)

Set the node to be relevant for the user.

Throws when status is not NOT_RELEVANT.

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

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

390 {
391 if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_NOT_RELEVANT) {
392 throw new ilException("Expected status IN_PROGRESS.");
393 }
394
395 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_IN_PROGRESS)
396 ->setCompletionBy($a_user_id)
397 ->setLastChangeBy($a_user_id)
398 ->update();
399
400 $this->updateStatus();
401 return $this;
402 }

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

+ Here is the call graph for this function:

◆ refreshLPStatus()

ilStudyProgrammeUserProgress::refreshLPStatus ( )
protected

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

745 {
746 require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
748 }
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
getUserId()
Get the id of the user who is assigned.

References ilLPStatusWrapper\_refreshStatus(), getId(), getStudyProgramme(), and getUserId().

Referenced by setLPCompleted(), unmarkAccredited(), and updateStatus().

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

◆ setLPCompleted()

ilStudyProgrammeUserProgress::setLPCompleted (   $a_obj_id,
  $a_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

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

626 {
627 if ($this->isSuccessful() || !$this->isRelevant()) {
628 return true;
629 }
630
631 $prg = $this->getStudyProgramme();
632 if ($prg->getLPMode() != ilStudyProgramme::MODE_LP_COMPLETED) {
633 throw new ilException("ilStudyProgrammeUserProgress::setLPCompleted: "
634 ."The node '".$prg->getId()."' is not in LP_COMPLETED mode.");
635 }
636 if ($this->getUserId() != $a_usr_id) {
637 throw new ilException("ilStudyProgrammeUserProgress::setLPCompleted: "
638 ."This progress does belong to user '".$this->getUserId()
639 ."' and not to user '$a_usr_id'");
640 }
641 if (!in_array($a_obj_id, $prg->getLPChildrenIds())) {
642 throw new ilException("ilStudyProgrammeUserProgress::setLPCompleted: "
643 ."Object '$a_obj_id' is no child of node '".$prg->getId()."'.");
644 }
645
646 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_COMPLETED)
647 ->setCompletionBy($a_obj_id)
648 ->update();
649
650 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
652
653 $this->refreshLPStatus();
654 $this->updateParentStatus();
655 }

References getStudyProgramme(), getUserId(), isRelevant(), isSuccessful(), ilStudyProgramme\MODE_LP_COMPLETED, refreshLPStatus(), ilStudyProgrammeProgress\STATUS_COMPLETED, updateParentStatus(), and ilStudyProgrammeEvents\userSuccessful().

+ Here is the call graph for this function:

◆ setRequiredAmountOfPoints()

ilStudyProgrammeUserProgress::setRequiredAmountOfPoints (   $a_points,
  $a_user_id 
)

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

Throws when status is completed.

Exceptions
ilException
Parameters
int$a_pointsThe amount of points the user needs for completion.
int$a_user_idThe id of the user who did the modification.
Returns
$this

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

414 {
415 $this->progress->setAmountOfPoints($a_points)
416 ->setLastChangeBy($a_user_id)
417 ->update();
418
419 $this->updateStatus();
420 return $this;
421 }

References updateStatus().

+ Here is the call graph for this function:

◆ statusToRepr()

static ilStudyProgrammeUserProgress::statusToRepr (   $a_status)
static

Get a user readable representation of a status.

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

164 {
165 global $DIC;
166 $lng = $DIC['lng'];
167 $lng->loadLanguageModule("prg");
168
170 return $lng->txt("prg_status_in_progress");
171 }
173 return $lng->txt("prg_status_completed");
174 }
176 return $lng->txt("prg_status_accredited");
177 }
179 return $lng->txt("prg_status_not_relevant");
180 }
181 throw new ilException("Unknown status: '$a_status'");
182 }
global $lng
Definition: privfeed.php:17
global $DIC

References $DIC, $lng, ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

Referenced by ilStudyProgrammeIndividualPlanTableGUI\fillRow(), and ilStudyProgrammeMembersTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ unmarkAccredited()

ilStudyProgrammeUserProgress::unmarkAccredited ( )

Set the node to in progress.

Throws when status is not ACCREDITED.

Exceptions
ilException
Returns
$this

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

347 {
348 if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_ACCREDITED) {
349 throw new ilException("Expected status ACCREDITED.");
350 }
351
352 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_IN_PROGRESS)
353 ->setCompletionBy(null)
354 ->update();
355
356 $this->refreshLPStatus();
357
358 $this->updateParentStatus();
359 return $this;
360 }

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.

Returns
bool

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

534 {
535 if ($this->hasIndividualModifications()) {
536 return false;
537 }
539 return false;
540 }
541
542 $prg = $this->getStudyProgramme();
543 $this->progress->setAmountOfPoints($prg->getPoints())
544 ->setStatus($prg->getStatus() == ilStudyProgramme::STATUS_ACTIVE
547 )
548 ->update();
549
550 $this->updateStatus();
551 }
hasIndividualModifications()
Check whether there are individual modifications for the user on this program.

References getStatus(), getStudyProgramme(), hasIndividualModifications(), ilStudyProgramme\STATUS_ACTIVE, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and updateStatus().

+ Here is the call graph for this function:

◆ updateParentStatus()

ilStudyProgrammeUserProgress::updateParentStatus ( )
protected

Update the status of the parent of this node.

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

609 {
610 $parent = $this->getParentProgress();
611 if ($parent) {
612 $parent->updateStatus();
613 }
614 }
getParentProgress()
Get the progress on the parent node for the same assignment this progress belongs to.

References getParentProgress().

Referenced by markAccredited(), setLPCompleted(), unmarkAccredited(), and updateStatus().

+ Here is the call graph for this function:
+ 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.

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

557 {
558 $prg = $this->getStudyProgramme();
559 if (( $prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED
560 && $this->getStatus() != ilStudyProgrammeProgress::STATUS_ACCREDITED)
561 || $this->getStatus() == ilStudyProgrammeProgress::STATUS_NOT_RELEVANT) {
562 // Nothing to do here, as the status will be set by LP.
563 // OR current status is NOT RELEVANT
564 return;
565 }
566
567 $add = function($a, $b) { return $a + $b; };
568 $get_points = function($child) {
569 if (!$child->isSuccessful()) {
570 return 0;
571 }
572 return $child->getAmountOfPoints();
573 };
574
575 $achieved_points = array_reduce(array_map($get_points, $this->getChildrenProgress()), $add);
576 if (!$achieved_points) {
577 $achieved_points = 0;
578 }
579 $successful = $achieved_points >= $this->getAmountOfPoints() && $this->hasSuccessfullChildren();
580 $status = $this->getStatus();
581
582 $this->progress->setCurrentAmountOfPoints($achieved_points);
583 if ($successful) {
584 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_COMPLETED);
585 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
587 } else {
588 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_IN_PROGRESS);
589 }
590
591 $this->progress->update();
592 $this->refreshLPStatus();
593 $this->updateParentStatus();
594 }

References getAmountOfPoints(), getChildrenProgress(), getStatus(), getStudyProgramme(), hasSuccessfullChildren(), ilStudyProgramme\MODE_LP_COMPLETED, refreshLPStatus(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, updateParentStatus(), and ilStudyProgrammeEvents\userSuccessful().

Referenced by markNotRelevant(), markRelevant(), setRequiredAmountOfPoints(), and updateFromProgramNode().

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

Field Documentation

◆ $progress

ilStudyProgrammeUserProgress::$progress
protected

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

Referenced by canBeCompleted().

◆ 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: