ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCertificateLearningHistoryProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
29{
31 private readonly ilCtrlInterface $ctrl;
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
101 public function getEntries(int $ts_start, int $ts_end): array
102 {
103 $entries = [];
104
105 $certificates = $this->userCertificateRepository->fetchActiveCertificatesInIntervalForPresentation(
106 $this->user_id,
107 $ts_start,
108 $ts_end
109 );
110
111 foreach ($certificates as $certificate) {
112 $objectId = $certificate->getUserCertificate()->getObjId();
113
114 $this->ctrl->setParameterByClass(
115 ilUserCertificateGUI::class,
116 'certificate_id',
117 $certificate->getUserCertificate()->getId()
118 );
119 $href = $this->ctrl->getLinkTargetByClass(
120 [
121 ilDashboardGUI::class,
122 ilAchievementsGUI::class,
123 ilUserCertificateGUI::class
124 ],
125 'download'
126 );
127 $this->ctrl->clearParametersByClass(ilUserCertificateGUI::class);
128
129 $prefixTextWithLink = sprintf(
130 $this->lng->txt('certificate_achievement_sub_obj'),
131 $this->uiRenderer->render($this->uiFactory->link()->standard(
132 $this->getEmphasizedTitle($certificate->getObjectTitle()),
133 $href
134 ))
135 );
136
137 $text = sprintf(
138 $this->lng->txt('certificate_achievement'),
139 $prefixTextWithLink
140 );
141
142 $entries[] = new ilLearningHistoryEntry(
143 $text,
144 $text,
145 $this->utilHelper->getImagePath("standard/icon_cert.svg"),
146 $certificate->getUserCertificate()->getAcquiredTimestamp(),
147 $objectId
148 );
149 }
150
151 return $entries;
152 }
153
154 public function getName(): string
155 {
156 return $this->lng->txt('certificates');
157 }
158}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
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)
readonly ilUserCertificateRepository $userCertificateRepository
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...
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
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...
$dic
Definition: ltiresult.php:33
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26