ILIAS  release_8 Revision v8.24
class.ilScormPlaceholderDescription.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
25 private array $placeholder;
28
29 public function __construct(
31 ?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject = null,
32 ?ilLanguage $language = null,
34 ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null
35 ) {
36 global $DIC;
37
38 $this->object = $object;
39
40 if (null === $language) {
41 $language = $DIC->language();
42 $language->loadLanguageModule('certificate');
43 }
44 $this->language = $language;
45
46 if (null === $defaultPlaceholderDescriptionObject) {
47 $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription(
49 $userDefinedFieldPlaceHolderDescriptionObject
50 );
51 }
52 $this->defaultPlaceHolderDescriptionObject = $defaultPlaceholderDescriptionObject;
53
54 if (null === $learningProgressObject) {
56 }
57 $this->learningProgressObject = $learningProgressObject;
58
59 $this->placeholder = $this->defaultPlaceHolderDescriptionObject->getPlaceholderDescriptions();
60
61 $this->placeholder['SCORM_TITLE'] = $language->txt('certificate_ph_scormtitle');
62 $this->placeholder['SCORM_POINTS'] = $language->txt('certificate_ph_scormpoints');
63 $this->placeholder['SCORM_POINTS_MAX'] = $language->txt('certificate_ph_scormmaxpoints');
64 $this->placeholder['DATE_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
65 $language->txt('certificate_ph_date_completed')
66 );
67 $this->placeholder['DATETIME_COMPLETED'] = ilLegacyFormElementsUtil::prepareFormOutput(
68 $language->txt('certificate_ph_datetime_completed')
69 );
70 }
71
78 public function createPlaceholderHtmlDescription(ilTemplate $template = null): string
79 {
80 if (null === $template) {
81 $template = new ilTemplate('tpl.scorm_description.html', true, true, 'Services/Certificate');
82 }
83
84 $template->setCurrentBlock('items');
85
86 foreach ($this->placeholder as $id => $caption) {
87 $template->setVariable('ID', $id);
88 $template->setVariable('TXT', $caption);
89 $template->parseCurrentBlock();
90 }
91
92 $template->setVariable('PH_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
93
94 $collection = $this->learningProgressObject->getCollectionInstance();
95 $items = [];
96 if ($collection) {
97 $items = $collection->getPossibleItems();
98 }
99
100 if ($items) {
101 $template->setCurrentBlock('SCOS');
102 $template->setVariable('PH_SCOS', $this->language->txt('certificate_ph_scos'));
103 $template->parseCurrentBlock();
104 $template->setCurrentBlock('SCO_HEADER');
105 $template->setVariable('PH_TITLE_SCO', $this->language->txt('certificate_ph_title_sco'));
106 $template->setVariable('PH_SCO_TITLE', $this->language->txt('certificate_ph_sco_title'));
107 $template->setVariable('PH_SCO_POINTS_RAW', $this->language->txt('certificate_ph_sco_points_raw'));
108 $template->setVariable('PH_SCO_POINTS_MAX', $this->language->txt('certificate_ph_sco_points_max'));
109 $template->setVariable('PH_SCO_POINTS_SCALED', $this->language->txt('certificate_ph_sco_points_scaled'));
110 } else {
111 $template->setCurrentBlock('NO_SCO');
112 $template->setVariable('PH_NO_SCO', $this->language->txt('certificate_ph_no_sco'));
113 }
114 $template->parseCurrentBlock();
115
116 if ($collection) {
117 $counter = 0;
118 foreach ($items as $item_id => $sahs_item) {
119 if ($collection->isAssignedEntry($item_id)) {
120 $template->setCurrentBlock('SCO');
121 $template->setVariable('SCO_TITLE', $sahs_item['title']);
122 $template->setVariable('PH_SCO_TITLE', '[SCO_T_' . $counter . ']');
123 $template->setVariable('PH_SCO_POINTS_RAW', '[SCO_P_' . $counter . ']');
124 $template->setVariable('PH_SCO_POINTS_MAX', '[SCO_PM_' . $counter . ']');
125 $template->setVariable('PH_SCO_POINTS_SCALED', '[SCO_PP_' . $counter . ']');
126 $template->parseCurrentBlock();
127 $counter++;
128 }
129 }
130 }
131
132 return $template->get();
133 }
134
140 public function getPlaceholderDescriptions(): array
141 {
142 return $this->placeholder;
143 }
144}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Collection of basic placeholder values that can be used.
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createPlaceholderHtmlDescription(ilTemplate $template=null)
This methods MUST return an array containing an array with the the description as array value.
ilDefaultPlaceholderDescription $defaultPlaceHolderDescriptionObject
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value.
__construct(ilObject $object, ?ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject=null, ?ilLanguage $language=null, ?ilObjectLP $learningProgressObject=null, ?ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null)
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: feed.php:28