ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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;
23
24 // all services being covered under the achievements menu item
28 const SERV_BADGES = 4;
30
31 // this also determines the order of tabs
32 protected $services = [
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) {
68 return (bool) $this->learing_history->isActive();
69 break;
71 return (bool) $this->skmg_setting->get("enable_skmg");
72 break;
77 break;
79 return (bool) ilBadgeHandler::getInstance()->isActive();
80 break;
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}
An exception for terminatinating execution or to throw for unit testing.
Maybe a separate service in the future.
getActiveServices()
Get active services.
isActive($service)
Is subservice active?
isAnyActive()
Is any subservice active?
__construct()
Constructor.
static getInstance()
Constructor.
static _enabledLearningProgress()
check wether learing progress is enabled or not
ILIAS Setting Class.
$service
Definition: result.php:17
$DIC
Definition: xapitoken.php:46