ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCourseLPBadge Class Reference
+ Inheritance diagram for ilCourseLPBadge:
+ Collaboration diagram for ilCourseLPBadge:

Public Member Functions

 getId ()
 Get typ id (unique for component) More...
 
 getCaption ()
 
 isSingleton ()
 Can only be created once? More...
 
 getValidObjectTypes ()
 
 getConfigGUIInstance ()
 Get GUI config instance. More...
 
 evaluate (int $a_user_id, array $a_params, ?array $a_config)
 Evaluate if given user has earned badge. More...
 

Detailed Description

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

Member Function Documentation

◆ evaluate()

ilCourseLPBadge::evaluate ( int  $a_user_id,
array  $a_params,
?array  $a_config 
)

Evaluate if given user has earned badge.

Implements ilBadgeAuto.

Definition at line 60 of file class.ilCourseLPBadge.php.

References $ref_id, ilObject\_lookupObjId(), ilLPStatus\_lookupStatus(), ILIAS\Repository\int(), and ilLPStatus\LP_STATUS_COMPLETED_NUM.

60  : bool
61  {
62  $subitem_obj_ids = [];
63 
64  if ($a_config !== null && isset($a_config['subitems'])) {
65  foreach ($a_config['subitems'] as $ref_id) {
66  $subitem_obj_ids[$ref_id] = ilObject::_lookupObjId((int) $ref_id);
67  }
68  }
69 
70  $trigger_subitem_id = $a_params['obj_id'];
71 
72  // relevant for current badge instance?
73  if (in_array($trigger_subitem_id, $subitem_obj_ids)) {
74  $completed = true;
75 
76  // check if all subitems are completed now
77  if ($a_config !== null && isset($a_config['subitems'])) {
78  foreach ($a_config['subitems'] as $subitem_id) {
79  $subitem_obj_id = (int) $subitem_obj_ids[$subitem_id];
80  if (ilLPStatus::_lookupStatus($subitem_obj_id, $a_user_id) !== ilLPStatus::LP_STATUS_COMPLETED_NUM) {
81  $completed = false;
82  break;
83  }
84  }
85  }
86 
87  return $completed;
88  }
89 
90  return false;
91  }
const LP_STATUS_COMPLETED_NUM
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:67
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
+ Here is the call graph for this function:

◆ getCaption()

ilCourseLPBadge::getCaption ( )

Implements ilBadgeType.

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

References $DIC, and $lng.

34  : string
35  {
36  global $DIC;
37 
38  $lng = $DIC['lng'];
39  return $lng->txt('badge_course_lp');
40  }
$lng
global $DIC
Definition: feed.php:28

◆ getConfigGUIInstance()

ilCourseLPBadge::getConfigGUIInstance ( )

Get GUI config instance.

Implements ilBadgeType.

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

56  {
57  return new ilCourseLPBadgeGUI();
58  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getId()

ilCourseLPBadge::getId ( )

Get typ id (unique for component)

Implements ilBadgeType.

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

29  : string
30  {
31  return 'course_lp';
32  }

◆ getValidObjectTypes()

ilCourseLPBadge::getValidObjectTypes ( )
Returns
string[]

Implements ilBadgeType.

Definition at line 50 of file class.ilCourseLPBadge.php.

50  : array
51  {
52  return ['crs'];
53  }

◆ isSingleton()

ilCourseLPBadge::isSingleton ( )

Can only be created once?

Implements ilBadgeType.

Definition at line 42 of file class.ilCourseLPBadge.php.

42  : bool
43  {
44  return false;
45  }

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