ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCourseLPBadge.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 public function getId(): string
30 {
31 return 'course_lp';
32 }
33
34 public function getCaption(): string
35 {
36 global $DIC;
37
38 $lng = $DIC['lng'];
39 return $lng->txt('badge_course_lp');
40 }
41
42 public function isSingleton(): bool
43 {
44 return false;
45 }
46
50 public function getValidObjectTypes(): array
51 {
52 return ['crs'];
53 }
54
56 {
57 return new ilCourseLPBadgeGUI();
58 }
59
60 public function evaluate(int $a_user_id, array $a_params, ?array $a_config): 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 = $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 }
92}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getConfigGUIInstance()
Get GUI config instance.
getId()
Get typ id (unique for component)
evaluate(int $a_user_id, array $a_params, ?array $a_config)
Evaluate if given user has earned badge.
isSingleton()
Can only be created once?
const LP_STATUS_COMPLETED_NUM
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
static _lookupObjId(int $ref_id)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26