ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCertificateLearningHistoryProvider.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
6
11{
16
20 private $controller;
21
26
28 protected $uiFactory;
29
31 protected $uiRenderer;
32
34 private $utilHelper;
35
49 public function __construct(
50 int $user_id,
53 ilTemplate $template = null,
54 \ILIAS\DI\Container $dic = null,
56 ilCtrl $controller = null,
58 Factory $uiFactory = null,
59 Renderer $uiRenderer = null,
61 ) {
62 $lng->loadLanguageModule("cert");
63
65
66 if (null === $dic) {
67 global $DIC;
68 $dic = $DIC;
69 }
70
71 if (null === $userCertificateRepository) {
72 $database = $dic->database();
73 $looger = $dic->logger()->cert();
75 }
76 $this->userCertificateRepository = $userCertificateRepository;
77
78 if (null === $controller) {
79 $controller = $dic->ctrl();
80 }
81 $this->controller = $controller;
82
83 if (null === $certificateSettings) {
84 $certificateSettings = new ilSetting("certificate");
85 }
86 $this->certificateSettings = $certificateSettings;
87
88 if (null === $uiFactory) {
89 $uiFactory = $dic->ui()->factory();
90 }
91 $this->uiFactory = $uiFactory;
92
93 if (null === $uiRenderer) {
94 $uiRenderer = $dic->ui()->renderer();
95 }
96 $this->uiRenderer = $uiRenderer;
97
98 if (null === $utilHelper) {
100 }
101 $this->utilHelper = $utilHelper;
102 }
103
109 public function isActive()
110 {
111 return (bool) $this->certificateSettings->get('active');
112 }
113
121 public function getEntries($ts_start, $ts_end)
122 {
123 $entries = array();
124
125 $certificates = $this->userCertificateRepository->fetchActiveCertificatesInIntervalForPresentation($this->user_id, $ts_start, $ts_end);
126
127 foreach ($certificates as $certificate) {
128 $objectId = $certificate->getUserCertificate()->getObjId();
129
130 $this->controller->setParameterByClass(
131 'ilUserCertificateGUI',
132 'certificate_id',
133 $certificate->getUserCertificate()->getId()
134 );
135 $href = $this->controller->getLinkTargetByClass(['ilDashboardGUI', 'ilAchievementsGUI', 'ilUserCertificateGUI'], 'download');
136 $this->controller->clearParametersByClass('ilUserCertificateGUI');
137
138 $prefixTextWithLink = sprintf(
139 $this->lng->txt('certificate_achievement_sub_obj'),
140 $this->uiRenderer->render($this->uiFactory->link()->standard($this->getEmphasizedTitle($certificate->getObjectTitle()), $href))
141 );
142
143 $text = sprintf(
144 $this->lng->txt('certificate_achievement'),
145 $prefixTextWithLink
146 );
147
148 $entries[] = new ilLearningHistoryEntry(
149 $text,
150 $text,
151 $this->utilHelper->getImagePath("icon_cert.svg"),
152 $certificate->getUserCertificate()->getAcquiredTimestamp(),
153 $objectId
154 );
155 }
156
157 return $entries;
158 }
159
164 public function getName() : string
165 {
166 return $this->lng->txt('certificates');
167 }
168}
An exception for terminatinating execution or to throw for unit testing.
__construct(int $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ilTemplate $template=null, \ILIAS\DI\Container $dic=null, ilUserCertificateRepository $userCertificateRepository=null, ilCtrl $controller=null, ilSetting $certificateSettings=null, Factory $uiFactory=null, Renderer $uiRenderer=null, ilCertificateUtilHelper $utilHelper=null)
Just a wrapper class to create Unit Test for other classes.
This class provides processing control methods.
language handling
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
This is how the factory for UI elements looks.
Definition: Factory.php:18
An entity that renders components to a string output.
Definition: Renderer.php:15
Class HTTPServicesTest.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
$dic
Definition: result.php:13
$DIC
Definition: xapitoken.php:46