ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAchievements.php
Go to the documentation of this file.
1 <?php
2 
20 {
23 
24  // all services being covered under the achievements menu item
25  public const SERV_LEARNING_HISTORY = 1;
26  public const SERV_COMPETENCES = 2;
27  public const SERV_LEARNING_PROGRESS = 3;
28  public const SERV_BADGES = 4;
29  public const SERV_CERTIFICATES = 5;
30 
31  // this also determines the order of tabs
32  protected array $services = [
33  self::SERV_LEARNING_HISTORY,
34  self::SERV_COMPETENCES,
35  self::SERV_LEARNING_PROGRESS,
36  self::SERV_BADGES,
37  self::SERV_CERTIFICATES
38  ];
39 
40  protected ilSetting $setting;
42 
43  public function __construct()
44  {
46  global $DIC;
47 
48  $this->setting = $DIC->settings();
49  $this->learing_history = $DIC->learningHistory();
50  $this->skmg_setting = new ilSetting("skmg");
51  $this->validator = new ilCertificateActiveValidator();
52  }
53 
57  public function isActive(int $service): bool
58  {
59  switch ($service) {
60  case self::SERV_LEARNING_HISTORY:
61  return $this->learing_history->isActive();
62 
63  case self::SERV_COMPETENCES:
64  return (bool) $this->skmg_setting->get("enable_skmg");
65 
66  case self::SERV_LEARNING_PROGRESS:
70 
71  case self::SERV_BADGES:
72  return ilBadgeHandler::getInstance()->isActive();
73 
74  case self::SERV_CERTIFICATES:
75  return $this->validator->validate();
76 
77  }
78  return false;
79  }
80 
84  public function isAnyActive(): bool
85  {
86  foreach ($this->services as $s) {
87  if ($this->isActive($s)) {
88  return true;
89  }
90  }
91  return false;
92  }
93 
98  public function getActiveServices(): array
99  {
100  return array_filter($this->services, function ($s) {
101  return $this->isActive($s);
102  });
103  }
104 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isActive(int $service)
Is sub-service active?
global $DIC
Definition: feed.php:28
getActiveServices()
Get active services.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilCertificateActiveValidator $validator
ilLearningHistoryService $learing_history
isAnyActive()
Is any sub-service active?
__construct(Container $dic, ilPlugin $plugin)
$service
Definition: ltiservices.php:43