19 declare(strict_types=1);
34 $this->tree = $DIC->repositoryTree();
41 $members = self::getMembers($a_obj_id);
66 $collection = $olp->getCollectionInstance();
68 foreach ($collection->getItems() as $item_id) {
72 $users = array_unique(
78 $users = array_unique(
97 $users = array_intersect(self::getMembers($a_obj_id), $users);
114 $collection = $olp->getCollectionInstance();
117 $grouped_items = $collection->getGroupedItemsForLPStatus();
119 if (!count($grouped_items)) {
126 foreach ($grouped_items as $grouping_id => $grouping) {
127 $isGrouping = $grouping_id ? true :
false;
128 $grouping_completed = array();
129 $grouping_completed_users_num = array();
130 foreach ((array) $grouping[
'items'] as $item) {
135 foreach ($tmp_users as $tmp_user_id) {
136 $grouping_completed_users_num[$tmp_user_id] =
137 ($grouping_completed_users_num[$tmp_user_id] ?? 0) + 1;
139 } elseif (!$counter++) {
142 $users = array_intersect($users, $tmp_users);
148 foreach ($grouping_completed_users_num as $tmp_user_id => $grouping_num_completed) {
149 if ($grouping_num_completed >= $grouping[
'num_obligatory']) {
150 $grouping_completed[] = $tmp_user_id;
156 $users = $grouping_completed;
158 $users = array_intersect($users, $grouping_completed);
168 $users = array_intersect(self::getMembers($a_obj_id), $users);
171 return (array) $users;
183 $collection = $olp->getCollectionInstance();
185 foreach ($collection->getGroupedItemsForLPStatus(
186 ) as $grouping_id => $grouping) {
187 $isGrouping = $grouping_id ? true :
false;
189 $gr_failed = array();
190 $gr_failed_users_num = array();
192 foreach ((array) $grouping[
'items'] as $item) {
197 foreach ($tmp_users as $tmp_user_id) {
198 $gr_failed_users_num[$tmp_user_id] =
199 ($gr_failed_users_num[$tmp_user_id] ?? 0) + 1;
203 $gr_failed = array_merge($gr_failed, $tmp_users);
208 $allowed_failed = count(
210 ) - $grouping[
'num_obligatory'];
212 foreach ($gr_failed_users_num as $tmp_user_id => $num_failed) {
213 if ($num_failed > $allowed_failed) {
214 $gr_failed[] = $tmp_user_id;
218 $users = array_unique(array_merge($users, $gr_failed));
224 $users = array_intersect(self::getMembers($a_obj_id), $users);
227 return array_unique($users);
232 $status_info = array();
235 $collection = $olp->getCollectionInstance();
237 $status_info[
'collections'] = $collection->getItems();
238 $status_info[
'num_collections'] = count(
239 $status_info[
'collections']
252 if ($type ==
'sahs') {
253 return parent::_getTypicalLearningTime($type, $obj_id);
258 foreach ($status_info[
'collections'] as $item) {
272 ?
object $a_obj =
null 278 $status[
'completed'] =
true;
279 $status[
'failed'] =
false;
280 $status[
'in_progress'] =
false;
282 switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
288 $status[
'in_progress'] =
true;
292 $collection = $olp->getCollectionInstance();
295 $grouped_items = $collection->getGroupedItemsForLPStatus();
297 if (!count($grouped_items)) {
299 $status[
'completed'] =
false;
301 foreach ($grouped_items as $grouping_id => $grouping) {
302 $isGrouping = $grouping_id ? true :
false;
303 $status = self::determineGroupingStatus(
312 if ($status[
'completed']) {
313 if (!$this->
isMember((
int) $a_obj_id, (
int) $a_usr_id)) {
314 return self::LP_STATUS_IN_PROGRESS_NUM;
317 return self::LP_STATUS_COMPLETED_NUM;
320 if ($status[
'failed']) {
321 return self::LP_STATUS_FAILED_NUM;
324 if ($status[
'in_progress']) {
325 return self::LP_STATUS_IN_PROGRESS_NUM;
329 return self::LP_STATUS_NOT_ATTEMPTED_NUM;
345 $items = $gr_info[
'items'];
347 $max_allowed_failed = count($items) - $gr_info[
'num_obligatory'];
348 $required_completed = $gr_info[
'num_obligatory'];
350 $max_allowed_failed = 0;
351 $required_completed = count($items);
358 foreach ($items as $item_id) {
365 if ($gr_status == self::LP_STATUS_FAILED_NUM) {
366 if (++$num_failed > $max_allowed_failed) {
367 $status[
'failed'] =
true;
368 $status[
'completed'] =
false;
372 if ($gr_status == self::LP_STATUS_COMPLETED_NUM) {
373 if (++$num_completed >= $required_completed) {
379 $status[
'completed'] =
false;
390 switch ($this->ilObjDataCache->lookupType($objId)) {
393 return $participants->isMember();
397 return $participants->isMember($usrId);
401 $folderRefId = current($folderRefIds);
402 if ($crsRefId = $this->tree->checkForParentType($folderRefId,
'crs')) {
404 return $participants->isMember();
407 if ($grpRefId = $this->tree->checkForParentType($folderRefId,
'grp')) {
409 return $participants->isMember($usrId);
415 return $participants->isMember($usrId);
431 $tree = $DIC[
'tree'];
438 return $member_obj->getMembers();
444 return $member_obj->getMembers();
448 $folder_ref_id = current($folder_ref_ids);
456 return $member_obj->getMembers();
465 return $member_obj->getMembers();
473 return $member_obj->getMembers();
485 ?array $a_user_ids =
null 488 $a_user_ids = self::getMembers($a_obj_id);
493 return self::_lookupStatusForObject(
495 self::LP_STATUS_COMPLETED_NUM,
505 ?array $a_user_ids =
null 508 $a_user_ids = self::getMembers($a_obj_id);
513 return self::_lookupStatusForObject(
515 self::LP_STATUS_FAILED_NUM,
525 ?array $a_user_ids =
null 528 $a_user_ids = self::getMembers($a_obj_id);
533 return self::_lookupStatusForObject(
535 self::LP_STATUS_IN_PROGRESS_NUM,
542 $status_info = self::_getStatusInfo($a_obj_id);
543 if (empty($status_info)) {
547 foreach ($status_info[
'collections'] as $item_ref_id) {
554 if ($status_info[
"num_collections"] > 0) {
555 $percentage = (
int) ((100.0 / $status_info[
"num_collections"]) * $passed);
static _getFailed(int $a_obj_id)
static _getInstanceByObjId(int $obj_id)
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
static _getInstanceByObjId(int $a_obj_id, int $a_usr_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _getCompleted(int $a_obj_id)
Get completed users New handling for optional grouped assignments.
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
isMember(int $objId, int $usrId)
static _getInProgress(int $a_obj_id)
Static function to read users who have the status 'in_progress'.
static _getStatusInfo(int $a_obj_id)
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static lookupUsersInProgress(int $a_obj_id)
static determineGroupingStatus(array $status, array $gr_info, int $user_id, bool $is_grouping)
Determine grouping status.
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
__construct(int $a_obj_id)
static _getInstanceByObjId(int $a_obj_id)
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _getFailed(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static getMembers(int $a_obj_id)
Get members for object.
determinePercentage(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
ilObjectDataCache $ilObjDataCache
static _getTypicalLearningTime(string $type, int $obj_id, int $sub_id=0)
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get completed users for object.
static _getInProgress(int $a_obj_id)
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
Get in progress users for object.
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
__construct(Container $dic, ilPlugin $plugin)
static _determineStatus(int $a_obj_id, int $a_usr_id)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get failed users for object.
static _getTypicalLearningTime(string $type, int $a_obj_id)
Reads Typical learning time.
static getInstance(int $obj_id)
static _getNotAttempted(int $a_obj_id)