ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 getDeadline ()
 Get the deadline of this node. More...
 
 setDeadline ($deadline)
 Set the deadline 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...
 
 markFailed ($a_user_id)
 Mark this progress as failed. More...
 
 markNotFailed ()
 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...
 
 isFailed ()
 Check wether user as failed on this node. More...
 
 recalculateFailedToDeadline ()
 Recalculates the status according to deadline. 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...
 
 updateProgress ($user_id)
 Updates current progress. More...
 

Static Public Member Functions

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

References array, and ActiveRecord\where().

29  {
30  if ($a_ids_or_model instanceof ilStudyProgrammeProgress) {
31  $this->progress = $a_ids_or_model;
32  } else {
33  if (count($a_ids_or_model) != 3) {
34  throw new ilException("ilStudyProgrammeUserProgress::__construct: "
35  . "expected array with 3 items.");
36  }
37 
38  // TODO: ActiveRecord won't be caching the model objects, since
39  // we are not using find. Maybe we should do this ourselves??
40  // Or should we instead cache in getInstance?
41  $this->progress = array_shift(
42  ilStudyProgrammeProgress::where(array( "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  }
48  if ($this->progress === null) {
49  throw new ilException("ilStudyProgrammeUserProgress::__construct: Could not find progress.");
50  }
51  }
static where($where, $operator=null)
Create styles array
The data for the language used.
Class ilStudyProgrammeProgress.
+ 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 426 of file class.ilStudyProgrammeUserProgress.php.

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

Referenced by ilStudyProgrammeIndividualPlanProgressListGUI\buildProgressStatus().

427  {
428  $prg = $this->getStudyProgramme();
429 
430  if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
431  return true;
432  }
433 
434  if ($this->getMaximumPossibleAmountOfPoints(true) < $this->getAmountOfPoints()) {
435  // Fast track
436  return false;
437  }
438 
439  $children_progress = $this->getChildrenProgress();
440  foreach ($children_progress as $progress) {
441  if ($progress->isRelevant() && !$progress->canBeCompleted()) {
442  return false;
443  }
444  }
445  return true;
446  }
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to...
getStudyProgramme()
Get the program node where this progress belongs to was made.
getAmountOfPoints()
Get the amount of points needed to complete the node.
getMaximumPossibleAmountOfPoints($only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node...
+ 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 204 of file class.ilStudyProgrammeUserProgress.php.

205  {
206  $this->progress->delete();
207  }

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

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

133  {
134  return $this->progress->getAmountOfPoints();
135  }
+ Here is the caller graph for this function:

◆ getAssignment()

ilStudyProgrammeUserProgress::getAssignment ( )

Get the assignment this progress belongs to.

Returns
ilStudyProgrammeUserAssignment

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

References ilStudyProgrammeUserAssignment\getInstance().

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

81  {
82  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
83  return ilStudyProgrammeUserAssignment::getInstance($this->progress->getAssignmentId());
84  }
+ 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 684 of file class.ilStudyProgrammeUserProgress.php.

References getStudyProgramme(), and ilStudyProgramme\MODE_LP_COMPLETED.

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

685  {
686  $prg = $this->getStudyProgramme();
687  if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
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 "
691  . "mode.");
692  }
693 
694  $ass_id = $this->progress->getAssignmentId();
695  return array_map(function ($child) use ($ass_id) {
696  return $child->getProgressForAssignment($ass_id);
697  }, $prg->getChildren());
698  }
getStudyProgramme()
Get the program node where this progress belongs to was made.
+ 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 176 of file class.ilStudyProgrammeUserProgress.php.

177  {
178  return $this->progress->getCompletionBy();
179  }

◆ getCurrentAmountOfPoints()

ilStudyProgrammeUserProgress::getCurrentAmountOfPoints ( )

Get the amount of points the user currently achieved.

Returns
int

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

References getAmountOfPoints(), getStudyProgramme(), isAccredited(), and isSuccessful().

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

143  {
144  if ($this->isAccredited()
145  || ($this->isSuccessful() && $this->getStudyProgramme()->hasLPChildren())) {
146  return $this->getAmountOfPoints();
147  }
148  return $this->progress->getCurrentAmountOfPoints();
149  }
getStudyProgramme()
Get the program node where this progress belongs to was made.
isSuccessful()
Check whether the user was successful on this node.
isAccredited()
Check whether the user was accredited on this node.
getAmountOfPoints()
Get the amount of points needed to complete the node.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeadline()

ilStudyProgrammeUserProgress::getDeadline ( )

Get the deadline of this node.

Returns
ilDateTime | null

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

Referenced by recalculateFailedToDeadline().

187  {
188  return $this->progress->getDeadline();
189  }
+ Here is the caller graph for this function:

◆ getId()

ilStudyProgrammeUserProgress::getId ( )

Get the id of the progress.

Returns
int

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

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

92  {
93  return $this->progress->getId();
94  }
+ 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 156 of file class.ilStudyProgrammeUserProgress.php.

157  {
158  return $this->progress->getLastChange();
159  }

◆ getLastChangeBy()

ilStudyProgrammeUserProgress::getLastChangeBy ( )

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

Returns
int

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

Referenced by hasIndividualModifications().

167  {
168  return $this->progress->getLastChangeBy();
169  }
+ 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 394 of file class.ilStudyProgrammeUserProgress.php.

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

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

395  {
396  $prg = $this->getStudyProgramme();
397  if ($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED) {
398  return $this->getAmountOfPoints();
399  }
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) {
405  if ($relevant) {
406  return $child->getProgressForAssignment($ass)->getAmountOfPoints();
407  } else {
408  return 0;
409  }
410  } else {
411  return $child->getProgressForAssignment($ass)->getAmountOfPoints();
412  }
413  }, $children);
414 
415  return array_reduce($points, function ($a, $b) {
416  return $a + $b;
417  }, 0);
418  }
getStudyProgramme()
Get the program node where this progress belongs to was made.
getAmountOfPoints()
Get the amount of points needed to complete the node.
+ 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 707 of file class.ilStudyProgrammeUserProgress.php.

References $names, array, and getStudyProgramme().

708  {
709  $prg = $this->getStudyProgramme();
710  $children = $prg->getChildren();
711  $ass_id = $this->progress->getAssignmentId();
712  $names = array();
713  foreach ($children as $child) {
714  $prgrs = $child->getProgressForAssignment($ass_id);
715  if (!$prgrs->isSuccessful()) {
716  continue;
717  }
718  $names[] = $child->getTitle();
719  }
720  return $names;
721  }
getStudyProgramme()
Get the program node where this progress belongs to was made.
Create styles array
The data for the language used.
+ 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 101 of file class.ilStudyProgrammeUserProgress.php.

102  {
103  return $this->progress->getNodeId();
104  }

◆ getParentProgress()

ilStudyProgrammeUserProgress::getParentProgress ( )
protected

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

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

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

Referenced by updateParentStatus().

664  {
665  $prg = $this->getStudyProgramme();
666  $parent = $prg->getParent();
667  if (!$parent) {
668  return null;
669  }
670 
671  if ($this->getStudyProgramme()->getId() == $this->getAssignment()->getStudyProgramme()->getId()) {
672  return null;
673  }
674 
675  return $parent->getProgressForAssignment($this->progress->getAssignmentId());
676  }
getStudyProgramme()
Get the program node where this progress belongs to was made.
getAssignment()
Get the assignment this progress belongs to.
+ 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 734 of file class.ilStudyProgrammeUserProgress.php.

References array, ilStudyProgrammeProgress\STATUS_ACCREDITED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

Referenced by ilStudyProgrammeMembersTableGUI\fetchData(), and ilStudyProgrammeUserProgressTest\testPossibleActions().

735  {
736  $actions = array();
737  if ($a_node_id == $a_root_prg_id) {
738  $actions[] = self::ACTION_SHOW_INDIVIDUAL_PLAN;
739  $actions[] = self::ACTION_REMOVE_USER;
740  }
742  $actions[] = self::ACTION_UNMARK_ACCREDITED;
743  } elseif ($a_status == ilStudyProgrammeProgress::STATUS_IN_PROGRESS) {
744  $actions[] = self::ACTION_MARK_ACCREDITED;
745  }
746  return $actions;
747  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getStatus()

ilStudyProgrammeUserProgress::getStatus ( )

Get the status of the progress.

Returns
ilStudyProgrammeProgress::$STATUS

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

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

122  {
123  return $this->progress->getStatus();
124  }
+ 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 63 of file class.ilStudyProgrammeUserProgress.php.

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().

64  {
65  require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
66  $refs = ilObject::_getAllReferences($this->progress->getNodeId());
67  if (!count($refs)) {
68  throw new ilException("ilStudyProgrammeUserAssignment::getStudyProgramme: "
69  . "could not find ref_id for program '"
70  . $this->progress->getNodeId() . "'.");
71  }
72  return ilObjStudyProgramme::getInstanceByRefId(array_shift($refs));
73  }
static _getAllReferences($a_id)
get all reference ids of object
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.
+ 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 111 of file class.ilStudyProgrammeUserProgress.php.

Referenced by refreshLPStatus(), and setLPCompleted().

112  {
113  return $this->progress->getUserId();
114  }
+ 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 453 of file class.ilStudyProgrammeUserProgress.php.

References getLastChangeBy().

Referenced by updateFromProgramNode().

454  {
455  return $this->getLastChangeBy() !== null;
456  }
getLastChangeBy()
Get the id of the user who did the last change on this progress.
+ 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.

References getChildrenProgress().

Referenced by updateStatus().

597  {
598  foreach ($this->getChildrenProgress() as $child) {
599  if ($child->isSuccessful()) {
600  return true;
601  }
602  }
603  return false;
604  }
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to...
+ 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 505 of file class.ilStudyProgrammeUserProgress.php.

References getStatus(), and ilStudyProgrammeProgress\STATUS_ACCREDITED.

Referenced by getCurrentAmountOfPoints().

506  {
507  $status = $this->getStatus();
508 
510  }
getStatus()
Get the status of the progress.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFailed()

ilStudyProgrammeUserProgress::isFailed ( )

Check wether user as failed on this node.

Returns
bool

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

References getStatus(), and ilStudyProgrammeProgress\STATUS_FAILED.

478  {
479  $status = $this->getStatus();
480 
481  return $status == ilStudyProgrammeProgress::STATUS_FAILED;
482  }
getStatus()
Get the status of the progress.
+ Here is the call graph for this function:

◆ isRelevant()

ilStudyProgrammeUserProgress::isRelevant ( )

Check whether this node is relevant for the user.

Returns
bool

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

References getStatus(), and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

Referenced by 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 464 of file class.ilStudyProgrammeUserProgress.php.

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

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

465  {
466  $status = $this->getStatus();
467 
470  }
getStatus()
Get the status of the progress.
+ 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 220 of file class.ilStudyProgrammeUserProgress.php.

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

221  {
223  $prg = $this->getStudyProgramme();
224  if ($prg->getStatus() == ilStudyProgramme::STATUS_OUTDATED) {
225  throw new ilException("ilStudyProgrammeUserProgress::markAccredited: "
226  . "Can't mark as accredited since program is outdated.");
227  }
228  }
229 
230  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_ACCREDITED)
231  ->setCompletionBy($a_user_id)
232  ->update();
233 
234  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
236 
237  $this->updateParentStatus();
238  return $this;
239  }
static userSuccessful(ilStudyProgrammeUserProgress $a_progress)
updateParentStatus()
Update the status of the parent of this node.
getStudyProgramme()
Get the program node where this progress belongs to was made.
getStatus()
Get the status of the progress.
+ Here is the call graph for this function:

◆ markFailed()

ilStudyProgrammeUserProgress::markFailed (   $a_user_id)

Mark this progress as failed.

Throws when status is not STATUS_COMPLETED, STATUS_ACCREDITED, STATUS_NOT_RELEVANT.

Exceptions
ilException
Parameters
int$a_user_idThe user who performed the operation.
Returns
$this

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

References array, getStatus(), refreshLPStatus(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_FAILED, and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

275  {
279  );
280 
281  if (in_array($this->getStatus(), $status)) {
282  throw new ilException("Can't mark as failed since program is passed.");
283  }
284 
285  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_FAILED)
286  ->setLastChangeBy($a_user_id)
287  ->update();
288 
289  $this->refreshLPStatus();
290 
291  return $this;
292  }
getStatus()
Get the status of the progress.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ markNotFailed()

ilStudyProgrammeUserProgress::markNotFailed ( )

Set the node to in progress.

Throws when status is not FAILED.

Exceptions
ilException
Returns
$this

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

References refreshLPStatus(), ilStudyProgrammeProgress\STATUS_FAILED, and ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

303  {
304  if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_FAILED) {
305  throw new ilException("Expected status FAILED.");
306  }
307 
308  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_IN_PROGRESS)
309  ->setCompletionBy(null)
310  ->setLastChangeBy($a_user_id)
311  ->update();
312 
313  $this->refreshLPStatus();
314 
315  return $this;
316  }
+ 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 327 of file class.ilStudyProgrammeUserProgress.php.

References ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and updateStatus().

328  {
329  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT)
330  ->setCompletionBy($a_user_id)
331  ->setLastChangeBy($a_user_id)
332  ->update();
333 
334  $this->updateStatus();
335  return $this;
336  }
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes...
+ 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 347 of file class.ilStudyProgrammeUserProgress.php.

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

348  {
349  if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_NOT_RELEVANT) {
350  throw new ilException("Expected status IN_PROGRESS.");
351  }
352 
353  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_IN_PROGRESS)
354  ->setCompletionBy($a_user_id)
355  ->setLastChangeBy($a_user_id)
356  ->update();
357 
358  $this->updateStatus();
359  return $this;
360  }
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes...
+ Here is the call graph for this function:

◆ recalculateFailedToDeadline()

ilStudyProgrammeUserProgress::recalculateFailedToDeadline ( )

Recalculates the status according to deadline.

Returns
viod

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

References date, getDeadline(), IL_CAL_DATE, and ilStudyProgrammeProgress\STATUS_FAILED.

490  {
491  $deadline = $this->getDeadline();
492  $today = date("Y-m-d");
493 
494  if ($deadline && $deadline->get(IL_CAL_DATE) < $today) {
495  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_FAILED)
496  ->update();
497  }
498  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
const IL_CAL_DATE
getDeadline()
Get the deadline of this node.
+ Here is the call graph for this function:

◆ refreshLPStatus()

ilStudyProgrammeUserProgress::refreshLPStatus ( )
protected

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

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

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

750  {
751  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
753  }
getStudyProgramme()
Get the program node where this progress belongs to was made.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
getUserId()
Get the id of the user who is assigned.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDeadline()

ilStudyProgrammeUserProgress::setDeadline (   $deadline)

Set the deadline of this node.

Parameters
ilDateTime  |  null$deadline

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

Referenced by ilObjStudyProgrammeIndividualPlanGUI\updateDeadline().

197  {
198  return $this->progress->setDeadline($deadline);
199  }
+ 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 627 of file class.ilStudyProgrammeUserProgress.php.

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

628  {
629  if ($this->isSuccessful() || !$this->isRelevant()) {
630  return true;
631  }
632 
633  $prg = $this->getStudyProgramme();
634  if ($prg->getLPMode() != ilStudyProgramme::MODE_LP_COMPLETED) {
635  throw new ilException("ilStudyProgrammeUserProgress::setLPCompleted: "
636  . "The node '" . $prg->getId() . "' is not in LP_COMPLETED mode.");
637  }
638  if ($this->getUserId() != $a_usr_id) {
639  throw new ilException("ilStudyProgrammeUserProgress::setLPCompleted: "
640  . "This progress does belong to user '" . $this->getUserId()
641  . "' and not to user '$a_usr_id'");
642  }
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() . "'.");
646  }
647 
648  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_COMPLETED)
649  ->setCompletionBy($a_obj_id)
650  ->update();
651 
652  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
654 
655  $this->refreshLPStatus();
656  $this->updateParentStatus();
657  }
static userSuccessful(ilStudyProgrammeUserProgress $a_progress)
isRelevant()
Check whether this node is relevant for the user.
updateParentStatus()
Update the status of the parent of this node.
getStudyProgramme()
Get the program node where this progress belongs to was made.
isSuccessful()
Check whether the user was successful on this node.
getUserId()
Get the id of the user who is assigned.
+ 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 372 of file class.ilStudyProgrammeUserProgress.php.

References updateStatus().

373  {
374  $this->progress->setAmountOfPoints($a_points)
375  ->setLastChangeBy($a_user_id)
376  ->update();
377 
378  $this->updateStatus();
379  return $this;
380  }
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes...
+ Here is the call 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 249 of file class.ilStudyProgrammeUserProgress.php.

References refreshLPStatus(), ilStudyProgrammeProgress\STATUS_ACCREDITED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, and updateParentStatus().

250  {
251  if ($this->progress->getStatus() != ilStudyProgrammeProgress::STATUS_ACCREDITED) {
252  throw new ilException("Expected status ACCREDITED.");
253  }
254 
255  $this->progress->setStatus(ilStudyProgrammeProgress::STATUS_IN_PROGRESS)
256  ->setCompletionBy(null)
257  ->update();
258 
259  $this->refreshLPStatus();
260 
261  $this->updateParentStatus();
262  return $this;
263  }
updateParentStatus()
Update the status of the parent of this node.
+ 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 529 of file class.ilStudyProgrammeUserProgress.php.

References getStatus(), getStudyProgramme(), hasIndividualModifications(), ilStudyProgramme\STATUS_ACTIVE, ilStudyProgrammeProgress\STATUS_COMPLETED, ilStudyProgrammeProgress\STATUS_IN_PROGRESS, ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, League\Flysystem\Adapter\Polyfill\update(), and updateStatus().

530  {
531  if ($this->hasIndividualModifications()) {
532  return false;
533  }
535  return false;
536  }
537 
538  $prg = $this->getStudyProgramme();
539  $this->progress->setAmountOfPoints($prg->getPoints())
540  ->setStatus(
541  $prg->getStatus() == ilStudyProgramme::STATUS_ACTIVE
544  )
545  ->update();
546 
547  $this->updateStatus();
548  }
getStudyProgramme()
Get the program node where this progress belongs to was made.
getStatus()
Get the status of the progress.
hasIndividualModifications()
Check whether there are individual modifications for the user on this program.
update($pash, $contents, Config $config)
updateStatus()
Updates the status of this progress based on the status of the progress on the sub nodes...
+ 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.

References getParentProgress().

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

610  {
611  $parent = $this->getParentProgress();
612  if ($parent) {
613  $parent->updateStatus();
614  }
615  }
getParentProgress()
Get the progress on the parent node for the same assignment this progress belongs to...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateProgress()

ilStudyProgrammeUserProgress::updateProgress (   $user_id)

Updates current progress.

Parameters
int$user_id
Returns
void

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

Referenced by ilObjStudyProgrammeIndividualPlanGUI\updateDeadline().

763  {
764  $this->progress->setLastChangeBy($user_id)
765  ->update();
766  }
+ 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 554 of file class.ilStudyProgrammeUserProgress.php.

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().

555  {
556  $prg = $this->getStudyProgramme();
557  if (($prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED
560  // Nothing to do here, as the status will be set by LP.
561  // OR current status is NOT RELEVANT
562  return;
563  }
564 
565  $add = function ($a, $b) {
566  return $a + $b;
567  };
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  }
getChildrenProgress()
Get the progresses on the child nodes of this node for the same assignment this progress belongs to...
static userSuccessful(ilStudyProgrammeUserProgress $a_progress)
updateParentStatus()
Update the status of the parent of this node.
getStudyProgramme()
Get the program node where this progress belongs to was made.
getStatus()
Get the status of the progress.
getAmountOfPoints()
Get the amount of points needed to complete the node.
+ 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 17 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: