ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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, \ilStudyProgrammeUserProgressDB $sp_user_progress_db)
 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
 

Private Attributes

 $sp_user_progress_db
 

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,
\ilStudyProgrammeUserProgressDB  $sp_user_progress_db 
)

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

Exceptions
ilException
Parameters
int  |  ilStudyProgrammeAssignment$a_id_or_model

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

30 {
31 if ($a_id_or_model instanceof ilStudyProgrammeAssignment) {
32 $this->assignment = $a_id_or_model;
33 } else {
34 $this->assignment = ilStudyProgrammeAssignment::find($a_id_or_model);
35 }
36 if ($this->assignment === null) {
37 throw new ilException("ilStudyProgrammeUserAssignment::__construct: "
38 . "Unknown assignmemt id '$a_id_or_model'.");
39 }
40 $this->sp_user_progress_db = $sp_user_progress_db;
41 }
Base class for ILIAS Exception handling.
Class ilStudyProgrammeAssignment.

References $sp_user_progress_db.

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

203 {
204 require_once("Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
205
206 $prg = $this->getStudyProgramme();
207 $id = $this->getId();
208
209 // Make $this->assignment protected again afterwards.
210 $prg->applyToSubTreeNodes(function ($node) use ($id) {
211 try {
212 $node->getProgressForAssignment($id);
214 global $DIC;
215 $ilLog = $DIC['ilLog'];
216 $ilLog->write("Adding progress for: " . $this->getId() . " " . $node->getId());
217 require_once("Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
218 $progress = ilStudyProgrammeProgress::createFor($node->getRawSettings(), $this->assignment);
220 ->update();
221 }
222 });
223
224 return $this;
225 }
Exception is thrown when a progress for some programme node and assignment is missing.
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
global $DIC
Definition: saml.php:7

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

+ Here is the call graph for this function:

◆ deassign()

ilStudyProgrammeUserAssignment::deassign ( )

Remove this assignment.

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

155 {
156 $this->getStudyProgramme()->removeAssignment($this);
157 }

References getStudyProgramme().

+ Here is the call graph for this function:

◆ delete()

ilStudyProgrammeUserAssignment::delete ( )

Delete the assignment from database.

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

163 {
164 $progresses = $this->sp_user_progress_db->getInstancesForAssignment($this->getId());
165 foreach ($progresses as $progress) {
166 $progress->delete();
167 }
168
169 $this->assignment->delete();
170 }

References getId().

Referenced by ilObjStudyProgramme\removeAssignment().

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

51 {
53 }
static _getStudyProgrammeUserProgressDB()
Get an instance of ilStudyProgrammeUserProgressDB.
Represents one assignment of a user to a study programme.

References ilObjStudyProgramme\_getStudyProgrammeUserProgressDB().

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

+ Here is the call graph for this function:
+ 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 91 of file class.ilStudyProgrammeUserAssignment.php.

92 {
93 $assignments = ilStudyProgrammeAssignment::where(array( "root_prg_id" => $a_program_id ))
94 ->get();
95 return array_map(function ($ass) {
97 }, array_values($assignments)); // use array values since we want keys 0...
98 }
static where($where, $operator=null)

References ilObjStudyProgramme\_getStudyProgrammeUserProgressDB(), and ActiveRecord\where().

Referenced by ilObjStudyProgramme\updateAllAssignments().

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

62 {
63 global $DIC;
64 $tree = $DIC['tree'];
65
66 $assignments = ilStudyProgrammeAssignment::where(array( "usr_id" => $a_user_id ))
67 ->get();
68
69 //if parent object is deleted or in trash
70 //the assignment for the user should not be returned
71 $ret = array();
72 foreach ($assignments as $ass) {
74 foreach (ilObject::_getAllReferences($ass_obj->assignment->getRootId()) as $value) {
75 if ($tree->isInTree($value)) {
76 $ret[] = $ass_obj;
77 break;
78 }
79 }
80 }
81
82 return $ret;
83 }
static _getAllReferences($a_id)
get all reference ids of object
$ret
Definition: parser.php:6

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

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

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

137 {
138 return $this->getStudyProgramme()->getProgressForAssignment($this->getId());
139 }

References getId(), and getStudyProgramme().

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

119 {
120 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
121 $refs = ilObject::_getAllReferences($this->assignment->getRootId());
122 if (!count($refs)) {
123 throw new ilException("ilStudyProgrammeUserAssignment::getStudyProgramme: "
124 . "could not find ref_id for program '"
125 . $this->assignment->getRootId() . "'.");
126 }
127 return ilObjStudyProgramme::getInstanceByRefId(array_shift($refs));
128 }
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.

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

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

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

147 {
148 return $this->assignment->getUserId();
149 }

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

+ Here is the caller graph for this function:

Field Documentation

◆ $assignment

ilStudyProgrammeUserAssignment::$assignment

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

◆ $sp_user_progress_db

ilStudyProgrammeUserAssignment::$sp_user_progress_db
private

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

Referenced by __construct().


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