19 declare(strict_types=1);
    35         string $certificatePath,
    36         bool $hasAdditionalElements,
    54             $hasAdditionalElements,
    59             $placeholderDescriptionObject,
    60             $DIC->ui()->factory(),
    61             $DIC->ui()->renderer()
    63         $this->tree = $tree ?? $DIC->repositoryTree();
    76         $form = $this->settingsFormFactory->createForm($certificateGUI);
    80         $mode = $objectLearningProgressSettings->
getMode();
    86             $form->addItem($formSection);
    88             $exp = $subitems->getExplorerGUI();
    89             $exp->setSkipRootNode(
true);
    90             $exp->setRootId($this->
object->getRefId());
    91             $exp->setTypeWhiteList($this->getLPTypes($this->
object->getRefId()));
    93             $objectHelper = $this->objectHelper;
    94             $lpHelper = $this->lpHelper;
    95             $subitems->setTitleModifier(
function (
$id) use ($objectHelper, $lpHelper): 
string {
    99                 $obj_id = $objectHelper->lookupObjId((
int) 
$id);
   100                 $olp = $lpHelper->getInstance($obj_id);
   104                 $mode = $olp->getModeText($olp->getCurrentMode());
   106                 if (in_array($olp->getCurrentMode(), $invalid_modes, 
true)) {
   107                     $mode = 
'<strong>' . $mode . 
'</strong>';
   109                 return $objectHelper->lookupTitle($obj_id) . 
' (' . $mode . 
')';
   112             $subitems->setRequired(
true);
   113             $form->addItem($subitems);
   122     public function save(array $formFields): void
   126         $titlesOfObjectsWithInvalidModes = [];
   127         $refIds = $formFields[
'subitems'] ?? [];
   129         foreach ($refIds as 
$refId) {
   130             $objectId = $this->objectHelper->lookupObjId((
int) $refId);
   131             $learningProgressObject = $this->lpHelper->getInstance($objectId);
   132             $currentMode = $learningProgressObject->getCurrentMode();
   133             if (in_array($currentMode, $invalidModes, 
true)) {
   134                 $titlesOfObjectsWithInvalidModes[] = $this->objectHelper->lookupTitle($objectId);
   138         if ($titlesOfObjectsWithInvalidModes !== []) {
   140                 $this->
language->txt(
'certificate_learning_progress_must_be_active'),
   141                 implode(
', ', $titlesOfObjectsWithInvalidModes)
   147             'cert_subitems_' . $this->
object->getId(),
   148             json_encode($formFields[
'subitems'] ?? [], JSON_THROW_ON_ERROR)
   157         $formFields = $this->settingsFormFactory->fetchFormFieldData($content);
   159         $formFields[
'subitems'] = json_decode($this->setting->get(
   160             'cert_subitems_' . $this->object->getId(),
   161             json_encode([], JSON_THROW_ON_ERROR)
   162         ), 
true, 512, JSON_THROW_ON_ERROR);
   163         if ($formFields[
'subitems'] === 
'null' || $formFields[
'subitems'] === null) {
   164             $formFields[
'subitems'] = [];
   172     private function getLPTypes(
int $a_parent_ref_id): array
   176         $root = $this->tree->getNodeData($a_parent_ref_id);
   177         $sub_items = $this->tree->getSubTree($root);
   178         array_shift($sub_items); 
   180         foreach ($sub_items as $node) {
   181             if ($this->lpHelper->isSupportedObjectType($node[
'type'])) {
   182                 $class = $this->lpHelper->getTypeClass($node[
'type']);
   184                 $modes = $class::getDefaultModes($this->trackingHelper->enabledLearningProgress());
   186                 if (count($modes) > 1) {
   187                     $result[] = $node[
'type'];
   206         if (!$this->trackingHelper->enabledLearningProgress()) {
   220         return $invalid_modes;
 
const LP_MODE_MANUAL_BY_TUTOR
 
const LP_MODE_COLLECTION_MANUAL
 
const LP_MODE_COLLECTION_TLT
 
GUI class to create PDF certificates. 
 
const LP_MODE_DEACTIVATED
 
const LP_MODE_COLLECTION_MOBS
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins