ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 186 of file class.ilStudyProgrammeUserAssignment.php.

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

186  {
187  require_once("Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
188 
189  $prg = $this->getStudyProgramme();
190  $id = $this->getId();
191 
192  // Make $this->assignment protected again afterwards.
193  $prg->applyToSubTreeNodes(function($node) use ($id) {
194  try {
195  $node->getProgressForAssignment($id);
196  }
198  global $DIC;
199  $ilLog = $DIC['ilLog'];
200  $ilLog->write("Adding progress for: ".$this->getId()." ".$node->getId());
201  require_once("Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
202  $progress = ilStudyProgrammeProgress::createFor($node->getRawSettings(), $this->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.
global $DIC
+ Here is the call graph for this function:

◆ deassign()

ilStudyProgrammeUserAssignment::deassign ( )

Remove this assignment.

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

References getStudyProgramme().

140  {
141  $this->getStudyProgramme()->removeAssignment($this);
142  }
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 147 of file class.ilStudyProgrammeUserAssignment.php.

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

Referenced by ilObjStudyProgramme\removeAssignment().

147  {
148  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
150  foreach ($progresses as $progress) {
151  $progress->delete();
152  }
153 
154  $this->assignment->delete();
155  }
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 82 of file class.ilStudyProgrammeUserAssignment.php.

References array, and ActiveRecord\where().

Referenced by ilObjStudyProgramme\updateAllAssignments().

82  {
83  $assignments = ilStudyProgrammeAssignment::where(array( "root_prg_id" => $a_program_id ))
84  ->get();
85  return array_map(function($ass) {
86  return new ilStudyProgrammeUserAssignment($ass);
87  }, array_values($assignments)); // use array values since we want keys 0...
88  }
static where($where, $operator=null)
Create styles array
The data for the language used.
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 $DIC, $ret, ilObject\_getAllReferences(), array, and ActiveRecord\where().

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

53  {
54  global $DIC;
55  $tree = $DIC['tree'];
56 
57  $assignments = ilStudyProgrammeAssignment::where(array( "usr_id" => $a_user_id ))
58  ->get();
59 
60  //if parent object is deleted or in trash
61  //the assignment for the user should not be returned
62  $ret = array();
63  foreach($assignments as $ass) {
64  $ass_obj = new ilStudyProgrammeUserAssignment($ass);
65  foreach (ilObject::_getAllReferences($ass_obj->assignment->getRootId()) as $value) {
66  if($tree->isInTree($value)) {
67  $ret[] = $ass_obj;
68  break;
69  }
70  }
71  }
72 
73  return $ret;
74  }
static where($where, $operator=null)
static _getAllReferences($a_id)
get all reference ids of object
Create styles array
The data for the language used.
$ret
Definition: parser.php:6
global $DIC
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 124 of file class.ilStudyProgrammeUserAssignment.php.

References getId(), and getStudyProgramme().

124  {
125  return $this->getStudyProgramme()->getProgressForAssignment($this->getId());
126  }
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 107 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().

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

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

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

Field Documentation

◆ $assignment

ilStudyProgrammeUserAssignment::$assignment

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

Referenced by addMissingProgresses().


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