ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

readonly ilLanguage $language
 
readonly ilDefaultPlaceholderValues $defaultPlaceholderValuesObject
 
readonly ilCertificateDateHelper $dateHelper
 
readonly ilCertificateObjectHelper $objectHelper
 
readonly ilCertificateUtilHelper $utilHelper
 
readonly ilCertificateObjectLPHelper $objectLPHelper
 
readonly 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.

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

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  }
readonly ilCertificateObjectLPHelper $objectLPHelper
readonly ilCertificateLPStatusHelper $lpStatusHelper
loadLanguageModule(string $a_module)
Load language module.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
readonly ilCertificateUtilHelper $utilHelper
readonly ilCertificateDateHelper $dateHelper
readonly ilCertificateObjectHelper $objectHelper
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ 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.

Exceptions
ilDatabaseException
ilDateTimeException
ilException
ilObjectNotFoundException

Implements ilCertificatePlaceholderValues.

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

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

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

Implements ilCertificatePlaceholderValues.

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

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

190  : array
191  {
192  $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
193 
194  $object = $this->objectHelper->getInstanceByObjId($objId);
195 
196  $placeholders['SCORM_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
197 
198  $placeholders['SCORM_POINTS'] = number_format(
199  80.7,
200  1,
201  $this->language->txt('lang_sep_decimal'),
202  $this->language->txt('lang_sep_thousand')
203  ) . ' %';
204 
205  $placeholders['SCORM_POINTS_MAX'] = number_format(
206  90,
207  0,
208  $this->language->txt('lang_sep_decimal'),
209  $this->language->txt('lang_sep_thousand')
210  );
211 
212  $insert_tags = [];
213  foreach ($placeholders as $id => $caption) {
214  $insert_tags[$id] = $caption;
215  }
216 
217  $olp = $this->objectLPHelper->getInstance($objId);
218  $collection = $olp->getCollectionInstance();
219 
220  if ($collection !== null) {
221  $counter = 0;
222  foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
223  if ($collection->isAssignedEntry($item_id)) {
224  $insert_tags['SCO_T_' . $counter] = $sahs_item['title'];
225 
226  $insert_tags['SCO_P_' . $counter] = number_format(
227  30.3,
228  1,
229  $this->language->txt('lang_sep_decimal'),
230  $this->language->txt('lang_sep_thousand')
231  );
232 
233  $insert_tags['SCO_PM_' . $counter] = number_format(
234  90.9,
235  1,
236  $this->language->txt('lang_sep_decimal'),
237  $this->language->txt('lang_sep_thousand')
238  );
239 
240  $insert_tags['SCO_PP_' . $counter] = number_format(
241  33.3333,
242  1,
243  $this->language->txt('lang_sep_decimal'),
244  $this->language->txt('lang_sep_thousand')
245  ) . ' %';
246 
247  $counter++;
248  }
249  }
250  }
251 
252  return $insert_tags;
253  }
$objId
Definition: xapitoken.php:57
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:

Field Documentation

◆ $dateHelper

readonly ilCertificateDateHelper ilScormPlaceholderValues::$dateHelper
private

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

Referenced by __construct().

◆ $defaultPlaceholderValuesObject

readonly ilDefaultPlaceholderValues ilScormPlaceholderValues::$defaultPlaceholderValuesObject
private

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

◆ $language

readonly ilLanguage ilScormPlaceholderValues::$language
private

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

Referenced by __construct().

◆ $lpStatusHelper

readonly ilCertificateLPStatusHelper ilScormPlaceholderValues::$lpStatusHelper
private

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

Referenced by __construct().

◆ $objectHelper

readonly ilCertificateObjectHelper ilScormPlaceholderValues::$objectHelper
private

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

Referenced by __construct().

◆ $objectLPHelper

readonly ilCertificateObjectLPHelper ilScormPlaceholderValues::$objectLPHelper
private

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

Referenced by __construct().

◆ $utilHelper

readonly 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: