ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 

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.

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

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

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 113 of file class.ilScormPlaceholderValues.php.

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

◆ 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 210 of file class.ilScormPlaceholderValues.php.

References $id.

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

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: