ILIAS  release_8 Revision v8.24
class.ilCertificateLearningHistoryProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
29{
36
37 public function __construct(
38 int $user_id,
41 ?ilTemplate $template = null,
42 ?Container $dic = null,
44 ?ilCtrlInterface $ctrl = null,
46 ?Factory $uiFactory = null,
47 ?Renderer $uiRenderer = null,
49 ) {
50 $lng->loadLanguageModule("cert");
51
53
54 if (null === $dic) {
55 global $DIC;
56 $dic = $DIC;
57 }
58
59 if (null === $userCertificateRepository) {
60 $database = $dic->database();
61 $looger = $dic->logger()->cert();
63 }
64 $this->userCertificateRepository = $userCertificateRepository;
65
66 if (null === $ctrl) {
67 $ctrl = $dic->ctrl();
68 }
69 $this->ctrl = $ctrl;
70
71 if (null === $certificateSettings) {
72 $certificateSettings = new ilSetting("certificate");
73 }
74 $this->certificateSettings = $certificateSettings;
75
76 if (null === $uiFactory) {
77 $uiFactory = $dic->ui()->factory();
78 }
79 $this->uiFactory = $uiFactory;
80
81 if (null === $uiRenderer) {
82 $uiRenderer = $dic->ui()->renderer();
83 }
84 $this->uiRenderer = $uiRenderer;
85
86 if (null === $utilHelper) {
88 }
89 $this->utilHelper = $utilHelper;
90 }
91
92 public function isActive(): bool
93 {
94 return (bool) $this->certificateSettings->get('active', '0');
95 }
96
103 public function getEntries(int $ts_start, int $ts_end): array
104 {
105 $entries = [];
106
107 $certificates = $this->userCertificateRepository->fetchActiveCertificatesInIntervalForPresentation(
108 $this->user_id,
109 $ts_start,
110 $ts_end
111 );
112
113 foreach ($certificates as $certificate) {
114 $objectId = $certificate->getUserCertificate()->getObjId();
115
116 $this->ctrl->setParameterByClass(
117 ilUserCertificateGUI::class,
118 'certificate_id',
119 $certificate->getUserCertificate()->getId()
120 );
121 $href = $this->ctrl->getLinkTargetByClass(
122 [
123 ilDashboardGUI::class,
124 ilAchievementsGUI::class,
125 ilUserCertificateGUI::class
126 ],
127 'download'
128 );
129 $this->ctrl->clearParametersByClass(ilUserCertificateGUI::class);
130
131 $prefixTextWithLink = sprintf(
132 $this->lng->txt('certificate_achievement_sub_obj'),
133 $this->uiRenderer->render($this->uiFactory->link()->standard(
134 $this->getEmphasizedTitle($certificate->getObjectTitle()),
135 $href
136 ))
137 );
138
139 $text = sprintf(
140 $this->lng->txt('certificate_achievement'),
141 $prefixTextWithLink
142 );
143
144 $entries[] = new ilLearningHistoryEntry(
145 $text,
146 $text,
147 $this->utilHelper->getImagePath("icon_cert.svg"),
148 $certificate->getUserCertificate()->getAcquiredTimestamp(),
149 $objectId
150 );
151 }
152
153 return $entries;
154 }
155
156 public function getName(): string
157 {
158 return $this->lng->txt('certificates');
159 }
160}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $user_id, ilLearningHistoryFactory $factory, ilLanguage $lng, ?ilTemplate $template=null, ?Container $dic=null, ?ilUserCertificateRepository $userCertificateRepository=null, ?ilCtrlInterface $ctrl=null, ?ilSetting $certificateSettings=null, ?Factory $uiFactory=null, ?Renderer $uiRenderer=null, ?ilCertificateUtilHelper $utilHelper=null)
Just a wrapper class to create Unit Test for other classes.
language handling
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: feed.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$dic
Definition: result.php:32