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.

References array, and ActiveRecord\where().

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  }
Base class for ILIAS Exception handling.
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 464 of file class.ilStudyProgrammeUserProgress.php.

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

Referenced by ilStudyProgrammeIndividualPlanProgressListGUI\buildProgressStatus().

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

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

257  {
258  return $this->progress->getAmountOfPoints();
259  }
+ 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.

References ilStudyProgrammeUserAssignment\getInstance().

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

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

References getStudyProgramme(), and ilStudyProgramme\MODE_LP_COMPLETED.

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

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  }
Base class for ILIAS Exception handling.
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 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.

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

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

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

◆ getId()

ilStudyProgrammeUserProgress::getId ( )

Get the id of the progress.

Returns
int

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

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

220  {
221  return $this->progress->getId();
222  }
+ 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.

References array.

Referenced by ilStudyProgrammeIndividualPlanTableGUI\fetchData().

61  {
62  return new ilStudyProgrammeUserProgress(array($a_assignment_id, $a_program_id, $a_user_id));
63  }
Create styles array
The data for the language used.
Represents the progress of a user at one node of a study programme.
+ 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.

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

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  }
Base class for ILIAS Exception handling.
Represents the progress of a user at one node of a study programme.
+ 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.

References array, and ActiveRecord\where().

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

106  {
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.
static where($where, $operator=null)
Create styles array
The data for the language used.
Represents the progress of a user at one node of a study programme.
+ 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.

References array, and ActiveRecord\where().

Referenced by ilStudyProgrammeUserAssignment\delete().

131  {
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  }
Exception is thrown when a progress for some programme node and assignment is missing.
static where($where, $operator=null)
Create styles array
The data for the language used.
Represents the progress of a user at one node of a study programme.
+ 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.

References array, and ActiveRecord\where().

Referenced by ilObjStudyProgramme\getProgresses().

152  {
154  ( "prg_id" => $a_program_id
155  ))->get();
156  return array_values(array_map(function($dat) {
157  return new ilStudyProgrammeUserProgress($dat);
158  }, $progresses));
159  }
static where($where, $operator=null)
Create styles array
The data for the language used.
Represents the progress of a user at one node of a study programme.
+ 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.

References array, and ActiveRecord\where().

Referenced by ilObjStudyProgramme\getProgressesOf().

86  {
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  }
static where($where, $operator=null)
Create styles array
The data for the language used.
Represents the progress of a user at one node of a study programme.
+ 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.

Referenced by hasIndividualModifications().

288  {
289  return $this->progress->getLastChangeBy();
290  }
+ 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.

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

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

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

References $names, array, and getStudyProgramme().

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

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

Referenced by updateParentStatus().

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

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

Referenced by ilStudyProgrammeMembersTableGUI\fetchData().

730  {
731  $actions = array();
732  if ($a_node_id == $a_root_prg_id) {
733  $actions[] = self::ACTION_SHOW_INDIVIDUAL_PLAN;
734  $actions[] = self::ACTION_REMOVE_USER;
735  }
737  $actions[] = self::ACTION_UNMARK_ACCREDITED;
738  }
739  else if ($a_status == ilStudyProgrammeProgress::STATUS_IN_PROGRESS) {
740  $actions[] = self::ACTION_MARK_ACCREDITED;
741  }
742  return $actions;
743  }
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 247 of file class.ilStudyProgrammeUserProgress.php.

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

247  {
248  return $this->progress->getStatus();
249  }
+ 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.

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

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  }
Base class for ILIAS Exception handling.
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 238 of file class.ilStudyProgrammeUserProgress.php.

Referenced by refreshLPStatus(), and setLPCompleted().

238  {
239  return $this->progress->getUserId();
240  }
+ 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.

References getLastChangeBy().

Referenced by updateFromProgramNode().

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

References getStatus(), and ilStudyProgrammeProgress\STATUS_ACCREDITED.

Referenced by getCurrentAmountOfPoints().

512  {
513  $status = $this->getStatus();
514 
516  }
getStatus()
Get the status of the progress.
+ 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 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.

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

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

500  {
501  $status = $this->getStatus();
502 
505  }
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 319 of file class.ilStudyProgrammeUserProgress.php.

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

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  }
Base class for ILIAS Exception handling.
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:

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

References ilStudyProgrammeProgress\STATUS_NOT_RELEVANT, and updateStatus().

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

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

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  }
Base class for ILIAS Exception handling.
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:

◆ refreshLPStatus()

ilStudyProgrammeUserProgress::refreshLPStatus ( )
protected

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

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

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

745  {
746  require_once("Services/Tracking/classes/class.ilLPStatusWrapper.php");
748  }
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:

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

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

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  }
Base class for ILIAS Exception handling.
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 414 of file class.ilStudyProgrammeUserProgress.php.

References updateStatus().

414  {
415  $this->progress->setAmountOfPoints($a_points)
416  ->setLastChangeBy($a_user_id)
417  ->update();
418 
419  $this->updateStatus();
420  return $this;
421  }
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:

◆ statusToRepr()

static ilStudyProgrammeUserProgress::statusToRepr (   $a_status)
static

Get a user readable representation of a status.

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

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

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  }
Base class for ILIAS Exception handling.
global $lng
Definition: privfeed.php:17
global $DIC
+ 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.

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

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  }
Base class for ILIAS Exception handling.
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 534 of file class.ilStudyProgrammeUserProgress.php.

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

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

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

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

557  {
558  $prg = $this->getStudyProgramme();
559  if (( $prg->getLPMode() == ilStudyProgramme::MODE_LP_COMPLETED
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  }
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 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: