ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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

 $language
 
 $defaultPlaceholderValuesObject
 
 $dateHelper
 
 $objectHelper
 
 $utilHelper
 
 $objectLPHelper
 
 $lpStatusHelper
 

Detailed Description

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 
)
Parameters
ilDefaultPlaceholderValues | null$defaultPlaceholderValues
ilLanguage | null$language
ilCertificateDateHelper | null$dateHelper
ilCertificateObjectHelper | null$objectHelper
ilCertificateUtilHelper | null$utilHelper
ilCertificateObjectLPHelper | null$objectLPHelper
ilCertificateLPStatusHelper | null$lpStatusHelper

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

61 {
62 if (null === $language) {
63 global $DIC;
64 $language = $DIC->language();
65 $language->loadLanguageModule('certificate');
66 }
67 $this->language = $language;
68
69 if (null === $defaultPlaceholderValues) {
70 $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
71 }
72 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
73
74 if (null === $dateHelper) {
76 }
77 $this->dateHelper = $dateHelper;
78
79 if (null === $objectHelper) {
81 }
82 $this->objectHelper = $objectHelper;
83
84 if (null === $utilHelper) {
86 }
87 $this->utilHelper = $utilHelper;
88
89 if (null === $objectLPHelper) {
91 }
92 $this->objectLPHelper = $objectLPHelper;
93
94 if (null === $lpStatusHelper) {
96 }
97 $this->lpStatusHelper = $lpStatusHelper;
98 }
Just a wrapper class to create Unit Test for other classes.
Collection of basic placeholder values that can be used.
language()
Definition: language.php:2
$DIC
Definition: xapitoken.php:46

References $dateHelper, $DIC, $language, $lpStatusHelper, $objectHelper, $objectLPHelper, $utilHelper, and language().

+ 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
$userId
$objId
Exceptions
ilInvalidCertificateException
Returns
mixed - [PLACEHOLDER] => 'actual value'
Exceptions
ilException

Implements ilCertificatePlaceholderValues.

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

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

References $objId, and 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 211 of file class.ilScormPlaceholderValues.php.

211 : array
212 {
213 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
214
215 $object = $this->objectHelper->getInstanceByObjId($objId);
216
217 $placeholders['SCORM_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
218
219 $placeholders['SCORM_POINTS'] = number_format(
220 80.7,
221 1,
222 $this->language->txt('lang_sep_decimal'),
223 $this->language->txt('lang_sep_thousand')
224 ) . ' %';
225
226 $placeholders['SCORM_POINTS_MAX'] = number_format(
227 90,
228 0,
229 $this->language->txt('lang_sep_decimal'),
230 $this->language->txt('lang_sep_thousand')
231 );
232
233 $insert_tags = array();
234 foreach ($placeholders as $id => $caption) {
235 $insert_tags[$id] = $caption;
236 }
237
238 $olp = $this->objectLPHelper->getInstance($objId);
239 $collection = $olp->getCollectionInstance();
240
241 if ($collection) {
242 $counter = 0;
243 foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
244 if ($collection->isAssignedEntry($item_id)) {
245 $insert_tags['SCO_T_' . $counter] = $sahs_item['title'];
246
247 $insert_tags['SCO_P_' . $counter] = number_format(
248 30.3,
249 1,
250 $this->language->txt('lang_sep_decimal'),
251 $this->language->txt('lang_sep_thousand')
252 );
253
254 $insert_tags['SCO_PM_' . $counter] = number_format(
255 90.9,
256 1,
257 $this->language->txt('lang_sep_decimal'),
258 $this->language->txt('lang_sep_thousand')
259 );
260
261 $insert_tags['SCO_PP_' . $counter] = number_format(
262 33.3333,
263 1,
264 $this->language->txt('lang_sep_decimal'),
265 $this->language->txt('lang_sep_thousand')
266 ) . ' %';
267
268 $counter++;
269 }
270 }
271 }
272
273 return $insert_tags;
274 }

References $objId, and language().

+ Here is the call graph for this function:

Field Documentation

◆ $dateHelper

ilScormPlaceholderValues::$dateHelper
private

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

Referenced by __construct().

◆ $defaultPlaceholderValuesObject

ilScormPlaceholderValues::$defaultPlaceholderValuesObject
private

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

◆ $language

ilScormPlaceholderValues::$language
private

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

Referenced by __construct().

◆ $lpStatusHelper

ilScormPlaceholderValues::$lpStatusHelper
private

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

Referenced by __construct().

◆ $objectHelper

ilScormPlaceholderValues::$objectHelper
private

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

Referenced by __construct().

◆ $objectLPHelper

ilScormPlaceholderValues::$objectLPHelper
private

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

Referenced by __construct().

◆ $utilHelper

ilScormPlaceholderValues::$utilHelper
private

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

Referenced by __construct().


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