ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilIndividualAssessmentMembers Class Reference

Member administration related logic, add and remove members, get the list of all members, etc ... More...

+ Inheritance diagram for ilIndividualAssessmentMembers:
+ Collaboration diagram for ilIndividualAssessmentMembers:

Public Member Functions

 __construct (ilObjIndividualAssessment $iass)
 
 count ()
 Countable Methods. More...
 
 current ()
 Iterator Methods. More...
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 
 referencedObject ()
 Get the Individual assessment object that is corresponding to this. More...
 
 recordOK (array $record)
 Check the validity of a record before adding it to this. More...
 
 userAllreadyMemberByUsrId ($usr_id)
 Check if a user with user_id is member of this. More...
 
 userAllreadyMember (ilObjUser $usr)
 Check if a user is member of this. More...
 
 withAdditionalRecord (array $record)
 Clone this and add a record. More...
 
 withAdditionalUser (ilObjUser $usr)
 Clone this and add a record created for user. More...
 
 withoutPresentUser (ilObjUser $usr)
 Clone this and remove record corresponding to user. More...
 
 withOnlyUsersByIds (array $keep_users_ids)
 Remove all users that do not exist in list of given ids. More...
 
 withAccessHandling (ilOrgUnitPositionAndRBACAccessHandler $access_handler)
 Get a collection like this, but only including users that are visible according to the supplied access handler. More...
 
 membersIds ()
 Get the ids of all the users being member in this iass. More...
 
 updateStorageAndRBAC (ilIndividualAssessmentMembersStorage $storage, IndividualAssessmentAccessHandler $access_handler)
 Store the data to a persistent medium. More...
 

Data Fields

const FIELD_FIRSTNAME = 'firstname'
 
const FIELD_LASTNAME = 'lastname'
 
const FIELD_LOGIN = 'login'
 
const FIELD_USR_ID = 'usr_id'
 
const FIELD_LEARNING_PROGRESS = 'learning_progress'
 
const FIELD_EXAMINER_ID = 'examiner_id'
 
const FIELD_EXAMINER_FIRSTNAME = 'examiner_firstname'
 
const FIELD_EXAMINER_LASTNAME = 'examiner_lastname'
 
const FIELD_CHANGER_ID = "changer_id"
 
const FIELD_CHANGER_FIRSTNAME = "changer_firstname"
 
const FIELD_CHANGER_LASTNAME = "changer_lastname"
 
const FIELD_CHANGE_TIME = "change_time"
 
const FIELD_RECORD = 'record'
 
const FIELD_INTERNAL_NOTE = 'internal_note'
 
const FIELD_NOTIFY = 'notify'
 
const FIELD_FINALIZED = 'finalized'
 
const FIELD_NOTIFICATION_TS = 'notification_ts'
 
const FIELD_PLACE = "place"
 
const FIELD_EVENTTIME = "event_time"
 
const FIELD_FILE_NAME = "file_name"
 
const FIELD_USER_VIEW_FILE = "user_view_file"
 
const LP_NOT_ATTEMPTED = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM
 
const LP_IN_PROGRESS = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM
 
const LP_COMPLETED = ilLPStatus::LP_STATUS_COMPLETED_NUM
 
const LP_FAILED = ilLPStatus::LP_STATUS_FAILED_NUM
 
const LP_ASSESSMENT_NOT_COMPLETED = "not_completed"
 

Protected Member Functions

 userExists (int $usr_id)
 
 buildNewRecordOfUser (ilObjUser $usr)
 

Protected Attributes

array $member_records = array()
 
int $position = 0
 
ilObjIndividualAssessment $iass
 

Detailed Description

Member administration related logic, add and remove members, get the list of all members, etc ...

Definition at line 25 of file class.ilIndividualAssessmentMembers.php.

Constructor & Destructor Documentation

◆ __construct()

ilIndividualAssessmentMembers::__construct ( ilObjIndividualAssessment  $iass)

Definition at line 59 of file class.ilIndividualAssessmentMembers.php.

60 {
61 $this->iass = $iass;
62 }

References $iass.

Member Function Documentation

◆ buildNewRecordOfUser()

ilIndividualAssessmentMembers::buildNewRecordOfUser ( ilObjUser  $usr)
protected

Definition at line 192 of file class.ilIndividualAssessmentMembers.php.

192 : array
193 {
194 return [
195 self::FIELD_USR_ID => $usr->getId(),
196 self::FIELD_RECORD => $this->iass->getSettings()->getRecordTemplate(),
197 self::FIELD_NOTIFY => 0,
198 self::FIELD_FIRSTNAME => $usr->getFirstname(),
199 self::FIELD_LASTNAME => $usr->getLastname(),
200 self::FIELD_LOGIN => $usr->getLogin(),
201 self::FIELD_LEARNING_PROGRESS => self::LP_NOT_ATTEMPTED,
202 self::FIELD_EXAMINER_ID => null,
203 self::FIELD_EXAMINER_FIRSTNAME => null,
204 self::FIELD_EXAMINER_LASTNAME => null,
205 self::FIELD_INTERNAL_NOTE => null,
206 self::FIELD_FILE_NAME => null,
207 self::FIELD_USER_VIEW_FILE => false,
208 self::FIELD_FINALIZED => 0,
209 self::FIELD_CHANGER_ID => null,
210 self::FIELD_CHANGER_FIRSTNAME => null,
211 self::FIELD_CHANGER_LASTNAME => null
212 ];
213 }

References ilObjUser\getFirstname(), ilObject\getId(), ilObjUser\getLastname(), ilObjUser\getLogin(), and LP_NOT_ATTEMPTED.

Referenced by TestObj\buildNewRecordOfUserWrapper(), and withAdditionalUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ count()

ilIndividualAssessmentMembers::count ( )

Countable Methods.

Definition at line 67 of file class.ilIndividualAssessmentMembers.php.

67 : int
68 {
69 return count($this->member_records);
70 }

References count().

Referenced by count(), and valid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current()

ilIndividualAssessmentMembers::current ( )

Iterator Methods.

Returns
false|mixed

Definition at line 76 of file class.ilIndividualAssessmentMembers.php.

76 : mixed
77 {
78 return current($this->member_records);
79 }

References current().

Referenced by current().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ key()

ilIndividualAssessmentMembers::key ( )
Returns
int|string|null

Definition at line 84 of file class.ilIndividualAssessmentMembers.php.

84 : mixed
85 {
86 return key($this->member_records);
87 }

References key().

Referenced by key().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ membersIds()

ilIndividualAssessmentMembers::membersIds ( )

Get the ids of all the users being member in this iass.

Returns
int[]|string[]

Definition at line 267 of file class.ilIndividualAssessmentMembers.php.

267 : array
268 {
269 return array_keys($this->member_records);
270 }

Referenced by withOnlyUsersByIds().

+ Here is the caller graph for this function:

◆ next()

ilIndividualAssessmentMembers::next ( )

Definition at line 89 of file class.ilIndividualAssessmentMembers.php.

89 : void
90 {
91 $this->position++;
92 next($this->member_records);
93 }

References next().

Referenced by next().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recordOK()

ilIndividualAssessmentMembers::recordOK ( array  $record)

Check the validity of a record before adding it to this.

Parameters
int | string | null[]$record
Returns
bool

Definition at line 120 of file class.ilIndividualAssessmentMembers.php.

120 : bool
121 {
122 if (isset($record[self::FIELD_USR_ID])) {
123 if (
124 !$this->userExists((int) $record[self::FIELD_USR_ID]) ||
125 $this->userAllreadyMemberByUsrId($record[self::FIELD_USR_ID])
126 ) {
127 return false;
128 }
129 }
130 if (!in_array(
131 $record[self::FIELD_LEARNING_PROGRESS],
132 array(self::LP_NOT_ATTEMPTED, self::LP_FAILED, self::LP_COMPLETED, self::LP_IN_PROGRESS)
133 )
134 ) {
135 return false;
136 }
137 return true;
138 }
userAllreadyMemberByUsrId($usr_id)
Check if a user with user_id is member of this.

References userAllreadyMemberByUsrId(), and userExists().

Referenced by withAdditionalRecord().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ referencedObject()

ilIndividualAssessmentMembers::referencedObject ( )

Get the Individual assessment object that is corresponding to this.

Definition at line 109 of file class.ilIndividualAssessmentMembers.php.

110 {
111 return $this->iass;
112 }
For the purpose of streamlining the grading and learning-process status definition outside of tests,...

References $iass.

◆ rewind()

ilIndividualAssessmentMembers::rewind ( )

Definition at line 95 of file class.ilIndividualAssessmentMembers.php.

95 : void
96 {
97 $this->position = 0;
98 reset($this->member_records);
99 }

◆ updateStorageAndRBAC()

ilIndividualAssessmentMembers::updateStorageAndRBAC ( ilIndividualAssessmentMembersStorage  $storage,
IndividualAssessmentAccessHandler  $access_handler 
)

Store the data to a persistent medium.

Parameters
ilIndividualAssessmentMembersStorage$storage
IndividualAssessmentAccessHandler$access_handler

Definition at line 278 of file class.ilIndividualAssessmentMembers.php.

281 : void {
282 $current = $storage->loadMembers($this->referencedObject());
283 $iass = $this->referencedObject();
284 foreach ($this as $usr_id => $record) {
285 if (!$current->userAllreadyMemberByUsrId($usr_id)) {
286 $storage->insertMembersRecord($this->referencedObject(), $record);
287 $access_handler->assignUserToMemberRole(new ilObjUser($usr_id), $iass);
288 }
289 }
290 foreach ($current as $usr_id => $record) {
291 if (!$this->userAllreadyMemberByUsrId($usr_id)) {
292 $storage->removeMembersRecord($this->referencedObject(), $record);
293 $access_handler->deassignUserFromMemberRole(new ilObjUser($usr_id), $iass);
294 }
295 }
296 }
referencedObject()
Get the Individual assessment object that is corresponding to this.
User class.
assignUserToMemberRole(ilObjUser $usr, ilObjIndividualAssessment $iass)
Assign a user to the member role at an Individual assessment.
deassignUserFromMemberRole(ilObjUser $usr, ilObjIndividualAssessment $iass)
Deasign a user from the member role at an Individual assessment.
insertMembersRecord(ilObjIndividualAssessment $iass, array $record)
Create a membership inside storage.
removeMembersRecord(ilObjIndividualAssessment $iass, array $record)
Remove a membership associated with a IndividualAssessment object inside storage.
loadMembers(ilObjIndividualAssessment $obj)
Get ilIndividualAssessmentMembers-object containing member info associated with $obj.

Referenced by ilObjIndividualAssessment\updateMembers().

+ Here is the caller graph for this function:

◆ userAllreadyMember()

ilIndividualAssessmentMembers::userAllreadyMember ( ilObjUser  $usr)

Check if a user is member of this.

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

154 : bool
155 {
156 return $this->userAllreadyMemberByUsrId($usr->getId());
157 }

References ilObject\getId(), and userAllreadyMemberByUsrId().

Referenced by withAdditionalUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userAllreadyMemberByUsrId()

ilIndividualAssessmentMembers::userAllreadyMemberByUsrId (   $usr_id)

Check if a user with user_id is member of this.

Parameters
int | string$usr_id
Returns
bool

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

146 : bool
147 {
148 return isset($this->member_records[$usr_id]);
149 }

Referenced by recordOK(), and userAllreadyMember().

+ Here is the caller graph for this function:

◆ userExists()

ilIndividualAssessmentMembers::userExists ( int  $usr_id)
protected

Reimplemented in TestObj.

Definition at line 159 of file class.ilIndividualAssessmentMembers.php.

159 : bool
160 {
161 return ilObjUser::_exists($usr_id, false, 'usr');
162 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data

References ilObject\_exists().

Referenced by recordOK().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ valid()

ilIndividualAssessmentMembers::valid ( )

Definition at line 101 of file class.ilIndividualAssessmentMembers.php.

101 : bool
102 {
103 return $this->position < count($this->member_records);
104 }

References count().

+ Here is the call graph for this function:

◆ withAccessHandling()

ilIndividualAssessmentMembers::withAccessHandling ( ilOrgUnitPositionAndRBACAccessHandler  $access_handler)

Get a collection like this, but only including users that are visible according to the supplied access handler.

Definition at line 248 of file class.ilIndividualAssessmentMembers.php.

251 return $this->withOnlyUsersByIds(
253 "read_learning_progress",
254 "read_learning_progress",
255 $this->referencedObject()->getRefId(),
256 $this->membersIds()
257 )
258 );
259 }
Member administration related logic, add and remove members, get the list of all members,...
withOnlyUsersByIds(array $keep_users_ids)
Remove all users that do not exist in list of given ids.
filterUserIdsByRbacOrPositionOfCurrentUser(string $rbac_perm, string $pos_perm, int $ref_id, array $user_ids)

Referenced by ilObjIndividualAssessment\loadVisibleMembers().

+ Here is the caller graph for this function:

◆ withAdditionalRecord()

ilIndividualAssessmentMembers::withAdditionalRecord ( array  $record)

Clone this and add a record.

Parameters
int | string | null[]$record

Definition at line 169 of file class.ilIndividualAssessmentMembers.php.

170 {
171 if ($this->recordOK($record)) {
172 $clone = clone $this;
173 $clone->member_records[$record[self::FIELD_USR_ID]] = $record;
174 return $clone;
175 }
176 throw new ilIndividualAssessmentException('Ill defined record.');
177 }
recordOK(array $record)
Check the validity of a record before adding it to this.

References FIELD_USR_ID, and recordOK().

+ Here is the call graph for this function:

◆ withAdditionalUser()

ilIndividualAssessmentMembers::withAdditionalUser ( ilObjUser  $usr)

Clone this and add a record created for user.

Definition at line 182 of file class.ilIndividualAssessmentMembers.php.

183 {
184 if (!$this->userAllreadyMember($usr)) {
185 $clone = clone $this;
186 $clone->member_records[$usr->getId()] = $this->buildNewRecordOfUser($usr);
187 return $clone;
188 }
189 throw new ilIndividualAssessmentException('User allready member');
190 }
userAllreadyMember(ilObjUser $usr)
Check if a user is member of this.

References buildNewRecordOfUser(), ilObject\getId(), and userAllreadyMember().

+ Here is the call graph for this function:

◆ withOnlyUsersByIds()

ilIndividualAssessmentMembers::withOnlyUsersByIds ( array  $keep_users_ids)

Remove all users that do not exist in list of given ids.

Definition at line 232 of file class.ilIndividualAssessmentMembers.php.

233 {
234 $clone = clone $this;
235
236 $remove = array_diff($this->membersIds(), $keep_users_ids);
237 foreach ($remove as $id) {
238 unset($clone->member_records[$id]);
239 }
240
241 return $clone;
242 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
membersIds()
Get the ids of all the users being member in this iass.

References $id, and membersIds().

+ Here is the call graph for this function:

◆ withoutPresentUser()

ilIndividualAssessmentMembers::withoutPresentUser ( ilObjUser  $usr)

Clone this and remove record corresponding to user.

Definition at line 218 of file class.ilIndividualAssessmentMembers.php.

219 {
220 $usr_id = $usr->getId();
221 if (isset($this->member_records[$usr_id]) && (string) $this->member_records[$usr_id][self::FIELD_FINALIZED] !== "1") {
222 $clone = clone $this;
223 unset($clone->member_records[$usr->getId()]);
224 return $clone;
225 }
226 throw new ilIndividualAssessmentException('User not member or allready finished');
227 }

References ilObject\getId().

+ Here is the call graph for this function:

Field Documentation

◆ $iass

ilObjIndividualAssessment ilIndividualAssessmentMembers::$iass
protected

Definition at line 57 of file class.ilIndividualAssessmentMembers.php.

Referenced by __construct(), and referencedObject().

◆ $member_records

array ilIndividualAssessmentMembers::$member_records = array()
protected

Definition at line 55 of file class.ilIndividualAssessmentMembers.php.

Referenced by TestObj\getMemberRecords().

◆ $position

int ilIndividualAssessmentMembers::$position = 0
protected

Definition at line 56 of file class.ilIndividualAssessmentMembers.php.

◆ FIELD_CHANGE_TIME

◆ FIELD_CHANGER_FIRSTNAME

◆ FIELD_CHANGER_ID

◆ FIELD_CHANGER_LASTNAME

◆ FIELD_EVENTTIME

◆ FIELD_EXAMINER_FIRSTNAME

◆ FIELD_EXAMINER_ID

◆ FIELD_EXAMINER_LASTNAME

◆ FIELD_FILE_NAME

◆ FIELD_FINALIZED

◆ FIELD_FIRSTNAME

◆ FIELD_INTERNAL_NOTE

◆ FIELD_LASTNAME

◆ FIELD_LEARNING_PROGRESS

◆ FIELD_LOGIN

◆ FIELD_NOTIFICATION_TS

◆ FIELD_NOTIFY

◆ FIELD_PLACE

◆ FIELD_RECORD

◆ FIELD_USER_VIEW_FILE

◆ FIELD_USR_ID

◆ LP_ASSESSMENT_NOT_COMPLETED

◆ LP_COMPLETED

◆ LP_FAILED

◆ LP_IN_PROGRESS

◆ LP_NOT_ATTEMPTED


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