ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilAchievements.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
27 
28  public const SERV_LEARNING_HISTORY = 1;
29  public const SERV_COMPETENCES = 2;
30  public const SERV_LEARNING_PROGRESS = 3;
31  public const SERV_BADGES = 4;
32  public const SERV_CERTIFICATES = 5;
33 
34  protected array $services = [
35  self::SERV_LEARNING_HISTORY,
36  self::SERV_COMPETENCES,
37  self::SERV_LEARNING_PROGRESS,
38  self::SERV_BADGES,
39  self::SERV_CERTIFICATES
40  ];
41 
42  protected ilSetting $setting;
44 
45  public function __construct()
46  {
47  global $DIC;
48 
49  $this->setting = $DIC->settings();
50  $this->learing_history = $DIC->learningHistory();
51  $this->skmg_setting = new ilSetting('skmg');
52  $this->validator = new ilCertificateActiveValidator();
53  }
54 
55  public function isActive(int $service): bool
56  {
57  switch ($service) {
58  case self::SERV_LEARNING_HISTORY:
59  return $this->learing_history->isActive();
60 
61  case self::SERV_COMPETENCES:
62  return (bool) $this->skmg_setting->get('enable_skmg');
63 
64  case self::SERV_LEARNING_PROGRESS:
68 
69  case self::SERV_BADGES:
70  return ilBadgeHandler::getInstance()->isActive();
71 
72  case self::SERV_CERTIFICATES:
73  return $this->validator->validate();
74  }
75  return false;
76  }
77 
78  public function isAnyActive(): bool
79  {
80  foreach ($this->services as $s) {
81  if ($this->isActive($s)) {
82  return true;
83  }
84  }
85  return false;
86  }
87 
91  public function getActiveServices(): array
92  {
93  return array_filter($this->services, function ($s) {
94  return $this->isActive($s);
95  });
96  }
97 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isActive(int $service)
global $DIC
Definition: shib_login.php:22
ilCertificateActiveValidator $validator
ilLearningHistoryService $learing_history
$service
Definition: ltiservices.php:40