ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCertificateSettingsCourseFormRepository Class Reference
+ Inheritance diagram for ilCertificateSettingsCourseFormRepository:
+ Collaboration diagram for ilCertificateSettingsCourseFormRepository:

Public Member Functions

 __construct (private readonly ilObject $object, string $certificatePath, bool $hasAdditionalElements, private readonly ilLanguage $language, ilCtrlInterface $ctrl, ilAccess $access, ilToolbarGUI $toolbar, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ?ilCertificateSettingsFormRepository $settingsFormFactory=null, private readonly ilCertificateObjUserTrackingHelper $trackingHelper=new ilCertificateObjUserTrackingHelper(), private readonly ilCertificateObjectHelper $objectHelper=new ilCertificateObjectHelper(), private readonly ilCertificateObjectLPHelper $lpHelper=new ilCertificateObjectLPHelper(), ?ilTree $tree=null, private readonly ilSetting $setting=new ilSetting('crs'))
 
 createForm (ilCertificateGUI $certificateGUI)
 
 save (array $formFields)
 
 fetchFormFieldData (string $content)
 

Private Member Functions

 getInvalidLPModes ()
 

Private Attributes

readonly ilCertificateSettingsFormRepository $settingsFormFactory
 
readonly ilTree $tree
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateSettingsCourseFormRepository::__construct ( private readonly ilObject  $object,
string  $certificatePath,
bool  $hasAdditionalElements,
private readonly ilLanguage  $language,
ilCtrlInterface  $ctrl,
ilAccess  $access,
ilToolbarGUI  $toolbar,
ilCertificatePlaceholderDescription  $placeholderDescriptionObject,
?ilCertificateSettingsFormRepository  $settingsFormFactory = null,
private readonly ilCertificateObjUserTrackingHelper  $trackingHelper = new ilCertificateObjUserTrackingHelper(),
private readonly ilCertificateObjectHelper  $objectHelper = new ilCertificateObjectHelper(),
private readonly ilCertificateObjectLPHelper  $lpHelper = new ilCertificateObjectLPHelper(),
?ilTree  $tree = null,
private readonly ilSetting  $setting = new ilSetting('crs') 
)

Definition at line 33 of file class.ilCertificateSettingsCourseFormRepository.php.

References $DIC.

48  {
49  global $DIC;
50 
51  $this->settingsFormFactory = $settingsFormFactory ?? new ilCertificateSettingsFormRepository(
52  $object->getId(),
53  $certificatePath,
54  $hasAdditionalElements,
55  $language,
56  $ctrl,
57  $access,
58  $toolbar,
59  $placeholderDescriptionObject,
60  $DIC->ui()->factory(),
61  $DIC->ui()->renderer()
62  );
63  $this->tree = $tree ?? $DIC->repositoryTree();
64  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ createForm()

ilCertificateSettingsCourseFormRepository::createForm ( ilCertificateGUI  $certificateGUI)
Exceptions
FileAlreadyExistsException
FileNotFoundException
IOException
ilDatabaseException
ilException
ilWACException

Implements ilCertificateFormRepository.

Definition at line 74 of file class.ilCertificateSettingsCourseFormRepository.php.

References $id, getInvalidLPModes(), ilLPObjSettings\getMode(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ilLPObjSettings\LP_MODE_DEACTIVATED, ILIAS\Repository\object(), and ilFormPropertyGUI\setTitle().

75  {
76  $form = $this->settingsFormFactory->createForm($certificateGUI);
77 
78  $objectLearningProgressSettings = new ilLPObjSettings($this->object->getId());
79 
80  $mode = $objectLearningProgressSettings->getMode();
81  if (!$this->trackingHelper->enabledLearningProgress() || $mode === ilLPObjSettings::LP_MODE_DEACTIVATED) {
82  $subitems = new ilRepositorySelector2InputGUI($this->language->txt('objects'), 'subitems', true);
83 
84  $formSection = new ilFormSectionHeaderGUI();
85  $formSection->setTitle($this->language->txt('cert_form_sec_add_features'));
86  $form->addItem($formSection);
87 
88  $exp = $subitems->getExplorerGUI();
89  $exp->setSkipRootNode(true);
90  $exp->setRootId($this->object->getRefId());
91  $exp->setTypeWhiteList($this->getLPTypes($this->object->getRefId()));
92 
93  $objectHelper = $this->objectHelper;
94  $lpHelper = $this->lpHelper;
95  $subitems->setTitleModifier(function ($id) use ($objectHelper, $lpHelper): string {
96  if (null === $id) {
97  return '';
98  }
99  $obj_id = $objectHelper->lookupObjId((int) $id);
100  $olp = $lpHelper->getInstance($obj_id);
101 
102  $invalid_modes = $this->getInvalidLPModes();
103 
104  $mode = $olp->getModeText($olp->getCurrentMode());
105 
106  if (in_array($olp->getCurrentMode(), $invalid_modes, true)) {
107  $mode = '<strong>' . $mode . '</strong>';
108  }
109  return $objectHelper->lookupTitle($obj_id) . ' (' . $mode . ')';
110  });
111 
112  $subitems->setRequired(true);
113  $form->addItem($subitems);
114  }
115 
116  return $form;
117  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ fetchFormFieldData()

ilCertificateSettingsCourseFormRepository::fetchFormFieldData ( string  $content)
Returns
array{pageformat: string, pagewidth: mixed, pageheight: mixed, margin_body_top: mixed, margin_body_right: mixed, margin_body_bottom: mixed, margin_body_left: mixed, certificate_text: string, subitems: mixed}

Implements ilCertificateFormRepository.

Definition at line 155 of file class.ilCertificateSettingsCourseFormRepository.php.

155  : array
156  {
157  $formFields = $this->settingsFormFactory->fetchFormFieldData($content);
158 
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'] = [];
165  }
166  return $formFields;
167  }

◆ getInvalidLPModes()

ilCertificateSettingsCourseFormRepository::getInvalidLPModes ( )
private
Returns
int[]

Definition at line 198 of file class.ilCertificateSettingsCourseFormRepository.php.

References ilLPObjSettings\LP_MODE_COLLECTION, ilLPObjSettings\LP_MODE_COLLECTION_MANUAL, ilLPObjSettings\LP_MODE_COLLECTION_MOBS, ilLPObjSettings\LP_MODE_COLLECTION_TLT, ilLPObjSettings\LP_MODE_DEACTIVATED, ilLPObjSettings\LP_MODE_MANUAL, ilLPObjSettings\LP_MODE_MANUAL_BY_TUTOR, ilLPObjSettings\LP_MODE_SCORM, ilLPObjSettings\LP_MODE_UNDEFINED, and ilLPObjSettings\LP_MODE_VISITS.

Referenced by createForm(), and save().

198  : array
199  {
200  $invalid_modes = [
203  ];
204 
205  // without active LP the following modes cannot be supported
206  if (!$this->trackingHelper->enabledLearningProgress()) {
207  // status cannot be set without active LP
208  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL;
209  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR;
211 
212  // mode cannot be configured without active LP
213  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION;
214  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_MOBS;
215  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_TLT;
216  $invalid_modes[] = ilLPObjSettings::LP_MODE_SCORM;
217  $invalid_modes[] = ilLPObjSettings::LP_MODE_VISITS; // ?
218  }
219 
220  return $invalid_modes;
221  }
+ Here is the caller graph for this function:

◆ save()

ilCertificateSettingsCourseFormRepository::save ( array  $formFields)
Exceptions
ilException

Implements ilCertificateFormRepository.

Definition at line 122 of file class.ilCertificateSettingsCourseFormRepository.php.

References $message, $refId, getInvalidLPModes(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\object().

122  : void
123  {
124  $invalidModes = $this->getInvalidLPModes();
125 
126  $titlesOfObjectsWithInvalidModes = [];
127  $refIds = $formFields['subitems'] ?? [];
128 
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);
135  }
136  }
137 
138  if ($titlesOfObjectsWithInvalidModes !== []) {
139  $message = sprintf(
140  $this->language->txt('certificate_learning_progress_must_be_active'),
141  implode(', ', $titlesOfObjectsWithInvalidModes)
142  );
143  throw new ilException($message);
144  }
145 
146  $this->setting->set(
147  'cert_subitems_' . $this->object->getId(),
148  json_encode($formFields['subitems'] ?? [], JSON_THROW_ON_ERROR)
149  );
150  }
$refId
Definition: xapitoken.php:58
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:

Field Documentation

◆ $settingsFormFactory

readonly ilCertificateSettingsFormRepository ilCertificateSettingsCourseFormRepository::$settingsFormFactory
private

◆ $tree

readonly ilTree ilCertificateSettingsCourseFormRepository::$tree
private

The documentation for this class was generated from the following file: