ILIAS  release_8 Revision v8.24
ilScormPlaceholderValues Class Reference
+ Inheritance diagram for ilScormPlaceholderValues:
+ Collaboration diagram for ilScormPlaceholderValues:

Public Member Functions

 __construct (?ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ?ilLanguage $language=null, ?ilCertificateDateHelper $dateHelper=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateObjectLPHelper $objectLPHelper=null, ?ilCertificateLPStatusHelper $lpStatusHelper=null)
 
 getPlaceholderValues (int $userId, int $objId)
 This method MUST return an array that contains the actual data for the given user of the given object. More...
 
 getPlaceholderValuesForPreview (int $userId, int $objId)
 This method is different then the 'getPlaceholderValues' method, this method is used to create a placeholder value array containing dummy values that is used to create a preview certificate. More...
 
 getPlaceholderValues (int $userId, int $objId)
 This method MUST return an array that contains the actual data for the given user of the given object. More...
 
 getPlaceholderValuesForPreview (int $userId, int $objId)
 This method is different then the 'getPlaceholderValues' method, this method is used to create a placeholder value array containing dummy values that is used to create a preview certificate. More...
 

Private Attributes

ilLanguage $language
 
ilDefaultPlaceholderValues $defaultPlaceholderValuesObject
 
ilCertificateDateHelper $dateHelper
 
ilCertificateObjectHelper $objectHelper
 
ilCertificateUtilHelper $utilHelper
 
ilCertificateObjectLPHelper $objectLPHelper
 
ilCertificateLPStatusHelper $lpStatusHelper
 

Detailed Description

Definition at line 21 of file class.ilScormPlaceholderValues.php.

Constructor & Destructor Documentation

◆ __construct()

ilScormPlaceholderValues::__construct ( ?ilDefaultPlaceholderValues  $defaultPlaceholderValues = null,
?ilLanguage  $language = null,
?ilCertificateDateHelper  $dateHelper = null,
?ilCertificateObjectHelper  $objectHelper = null,
?ilCertificateUtilHelper  $utilHelper = null,
?ilCertificateObjectLPHelper  $objectLPHelper = null,
?ilCertificateLPStatusHelper  $lpStatusHelper = null 
)

Definition at line 31 of file class.ilScormPlaceholderValues.php.

39 {
40 if (null === $language) {
41 global $DIC;
42 $language = $DIC->language();
43 $language->loadLanguageModule('certificate');
44 }
45 $this->language = $language;
46
47 if (null === $defaultPlaceholderValues) {
48 $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
49 }
50 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
51
52 if (null === $dateHelper) {
54 }
55 $this->dateHelper = $dateHelper;
56
57 if (null === $objectHelper) {
59 }
60 $this->objectHelper = $objectHelper;
61
62 if (null === $utilHelper) {
64 }
65 $this->utilHelper = $utilHelper;
66
67 if (null === $objectLPHelper) {
69 }
70 $this->objectLPHelper = $objectLPHelper;
71
72 if (null === $lpStatusHelper) {
74 }
75 $this->lpStatusHelper = $lpStatusHelper;
76 }
Just a wrapper class to create Unit Test for other classes.
Collection of basic placeholder values that can be used.
loadLanguageModule(string $a_module)
Load language module.
ilCertificateObjectLPHelper $objectLPHelper
ilCertificateLPStatusHelper $lpStatusHelper
ilCertificateObjectHelper $objectHelper
global $DIC
Definition: feed.php:28

References $dateHelper, $DIC, $language, $lpStatusHelper, $objectHelper, $objectLPHelper, $utilHelper, ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ilLanguage\loadLanguageModule().

+ Here is the call graph for this function:

Member Function Documentation

◆ getPlaceholderValues()

ilScormPlaceholderValues::getPlaceholderValues ( int  $userId,
int  $objId 
)

This method MUST return an array that contains the actual data for the given user of the given object.

ilInvalidCertificateException MUST be thrown if the data could not be determined or the user did NOT achieve the certificate.

Parameters
int$userId
int$objId
Returns
array - [PLACEHOLDER] => 'actual value'
Exceptions
ilDatabaseException
ilDateTimeException
ilException
ilObjectNotFoundException

Implements ilCertificatePlaceholderValues.

Definition at line 92 of file class.ilScormPlaceholderValues.php.

92 : array
93 {
94 $this->language->loadLanguageModule('certificate');
95
96 $object = $this->objectHelper->getInstanceByObjId($objId);
97 $points = $object->getPointsInPercent();
98 if (is_null($points)) {
99 $txtPoints = $this->language->txt('certificate_points_notavailable');
100 } else {
101 $txtPoints = number_format(
102 $points,
103 1,
104 $this->language->txt('lang_sep_decimal'),
105 $this->language->txt('lang_sep_thousand')
106 ) . ' %';
107 }
108
109 $max_points = $object->getMaxPoints();
110 $txtMaxPoints = $max_points;
111 if (is_null($max_points)) {
112 $txtMaxPoints = $this->language->txt('certificate_points_notavailable');
113 } elseif ($max_points != floor($max_points)) {
114 $txtMaxPoints = number_format(
115 $max_points,
116 1,
117 $this->language->txt('lang_sep_decimal'),
118 $this->language->txt('lang_sep_thousand')
119 );
120 }
121
122 $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
123
124 $placeHolders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
125
126 $placeHolders['SCORM_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
127 $placeHolders['SCORM_POINTS'] = $txtPoints;
128 $placeHolders['SCORM_POINTS_MAX'] = $txtMaxPoints;
129
130 $placeHolders['DATE_COMPLETED'] = '';
131 $placeHolders['DATETIME_COMPLETED'] = '';
132
133 if ($completionDate !== '') {
134 $placeHolders['DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
135 $placeHolders['DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
136 }
137
138 $olp = $this->objectLPHelper->getInstance($object->getId());
139 $collection = $olp->getCollectionInstance();
140
141 if ($collection) {
142 $counter = 0;
143 foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
144 if ($collection->isAssignedEntry($item_id)) {
145 $placeHolders['SCO_T_' . $counter] = $sahs_item['title'];
146 $a_scores = $collection->getScoresForUserAndCP_Node_Id($item_id, $userId);
147
148 $placeHolders['SCO_P_' . $counter] = $this->language->txt('certificate_points_notavailable');
149 if ($a_scores['raw'] !== null) {
150 $placeHolders['SCO_P_' . $counter] = number_format(
151 (float) $a_scores['raw'],
152 1,
153 $this->language->txt('lang_sep_decimal'),
154 $this->language->txt('lang_sep_thousand')
155 );
156 }
157
158 $placeHolders['SCO_PM_' . $counter] = $this->language->txt('certificate_points_notavailable');
159 if ($a_scores['max'] !== null) {
160 $placeHolders['SCO_PM_' . $counter] = number_format(
161 (float) $a_scores['max'],
162 1,
163 $this->language->txt('lang_sep_decimal'),
164 $this->language->txt('lang_sep_thousand')
165 );
166 }
167
168 $placeHolders['SCO_PP_' . $counter] = $this->language->txt('certificate_points_notavailable');
169 if ($a_scores['scaled'] !== null) {
170 $placeHolders['SCO_PP_' . $counter] = number_format(
171 (float) ($a_scores['scaled'] * 100),
172 1,
173 $this->language->txt('lang_sep_decimal'),
174 $this->language->txt('lang_sep_thousand')
175 );
176
177 $placeHolders['SCO_PP_' . $counter] .= ' %';
178 }
179
180 $counter++;
181 }
182 }
183 }
184
185 return $placeHolders;
186 }
$objId
Definition: xapitoken.php:57

References $objId, and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ getPlaceholderValuesForPreview()

ilScormPlaceholderValues::getPlaceholderValuesForPreview ( int  $userId,
int  $objId 
)

This method is different then the 'getPlaceholderValues' method, this method is used to create a placeholder value array containing dummy values that is used to create a preview certificate.

Parameters
int$userId
int$objId
Returns
array

Implements ilCertificatePlaceholderValues.

Definition at line 196 of file class.ilScormPlaceholderValues.php.

196 : array
197 {
198 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
199
200 $object = $this->objectHelper->getInstanceByObjId($objId);
201
202 $placeholders['SCORM_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
203
204 $placeholders['SCORM_POINTS'] = number_format(
205 80.7,
206 1,
207 $this->language->txt('lang_sep_decimal'),
208 $this->language->txt('lang_sep_thousand')
209 ) . ' %';
210
211 $placeholders['SCORM_POINTS_MAX'] = number_format(
212 90,
213 0,
214 $this->language->txt('lang_sep_decimal'),
215 $this->language->txt('lang_sep_thousand')
216 );
217
218 $insert_tags = [];
219 foreach ($placeholders as $id => $caption) {
220 $insert_tags[$id] = $caption;
221 }
222
223 $olp = $this->objectLPHelper->getInstance($objId);
224 $collection = $olp->getCollectionInstance();
225
226 if ($collection) {
227 $counter = 0;
228 foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
229 if ($collection->isAssignedEntry($item_id)) {
230 $insert_tags['SCO_T_' . $counter] = $sahs_item['title'];
231
232 $insert_tags['SCO_P_' . $counter] = number_format(
233 30.3,
234 1,
235 $this->language->txt('lang_sep_decimal'),
236 $this->language->txt('lang_sep_thousand')
237 );
238
239 $insert_tags['SCO_PM_' . $counter] = number_format(
240 90.9,
241 1,
242 $this->language->txt('lang_sep_decimal'),
243 $this->language->txt('lang_sep_thousand')
244 );
245
246 $insert_tags['SCO_PP_' . $counter] = number_format(
247 33.3333,
248 1,
249 $this->language->txt('lang_sep_decimal'),
250 $this->language->txt('lang_sep_thousand')
251 ) . ' %';
252
253 $counter++;
254 }
255 }
256 }
257
258 return $insert_tags;
259 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, $objId, and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

Field Documentation

◆ $dateHelper

ilCertificateDateHelper ilScormPlaceholderValues::$dateHelper
private

Definition at line 25 of file class.ilScormPlaceholderValues.php.

Referenced by __construct().

◆ $defaultPlaceholderValuesObject

ilDefaultPlaceholderValues ilScormPlaceholderValues::$defaultPlaceholderValuesObject
private

Definition at line 24 of file class.ilScormPlaceholderValues.php.

◆ $language

ilLanguage ilScormPlaceholderValues::$language
private

Definition at line 23 of file class.ilScormPlaceholderValues.php.

Referenced by __construct().

◆ $lpStatusHelper

ilCertificateLPStatusHelper ilScormPlaceholderValues::$lpStatusHelper
private

Definition at line 29 of file class.ilScormPlaceholderValues.php.

Referenced by __construct().

◆ $objectHelper

ilCertificateObjectHelper ilScormPlaceholderValues::$objectHelper
private

Definition at line 26 of file class.ilScormPlaceholderValues.php.

Referenced by __construct().

◆ $objectLPHelper

ilCertificateObjectLPHelper ilScormPlaceholderValues::$objectLPHelper
private

Definition at line 28 of file class.ilScormPlaceholderValues.php.

Referenced by __construct().

◆ $utilHelper

ilCertificateUtilHelper ilScormPlaceholderValues::$utilHelper
private

Definition at line 27 of file class.ilScormPlaceholderValues.php.

Referenced by __construct().


The documentation for this class was generated from the following file: