ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 463 of file class.ilStudyProgrammeUserProgress.php.

463 {
464 $prg = $this->getStudyProgramme();
465
466 if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
467 return true;
468 }
469
470 if ($this->getMaximumPossibleAmountOfPoints(true) < $this->getAmountOfPoints()) {
471 // Fast track
472 return false;
473 }
474
475 $children_progress = $this->getChildrenProgress();
476 foreach ($children_progress as $progress) {
477 if ($progress->isRelevant() && !$progress->canBeCompleted()) {
478 return false;
479 }
480 }
481 return true;
482 }
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 303 of file class.ilStudyProgrammeUserProgress.php.

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

◆ 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 256 of file class.ilStudyProgrammeUserProgress.php.

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

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 209 of file class.ilStudyProgrammeUserProgress.php.

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

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 680 of file class.ilStudyProgrammeUserProgress.php.

680 {
681 $prg = $this->getStudyProgramme();
682 if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
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 "
686 ."mode.");
687 }
688
689 $ass_id = $this->progress->getAssignmentId();
690 return array_map(function($child) use ($ass_id) {
691 return $child->getProgressForAssignment($ass_id);
692 }, $prg->getChildren());
693 }

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 296 of file class.ilStudyProgrammeUserProgress.php.

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

◆ getCurrentAmountOfPoints()

ilStudyProgrammeUserProgress::getCurrentAmountOfPoints ( )

Get the amount of points the user currently achieved.

Returns
int

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

265 {
266 if ( $this->isAccredited()
267 || ($this->isSuccessful() && $this->getStudyProgramme()->hasLPChildren())) {
268 return $this->getAmountOfPoints();
269 }
270 return $this->progress->getCurrentAmountOfPoints();
271 }
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 219 of file class.ilStudyProgrammeUserProgress.php.

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

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 278 of file class.ilStudyProgrammeUserProgress.php.

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

◆ getLastChangeBy()

ilStudyProgrammeUserProgress::getLastChangeBy ( )

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

Returns
int

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

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

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 434 of file class.ilStudyProgrammeUserProgress.php.

434 {
435 $prg = $this->getStudyProgramme();
436 if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
437 return $this->getAmountOfPoints();
438 }
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();
443 if($only_relevant) {
444 if($relevant) {
445 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
446 } else {
447 return 0;
448 }
449 } else {
450 return $child->getProgressForAssignment($ass)->getAmountOfPoints();
451 }
452 }, $children);
453
454 return array_reduce($points, function($a, $b) { return $a + $b; }, 0);
455 }
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 702 of file class.ilStudyProgrammeUserProgress.php.

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

References 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 228 of file class.ilStudyProgrammeUserProgress.php.

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

◆ getParentProgress()

ilStudyProgrammeUserProgress::getParentProgress ( )
protected

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

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

660 {
661 $prg = $this->getStudyProgramme();
662 $parent = $prg->getParent();
663 if (!$parent) {
664 return null;
665 }
666
667 if($this->getStudyProgramme()->getId() == $this->getAssignment()->getStudyProgramme()->getId()) {
668 return null;
669 }
670
671 return $parent->getProgressForAssignment($this->progress->getAssignmentId());
672 }
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 729 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 246 of file class.ilStudyProgrammeUserProgress.php.

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

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 193 of file class.ilStudyProgrammeUserProgress.php.

193 {
194 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
195 $refs = ilObject::_getAllReferences($this->progress->getNodeId());
196 if (!count($refs)) {
197 throw new ilException("ilStudyProgrammeUserAssignment::getStudyProgramme: "
198 ."could not find ref_id for program '"
199 .$this->progress->getNodeId()."'.");
200 }
201 return ilObjStudyProgramme::getInstanceByRefId(array_shift($refs));
202 }
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 237 of file class.ilStudyProgrammeUserProgress.php.

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

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 489 of file class.ilStudyProgrammeUserProgress.php.

489 {
490 return $this->getLastChangeBy() !== null;
491 }
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 595 of file class.ilStudyProgrammeUserProgress.php.

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

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 511 of file class.ilStudyProgrammeUserProgress.php.

511 {
512 $status = $this->getStatus();
513
515 }
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 522 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 499 of file class.ilStudyProgrammeUserProgress.php.

499 {
500 $status = $this->getStatus();
501
504 }

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 318 of file class.ilStudyProgrammeUserProgress.php.

318 {
320 $prg = $this->getStudyProgramme();
321 if ($prg->getStatus() == ilStudyProgramme::STATUS_OUTDATED) {
322 throw new ilException("ilStudyProgrammeUserProgress::markAccredited: "
323 ."Can't mark as accredited since program is outdated.");
324 }
325 }
326
327 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_ACCREDITED)
328 ->setCompletionBy($a_user_id)
329 ->update();
330
331 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
333
334 $this->updateParentStatus();
335 return $this;
336 }
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 370 of file class.ilStudyProgrammeUserProgress.php.

370 {
371 $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT)
372 ->setCompletionBy($a_user_id)
373 ->setLastChangeBy($a_user_id)
374 ->update();
375
376 $this->updateStatus();
377 return $this;
378 }
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 389 of file class.ilStudyProgrammeUserProgress.php.

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

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 744 of file class.ilStudyProgrammeUserProgress.php.

744 {
745 require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
747 }
_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 625 of file class.ilStudyProgrammeUserProgress.php.

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

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 413 of file class.ilStudyProgrammeUserProgress.php.

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

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 $lng;
166 $lng->loadLanguageModule("prg");
167
169 return $lng->txt("prg_status_in_progress");
170 }
172 return $lng->txt("prg_status_completed");
173 }
175 return $lng->txt("prg_status_accredited");
176 }
178 return $lng->txt("prg_status_not_relevant");
179 }
180 throw new ilException("Unknown status: '$a_status'");
181 }
global $lng
Definition: privfeed.php:40

References $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 346 of file class.ilStudyProgrammeUserProgress.php.

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

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 533 of file class.ilStudyProgrammeUserProgress.php.

533 {
534 if ($this->hasIndividualModifications()) {
535 return false;
536 }
538 return false;
539 }
540
541 $prg = $this->getStudyProgramme();
542 $this->progress->setAmountOfPoints($prg->getPoints())
543 ->setStatus($prg->getStatus() == ilStudyProgramme::STATUS_ACTIVE
546 )
547 ->update();
548
549 $this->updateStatus();
550 }
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 608 of file class.ilStudyProgrammeUserProgress.php.

608 {
609 $parent = $this->getParentProgress();
610 if ($parent) {
611 $parent->updateStatus();
612 }
613 }
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 556 of file class.ilStudyProgrammeUserProgress.php.

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

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: