ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilStudyProgrammeUserAssignment Class Reference

Represents one assignment of a user to a study programme. More...

+ Collaboration diagram for ilStudyProgrammeUserAssignment:

Public Member Functions

 __construct ($a_id_or_model)
 Throws when id does not refer to a study programme assignment. More...
 
 getId ()
 Get the id of the assignment. More...
 
 getStudyProgramme ()
 Get the program node where this assignment was made. More...
 
 getRootProgress ()
 Get the progress on the root node of the programme. More...
 
 getUserId ()
 Get the id of the user who is assigned. More...
 
 deassign ()
 Remove this assignment. More...
 
 delete ()
 Delete the assignment from database. More...
 
 addMissingProgresses ()
 Add missing progresses for new nodes in the programm. More...
 

Static Public Member Functions

static getInstance ($a_id)
 Get an instance. More...
 
static getInstancesOfUser ($a_user_id)
 Get all instances for a given user. More...
 
static getInstancesForProgram ($a_program_id)
 Get all assignments that were made to the given program. More...
 

Data Fields

 $assignment
 

Detailed Description

Represents one assignment of a user to a study programme.

A user could have multiple assignments per programme.

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 14 of file class.ilStudyProgrammeUserAssignment.php.

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeUserAssignment::__construct (   $a_id_or_model)

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

Exceptions
ilException
Parameters
int  |  ilStudyProgrammeAssignment$a_id_or_model

Definition at line 23 of file class.ilStudyProgrammeUserAssignment.php.

23  {
24  if ($a_id_or_model instanceof ilStudyProgrammeAssignment) {
25  $this->assignment = $a_id_or_model;
26  }
27  else {
28  $this->assignment = ilStudyProgrammeAssignment::find($a_id_or_model);
29  }
30  if ($this->assignment === null) {
31  throw new ilException("ilStudyProgrammeUserAssignment::__construct: "
32  ."Unknown assignmemt id '$a_id_or_model'.");
33  }
34  }
Base class for ILIAS Exception handling.
Class ilStudyProgrammeAssignment.

Member Function Documentation

◆ addMissingProgresses()

ilStudyProgrammeUserAssignment::addMissingProgresses ( )

Add missing progresses for new nodes in the programm.

The new progresses will be set to not relevant.

Returns
$this

Definition at line 185 of file class.ilStudyProgrammeUserAssignment.php.

References $ilLog, ilStudyProgrammeProgress\createFor(), getId(), getStudyProgramme(), and ilStudyProgrammeProgress\STATUS_NOT_RELEVANT.

185  {
186  require_once("Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
187 
188  $prg = $this->getStudyProgramme();
189  $id = $this->getId();
190 
191  // TODO: $this could be removed as soon as support for PHP 5.3 is dropped:
192  $self = $this;
193  // Make $this->assignment protected again afterwards.
194  $prg->applyToSubTreeNodes(function($node) use ($id, $self) {
195  try {
196  $node->getProgressForAssignment($id);
197  }
199  global $ilLog;
200  $ilLog->write("Adding progress for: ".$self->getId()." ".$node->getId());
201  require_once("Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
202  $progress = ilStudyProgrammeProgress::createFor($node->getRawSettings(), $self->assignment);
204  ->update();
205  }
206  });
207 
208  return $this;
209  }
static createFor(ilStudyProgramme $a_prg, ilStudyProgrammeAssignment $a_ass)
Create a new progress object for a given program node and assignment.
getStudyProgramme()
Get the program node where this assignment was made.
Exception is thrown when a progress for some programme node and assignment is missing.
+ Here is the call graph for this function:

◆ deassign()

ilStudyProgrammeUserAssignment::deassign ( )

Remove this assignment.

Definition at line 139 of file class.ilStudyProgrammeUserAssignment.php.

References getStudyProgramme().

139  {
140  $this->getStudyProgramme()->removeAssignment($this);
141  }
getStudyProgramme()
Get the program node where this assignment was made.
+ Here is the call graph for this function:

◆ delete()

ilStudyProgrammeUserAssignment::delete ( )

Delete the assignment from database.

Definition at line 146 of file class.ilStudyProgrammeUserAssignment.php.

References getId(), ilStudyProgrammeUserProgress\getInstancesForAssignment(), and getStudyProgramme().

Referenced by ilObjStudyProgramme\removeAssignment().

146  {
147  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
149  foreach ($progresses as $progress) {
150  $progress->delete();
151  }
152 
153  $this->assignment->delete();
154  }
static getInstancesForAssignment($a_assignment_id)
Get the instance for an assignment.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilStudyProgrammeUserAssignment::getId ( )

◆ getInstance()

static ilStudyProgrammeUserAssignment::getInstance (   $a_id)
static

Get an instance.

Just wraps constructor.

Exceptions
ilException
Parameters
int$a_id
Returns
ilStudyProgrammeUserAssignment

Definition at line 43 of file class.ilStudyProgrammeUserAssignment.php.

Referenced by ilStudyProgrammeUserProgress\getAssignment(), and ilObjStudyProgrammeIndividualPlanGUI\getAssignmentObject().

43  {
44  return new ilStudyProgrammeUserAssignment($a_id);
45  }
Represents one assignment of a user to a study programme.
+ Here is the caller graph for this function:

◆ getInstancesForProgram()

static ilStudyProgrammeUserAssignment::getInstancesForProgram (   $a_program_id)
static

Get all assignments that were made to the given program.

Parameters
int$a_program_id
Returns
ilStudyProgrammeUserAssignment[]

Definition at line 81 of file class.ilStudyProgrammeUserAssignment.php.

References ActiveRecord\where().

Referenced by ilObjStudyProgramme\updateAllAssignments().

81  {
82  $assignments = ilStudyProgrammeAssignment::where(array( "root_prg_id" => $a_program_id ))
83  ->get();
84  return array_map(function($ass) {
85  return new ilStudyProgrammeUserAssignment($ass);
86  }, array_values($assignments)); // use array values since we want keys 0...
87  }
static where($where, $operator=NULL)
Represents one assignment of a user to a study programme.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstancesOfUser()

static ilStudyProgrammeUserAssignment::getInstancesOfUser (   $a_user_id)
static

Get all instances for a given user.

Parameters
int$a_user_id
Returns
ilStudyProgrammeUserAssignment[]

Definition at line 53 of file class.ilStudyProgrammeUserAssignment.php.

References $ret, ilObject\_getAllReferences(), and ActiveRecord\where().

Referenced by ilStudyProgrammeAppEventListener\onServiceUserDeleteUser(), and ilPDStudyProgrammeSimpleListGUI\readUsersAssignments().

53  {
54  global $tree;
55 
56  $assignments = ilStudyProgrammeAssignment::where(array( "usr_id" => $a_user_id ))
57  ->get();
58 
59  //if parent object is deleted or in trash
60  //the assignment for the user should not be returned
61  $ret = array();
62  foreach($assignments as $ass) {
63  $ass_obj = new ilStudyProgrammeUserAssignment($ass);
64  foreach (ilObject::_getAllReferences($ass_obj->assignment->getRootId()) as $value) {
65  if($tree->isInTree($value)) {
66  $ret[] = $ass_obj;
67  break;
68  }
69  }
70  }
71 
72  return $ret;
73  }
static _getAllReferences($a_id)
get all reference ids of object
static where($where, $operator=NULL)
Represents one assignment of a user to a study programme.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRootProgress()

ilStudyProgrammeUserAssignment::getRootProgress ( )

Get the progress on the root node of the programme.

Exceptions
ilException
Returns
ilStudyProgrammeUserProgress

Definition at line 123 of file class.ilStudyProgrammeUserAssignment.php.

References getId(), and getStudyProgramme().

123  {
124  return $this->getStudyProgramme()->getProgressForAssignment($this->getId());
125  }
getStudyProgramme()
Get the program node where this assignment was made.
+ Here is the call graph for this function:

◆ getStudyProgramme()

ilStudyProgrammeUserAssignment::getStudyProgramme ( )

Get the program node where this assignment was made.

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

Exceptions
ilException
Returns
ilObjStudyProgramme

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

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

Referenced by addMissingProgresses(), deassign(), delete(), getRootProgress(), ilPDStudyProgrammeSimpleListGUI\hasPermission(), ilPDStudyProgrammeExpandableListGUI\new_ilStudyProgrammeAssignmentListGUI(), ilPDStudyProgrammeSimpleListGUI\new_ilStudyProgrammeAssignmentListGUI(), ilObjStudyProgramme\removeAssignment(), ilStudyProgrammeEvents\userAssigned(), and ilStudyProgrammeEvents\userDeassigned().

106  {
107  require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
108  $refs = ilObject::_getAllReferences($this->assignment->getRootId());
109  if (!count($refs)) {
110  throw new ilException("ilStudyProgrammeUserAssignment::getStudyProgramme: "
111  ."could not find ref_id for program '"
112  .$this->assignment->getRootId()."'.");
113  }
114  return ilObjStudyProgramme::getInstanceByRefId(array_shift($refs));
115  }
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()

ilStudyProgrammeUserAssignment::getUserId ( )

Get the id of the user who is assigned.

Returns
int

Definition at line 132 of file class.ilStudyProgrammeUserAssignment.php.

Referenced by ilStudyProgrammeEvents\userAssigned(), and ilStudyProgrammeEvents\userDeassigned().

132  {
133  return $this->assignment->getUserId();
134  }
+ Here is the caller graph for this function:

Field Documentation

◆ $assignment

ilStudyProgrammeUserAssignment::$assignment

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


The documentation for this class was generated from the following file: