19 declare(strict_types=1);
40 if (null === $language) {
42 $language = $DIC->language();
47 if (null === $defaultPlaceholderValues) {
50 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
52 if (null === $dateHelper) {
57 if (null === $objectHelper) {
62 if (null === $utilHelper) {
67 if (null === $objectLPHelper) {
72 if (null === $lpStatusHelper) {
94 $this->
language->loadLanguageModule(
'certificate');
96 $object = $this->objectHelper->getInstanceByObjId($objId);
97 $points = $object->getPointsInPercent();
98 if (is_null($points)) {
99 $txtPoints = $this->
language->txt(
'certificate_points_notavailable');
101 $txtPoints = number_format(
104 $this->
language->txt(
'lang_sep_decimal'),
105 $this->
language->txt(
'lang_sep_thousand')
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(
117 $this->
language->txt(
'lang_sep_decimal'),
118 $this->
language->txt(
'lang_sep_thousand')
122 $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
124 $placeHolders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
126 $placeHolders[
'SCORM_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
127 $placeHolders[
'SCORM_POINTS'] = $txtPoints;
128 $placeHolders[
'SCORM_POINTS_MAX'] = $txtMaxPoints;
130 $placeHolders[
'DATE_COMPLETED'] =
'';
131 $placeHolders[
'DATETIME_COMPLETED'] =
'';
133 if ($completionDate !==
'') {
134 $placeHolders[
'DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
135 $placeHolders[
'DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
138 $olp = $this->objectLPHelper->getInstance($object->getId());
139 $collection = $olp->getCollectionInstance();
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);
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'],
153 $this->
language->txt(
'lang_sep_decimal'),
154 $this->
language->txt(
'lang_sep_thousand')
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'],
163 $this->
language->txt(
'lang_sep_decimal'),
164 $this->
language->txt(
'lang_sep_thousand')
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),
173 $this->
language->txt(
'lang_sep_decimal'),
174 $this->
language->txt(
'lang_sep_thousand')
177 $placeHolders[
'SCO_PP_' . $counter] .=
' %';
185 return $placeHolders;
198 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
200 $object = $this->objectHelper->getInstanceByObjId($objId);
202 $placeholders[
'SCORM_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
204 $placeholders[
'SCORM_POINTS'] = number_format(
207 $this->
language->txt(
'lang_sep_decimal'),
208 $this->
language->txt(
'lang_sep_thousand')
211 $placeholders[
'SCORM_POINTS_MAX'] = number_format(
214 $this->
language->txt(
'lang_sep_decimal'),
215 $this->
language->txt(
'lang_sep_thousand')
219 foreach ($placeholders as
$id => $caption) {
220 $insert_tags[
$id] = $caption;
223 $olp = $this->objectLPHelper->getInstance($objId);
224 $collection = $olp->getCollectionInstance();
228 foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
229 if ($collection->isAssignedEntry($item_id)) {
230 $insert_tags[
'SCO_T_' . $counter] = $sahs_item[
'title'];
232 $insert_tags[
'SCO_P_' . $counter] = number_format(
235 $this->
language->txt(
'lang_sep_decimal'),
236 $this->
language->txt(
'lang_sep_thousand')
239 $insert_tags[
'SCO_PM_' . $counter] = number_format(
242 $this->
language->txt(
'lang_sep_decimal'),
243 $this->
language->txt(
'lang_sep_thousand')
246 $insert_tags[
'SCO_PP_' . $counter] = number_format(
249 $this->
language->txt(
'lang_sep_decimal'),
250 $this->
language->txt(
'lang_sep_thousand')
ilCertificateObjectLPHelper $objectLPHelper
Collection of basic placeholder values that can be used.
loadLanguageModule(string $a_module)
Load language module.
ilCertificateObjectHelper $objectHelper
ilCertificateLPStatusHelper $lpStatusHelper
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
Just a wrapper class to create Unit Test for other classes.
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
ilCertificateUtilHelper $utilHelper
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ilCertificateDateHelper $dateHelper
__construct(?ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ?ilLanguage $language=null, ?ilCertificateDateHelper $dateHelper=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateObjectLPHelper $objectLPHelper=null, ?ilCertificateLPStatusHelper $lpStatusHelper=null)
ilDefaultPlaceholderValues $defaultPlaceholderValuesObject