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

Provides Role actions. More...

+ Collaboration diagram for ilLearningSequenceRoles:

Public Member Functions

 __construct (int $ls_ref_id, int $ls_obj_id, ilLearningSequenceParticipants $participants, ilCtrl $ctrl, ilRbacAdmin $rbacadmin, ilRbacReview $rbacreview, ilDBInterface $database, ilObjUser $user, ilLanguage $lng)
 
 initDefaultRoles ()
 
 getLocalLearningSequenceRoles (bool $translate=false)
 
 getDefaultMemberRole ()
 
 getDefaultAdminRole ()
 
 addLSMember (int $user_id, int $role)
 
 join (int $user_id, ?int $role=null)
 
 leave (int $user_id)
 
 getLearningSequenceAdminIds ()
 
 getDefaultLearningSequenceRoles (string $lso_id)
 
 readMemberData (array $user_ids, ?array $selected_columns=null)
 
 isMember (int $usr_id)
 
 isCompletedByUser (int $usr_id)
 

Data Fields

const ROLE_LS_ADMIN = "il_lso_admin"
 
const ROLE_LS_MEMBER = "il_lso_member"
 
const TYPE_PORTFOLIO = "prtf"
 

Protected Member Functions

 getRoleObject (int $obj_id)
 
 isTrackingEnabled ()
 
 isPortfolio (?array $columns=null)
 

Protected Attributes

int $ref_id
 
int $obj_id
 
ilLearningSequenceParticipants $participants
 
ilCtrl $ctrl
 
ilRbacAdmin $rbacadmin
 
ilRbacReview $rbacreview
 
ilDBInterface $database
 
ilObjUser $user
 
ilLanguage $lng
 
array $local_roles
 

Detailed Description

Provides Role actions.

Definition at line 24 of file class.ilLearningSequenceRoles.php.

Constructor & Destructor Documentation

◆ __construct()

ilLearningSequenceRoles::__construct ( int  $ls_ref_id,
int  $ls_obj_id,
ilLearningSequenceParticipants  $participants,
ilCtrl  $ctrl,
ilRbacAdmin  $rbacadmin,
ilRbacReview  $rbacreview,
ilDBInterface  $database,
ilObjUser  $user,
ilLanguage  $lng 
)

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

53 {
54 $this->ref_id = $ls_ref_id;
55 $this->obj_id = $ls_obj_id;
56 $this->participants = $participants;
57 $this->ctrl = $ctrl;
58 $this->rbacadmin = $rbacadmin;
59 $this->rbacreview = $rbacreview;
60 $this->database = $database;
61 $this->user = $user;
62 $this->lng = $lng;
63
64 $this->local_roles = array();
65 }
ilLearningSequenceParticipants $participants

References $ctrl, $database, $lng, $participants, $rbacadmin, $rbacreview, $user, ILIAS\Repository\ctrl(), ILIAS\Repository\database(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addLSMember()

ilLearningSequenceRoles::addLSMember ( int  $user_id,
int  $role 
)

Definition at line 124 of file class.ilLearningSequenceRoles.php.

124 : bool
125 {
126 return $this->join($user_id, $role);
127 }
join(int $user_id, ?int $role=null)

References join().

+ Here is the call graph for this function:

◆ getDefaultAdminRole()

ilLearningSequenceRoles::getDefaultAdminRole ( )

Definition at line 118 of file class.ilLearningSequenceRoles.php.

118 : int
119 {
120 $local_ls_roles = $this->getLocalLearningSequenceRoles();
121 return $local_ls_roles[self::ROLE_LS_ADMIN . "_" . $this->ref_id];
122 }
getLocalLearningSequenceRoles(bool $translate=false)

References $ref_id, and getLocalLearningSequenceRoles().

+ Here is the call graph for this function:

◆ getDefaultLearningSequenceRoles()

ilLearningSequenceRoles::getDefaultLearningSequenceRoles ( string  $lso_id)
Returns
array<string, int>|[]

Definition at line 165 of file class.ilLearningSequenceRoles.php.

165 : array
166 {
167 if (strlen($lso_id) == 0) {
168 $lso_id = $this->ref_id;
169 }
170
171 $roles = $this->rbacreview->getRolesOfRoleFolder($lso_id);
172
173 $default_roles = array();
174 foreach ($roles as $role) {
175 $object = $this->getRoleObject($role);
176
177 $member = self::ROLE_LS_MEMBER . "_" . $lso_id;
178 $admin = self::ROLE_LS_ADMIN . "_" . $lso_id;
179
180 if (strcmp($object->getTitle(), $member) == 0) {
181 $default_roles["lso_member_role"] = $object->getId();
182 }
183
184 if (strcmp($object->getTitle(), $admin) == 0) {
185 $default_roles["lso_admin_role"] = $object->getId();
186 }
187 }
188
189 return $default_roles;
190 }

References $ref_id, and getRoleObject().

+ Here is the call graph for this function:

◆ getDefaultMemberRole()

ilLearningSequenceRoles::getDefaultMemberRole ( )

Definition at line 112 of file class.ilLearningSequenceRoles.php.

112 : int
113 {
114 $local_ls_roles = $this->getLocalLearningSequenceRoles();
115 return $local_ls_roles[self::ROLE_LS_MEMBER . "_" . $this->ref_id];
116 }

References $ref_id, and getLocalLearningSequenceRoles().

Referenced by join().

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

◆ getLearningSequenceAdminIds()

ilLearningSequenceRoles::getLearningSequenceAdminIds ( )
Returns
array<int>

Definition at line 152 of file class.ilLearningSequenceRoles.php.

152 : array
153 {
154 $users = array();
155 foreach ($this->rbacreview->assignedUsers($this->getDefaultAdminRole()) as $admin_id) {
156 $users[] = (int) $admin_id;
157 }
158
159 return $users;
160 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getLocalLearningSequenceRoles()

ilLearningSequenceRoles::getLocalLearningSequenceRoles ( bool  $translate = false)
Returns
array<string, int>

Definition at line 87 of file class.ilLearningSequenceRoles.php.

87 : array
88 {
89 if (count($this->local_roles) == 0) {
90 $role_ids = $this->rbacreview->getRolesOfRoleFolder(
91 $this->ref_id
92 );
93
94 foreach ($role_ids as $role_id) {
95 if ($this->rbacreview->isAssignable($role_id, $this->ref_id) == true) {
96 $role = $this->getRoleObject($role_id);
97
98 if ($translate) {
99 $role_name = ilObjRole::_getTranslation($role->getTitle());
100 } else {
101 $role_name = $role->getTitle();
102 }
103
104 $this->local_roles[$role_name] = $role->getId();
105 }
106 }
107 }
108
109 return $this->local_roles;
110 }
static _getTranslation(string $a_role_title)

References $local_roles, ilObjRole\_getTranslation(), and getRoleObject().

Referenced by getDefaultAdminRole(), and getDefaultMemberRole().

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

◆ getRoleObject()

ilLearningSequenceRoles::getRoleObject ( int  $obj_id)
protected

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

192 : ?\ilObject
193 {
195 }
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObject Basic functions for all objects.

References $obj_id, and ilObjectFactory\getInstanceByObjId().

Referenced by getDefaultLearningSequenceRoles(), and getLocalLearningSequenceRoles().

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

◆ initDefaultRoles()

ilLearningSequenceRoles::initDefaultRoles ( )

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

67 : void
68 {
70 self::ROLE_LS_ADMIN . '_' . $this->ref_id,
71 "LSO admin learning sequence obj_no." . $this->obj_id,
72 self::ROLE_LS_ADMIN,
73 $this->ref_id
74 );
75
77 self::ROLE_LS_MEMBER . '_' . $this->ref_id,
78 "LSO member of learning sequence obj_no." . $this->obj_id,
79 self::ROLE_LS_MEMBER,
80 $this->ref_id
81 );
82 }
static createDefaultRole(string $a_title, string $a_description, string $a_tpl_name, int $a_ref_id)

References ilObjRole\createDefaultRole().

+ Here is the call graph for this function:

◆ isCompletedByUser()

ilLearningSequenceRoles::isCompletedByUser ( int  $usr_id)

Definition at line 303 of file class.ilLearningSequenceRoles.php.

303 : bool
304 {
305 ilLPStatusWrapper::_updateStatus($this->obj_id, $usr_id);
307 $user_completion = ilLPStatus::_hasUserCompleted($this->obj_id, $usr_id);
308 return ($tracking_active && $user_completion);
309 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.

References ilObjUserTracking\_enabledLearningProgress(), ilLPStatus\_hasUserCompleted(), and ilLPStatusWrapper\_updateStatus().

+ Here is the call graph for this function:

◆ isMember()

ilLearningSequenceRoles::isMember ( int  $usr_id)

Definition at line 298 of file class.ilLearningSequenceRoles.php.

298 : bool
299 {
300 return $this->participants->isMember($usr_id);
301 }

◆ isPortfolio()

ilLearningSequenceRoles::isPortfolio ( ?array  $columns = null)
protected

Definition at line 290 of file class.ilLearningSequenceRoles.php.

290 : bool
291 {
292 if (is_null($columns)) {
293 return false;
294 }
295 return in_array(self::TYPE_PORTFOLIO, $columns);
296 }

Referenced by readMemberData().

+ Here is the caller graph for this function:

◆ isTrackingEnabled()

ilLearningSequenceRoles::isTrackingEnabled ( )
protected

Definition at line 282 of file class.ilLearningSequenceRoles.php.

References ilObjUserTracking\_enabledLearningProgress(), and ilObjUserTracking\_enabledUserRelatedData().

Referenced by readMemberData().

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

◆ join()

ilLearningSequenceRoles::join ( int  $user_id,
?int  $role = null 
)

Definition at line 129 of file class.ilLearningSequenceRoles.php.

129 : bool
130 {
131 if (is_null($role)) {
132 $role = $this->getDefaultMemberRole();
133 }
134 $this->rbacadmin->assignUser($role, $user_id);
135 return true;
136 }

References $user_id, and getDefaultMemberRole().

Referenced by addLSMember().

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

◆ leave()

ilLearningSequenceRoles::leave ( int  $user_id)

Definition at line 138 of file class.ilLearningSequenceRoles.php.

138 : bool
139 {
140 $roles = $this->participants::getMemberRoles($this->ref_id);
141
142 foreach ($roles as $role) {
143 $this->rbacadmin->deassignUser($role, $user_id);
144 }
145
146 return true;
147 }

References $user_id.

◆ readMemberData()

ilLearningSequenceRoles::readMemberData ( array  $user_ids,
?array  $selected_columns = null 
)
Parameters
array<int|string>$user_ids
string[]$columns
Returns
array<int|string, array>

Definition at line 202 of file class.ilLearningSequenceRoles.php.

202 : array
203 {
204 $portfolio_enabled = $this->isPortfolio($selected_columns);
205 $tracking_enabled = $this->isTrackingEnabled();
207
208 if ($tracking_enabled) {
209 $olp = ilObjectLP::getInstance($this->obj_id);
210 $tracking_enabled = $olp->isActive();
211
212 $completed = ilLPStatusWrapper::_lookupCompletedForObject($this->obj_id);
213 $in_progress = ilLPStatusWrapper::_lookupInProgressForObject($this->obj_id);
214 $failed = ilLPStatusWrapper::_lookupFailedForObject($this->obj_id);
215 }
216
217 if ($privacy->enabledLearningSequenceAccessTimes()) {
218 $progress = ilLearningProgress::_lookupProgressByObjId($this->obj_id);
219 }
220
221 if ($portfolio_enabled) {
223 $user_ids,
224 $this->ctrl->getLinkTargetByClass("ilLearningSequenceMembershipGUI", "members")
225 );
226 }
227
228 $members = array();
229 $profile_data = ilObjUser::_readUsersProfileData($user_ids);
230 foreach ($user_ids as $usr_id) {
231 $data = array();
232 $name = ilObjUser::_lookupName($usr_id);
233
234 $data['firstname'] = $name['firstname'];
235 $data['lastname'] = $name['lastname'];
236 $data['login'] = ilObjUser::_lookupLogin($usr_id);
237 $data['usr_id'] = $usr_id;
238
239 $data['notification'] = 0;
240 if ($this->participants->isNotificationEnabled($usr_id)) {
241 $data['notification'] = 1;
242 }
243
244 foreach ($profile_data[$usr_id] as $field => $value) {
245 $data[$field] = $value;
246 }
247
248 if ($tracking_enabled) {
249 if (in_array($usr_id, $completed)) {
251 } elseif (in_array($usr_id, $in_progress)) {
253 } elseif (in_array($usr_id, $failed)) {
255 } else {
257 }
258 }
259
260 if ($privacy->enabledLearningSequenceAccessTimes()) {
261 if (isset($progress[$usr_id]['ts']) && $progress[$usr_id]['ts']) {
262 $data['access_time'] = ilDatePresentation::formatDate(
263 $date = new ilDateTime($progress[$usr_id]['ts'], IL_CAL_UNIX)
264 );
265 $data['access_time_unix'] = $date->get(IL_CAL_UNIX);
266 } else {
267 $data['access_time'] = $this->lng->txt('no_date');
268 $data['access_time_unix'] = 0;
269 }
270 }
271
272 if ($portfolio_enabled && array_key_exists($usr_id, $portfolios)) {
273 $data['prtf'] = $portfolios[$usr_id];
274 }
275
276 $members[$usr_id] = $data;
277 }
278
279 return $members;
280 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
static _lookupProgressByObjId(int $a_obj_id)
lookup progress for a specific object
static getAvailablePortfolioLinksForUserIds(array $a_owner_ids, ?string $a_back_url=null)
static _lookupName(int $a_user_id)
static _lookupLogin(int $a_user_id)
static _readUsersProfileData(array $a_user_ids)
static getInstance(int $obj_id)

References $data, ilLPStatusWrapper\_lookupCompletedForObject(), ilLPStatusWrapper\_lookupFailedForObject(), ilLPStatusWrapper\_lookupInProgressForObject(), ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilLearningProgress\_lookupProgressByObjId(), ilObjUser\_readUsersProfileData(), ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ilObjPortfolio\getAvailablePortfolioLinksForUserIds(), ilPrivacySettings\getInstance(), ilObjectLP\getInstance(), IL_CAL_UNIX, isPortfolio(), isTrackingEnabled(), ILIAS\Repository\lng(), ilLPStatus\LP_STATUS_COMPLETED, ilLPStatus\LP_STATUS_FAILED, ilLPStatus\LP_STATUS_IN_PROGRESS, and ilLPStatus\LP_STATUS_NOT_ATTEMPTED.

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilLearningSequenceRoles::$ctrl
protected

Definition at line 34 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $database

ilDBInterface ilLearningSequenceRoles::$database
protected

Definition at line 37 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $lng

ilLanguage ilLearningSequenceRoles::$lng
protected

Definition at line 39 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $local_roles

array ilLearningSequenceRoles::$local_roles
protected

Definition at line 41 of file class.ilLearningSequenceRoles.php.

Referenced by getLocalLearningSequenceRoles().

◆ $obj_id

int ilLearningSequenceRoles::$obj_id
protected

Definition at line 32 of file class.ilLearningSequenceRoles.php.

Referenced by getRoleObject().

◆ $participants

ilLearningSequenceParticipants ilLearningSequenceRoles::$participants
protected

Definition at line 33 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $rbacadmin

ilRbacAdmin ilLearningSequenceRoles::$rbacadmin
protected

Definition at line 35 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $rbacreview

ilRbacReview ilLearningSequenceRoles::$rbacreview
protected

Definition at line 36 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $ref_id

int ilLearningSequenceRoles::$ref_id
protected

◆ $user

ilObjUser ilLearningSequenceRoles::$user
protected

Definition at line 38 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ ROLE_LS_ADMIN

const ilLearningSequenceRoles::ROLE_LS_ADMIN = "il_lso_admin"

Definition at line 26 of file class.ilLearningSequenceRoles.php.

◆ ROLE_LS_MEMBER

const ilLearningSequenceRoles::ROLE_LS_MEMBER = "il_lso_member"

Definition at line 27 of file class.ilLearningSequenceRoles.php.

◆ TYPE_PORTFOLIO

const ilLearningSequenceRoles::TYPE_PORTFOLIO = "prtf"

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


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