ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAchievements.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
14 {
18  private $validator;
22  protected $learing_history;
23 
24  // all services being covered under the achievements menu item
26  const SERV_COMPETENCES = 2;
28  const SERV_BADGES = 4;
29  const SERV_CERTIFICATES = 5;
30 
31  // this also determines the order of tabs
32  protected $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 
43  protected $setting;
44 
48  public function __construct()
49  {
50  global $DIC;
51 
52  $this->setting = $DIC["ilSetting"];
53  $this->learing_history = $DIC->learningHistory();
54  $this->skmg_setting = new ilSetting("skmg");
55  $this->validator = new ilCertificateActiveValidator();
56  }
57 
64  public function isActive($service) : bool
65  {
66  switch ($service) {
67  case self::SERV_LEARNING_HISTORY:
68  return (bool) $this->learing_history->isActive();
69  break;
70  case self::SERV_COMPETENCES:
71  return (bool) $this->skmg_setting->get("enable_skmg");
72  break;
73  case self::SERV_LEARNING_PROGRESS:
77  break;
78  case self::SERV_BADGES:
79  return (bool) ilBadgeHandler::getInstance()->isActive();
80  break;
81  case self::SERV_CERTIFICATES:
82  return $this->validator->validate();
83  break;
84  }
85  return false;
86  }
87 
93  public function isAnyActive() : bool
94  {
95  foreach ($this->services as $s) {
96  if ($this->isActive($s)) {
97  return true;
98  }
99  }
100  return false;
101  }
102 
108  public function getActiveServices() : array
109  {
110  return array_filter($this->services, function ($s) {
111  return $this->isActive($s);
112  });
113  }
114 }
__construct()
Constructor.
getActiveServices()
Get active services.
isActive($service)
Is subservice active?
static _enabledLearningProgress()
check wether learing progress is enabled or not
Maybe a separate service in the future.
$service
Definition: result.php:17
isAnyActive()
Is any subservice active?
$DIC
Definition: xapitoken.php:46
static getInstance()
Constructor.