19 declare(strict_types=1);
59 string $certificatePath,
60 bool $hasAdditionalElements,
78 $hasAdditionalElements,
83 $placeholderDescriptionObject,
84 $DIC->ui()->factory(),
85 $DIC->ui()->renderer()
87 $this->tree = $tree ?? $DIC->repositoryTree();
100 $form = $this->settingsFormFactory->createForm($certificateGUI);
104 $mode = $objectLearningProgressSettings->getMode();
110 $form->addItem($formSection);
112 $exp = $subitems->getExplorerGUI();
113 $exp->setSkipRootNode(
true);
114 $exp->setRootId($this->
object->getRefId());
115 $exp->setTypeWhiteList($this->getLPTypes($this->
object->getRefId()));
117 $objectHelper = $this->objectHelper;
118 $lpHelper = $this->lpHelper;
119 $subitems->setTitleModifier(
function (
$id) use ($objectHelper, $lpHelper):
string {
123 $obj_id = $objectHelper->lookupObjId((
int)
$id);
124 $olp = $lpHelper->getInstance($obj_id);
128 $mode = $olp->getModeText($olp->getCurrentMode());
130 if (in_array($olp->getCurrentMode(), $invalid_modes,
true)) {
131 $mode =
'<strong>' . $mode .
'</strong>';
134 return $objectHelper->lookupTitle($obj_id) .
' (' . $mode .
')';
137 $subitems->setRequired(
true);
138 $form->addItem($subitems);
147 public function save(array $formFields): void
151 $titlesOfObjectsWithInvalidModes = [];
152 $refIds = $formFields[
'subitems'] ?? [];
154 foreach ($refIds as
$refId) {
155 $objectId = $this->objectHelper->lookupObjId((
int) $refId);
156 $learningProgressObject = $this->lpHelper->getInstance($objectId);
157 $currentMode = $learningProgressObject->getCurrentMode();
158 if (in_array($currentMode, $invalidModes,
true)) {
159 $titlesOfObjectsWithInvalidModes[] = $this->objectHelper->lookupTitle($objectId);
163 if ($titlesOfObjectsWithInvalidModes !== []) {
165 $this->
language->txt(
'certificate_learning_progress_must_be_active'),
166 implode(
', ', $titlesOfObjectsWithInvalidModes)
173 'cert_subitems_' . $this->
object->getId(),
174 json_encode($formFields[
'subitems'] ?? [], JSON_THROW_ON_ERROR)
183 $formFields = $this->settingsFormFactory->fetchFormFieldData($content);
185 $formFields[
'subitems'] = json_decode($this->setting->get(
186 'cert_subitems_' . $this->object->getId(),
187 json_encode([], JSON_THROW_ON_ERROR)
188 ),
true, 512, JSON_THROW_ON_ERROR);
189 if ($formFields[
'subitems'] ===
'null' || $formFields[
'subitems'] ===
null) {
190 $formFields[
'subitems'] = [];
199 private function getLPTypes(
int $a_parent_ref_id): array
203 $root = $this->tree->getNodeData($a_parent_ref_id);
204 $sub_items = $this->tree->getSubTree($root);
205 array_shift($sub_items);
207 foreach ($sub_items as $node) {
208 if ($this->lpHelper->isSupportedObjectType($node[
'type'])) {
209 $class = $this->lpHelper->getTypeClass($node[
'type']);
211 $modes = $class::getDefaultModes($this->trackingHelper->enabledLearningProgress());
213 if (count($modes) > 1) {
214 $result[] = $node[
'type'];
233 if (!$this->trackingHelper->enabledLearningProgress()) {
247 return $invalid_modes;
const LP_MODE_MANUAL_BY_TUTOR
const LP_MODE_COLLECTION_MANUAL
const LP_MODE_COLLECTION_TLT
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const LP_MODE_DEACTIVATED
const LP_MODE_COLLECTION_MOBS
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
language()
description: > Example for rendring a language glyph.