ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository Class Reference
+ Inheritance diagram for ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository:
+ Collaboration diagram for ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository:

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)
 
 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()

ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository::__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 57 of file CertificateSettingsCourseFormRepository.php.

72 {
73 global $DIC;
74
75 $this->settingsFormFactory = $settingsFormFactory ?? new ilCertificateSettingsFormRepository(
76 $object->getId(),
77 $certificatePath,
78 $hasAdditionalElements,
79 $language,
80 $ctrl,
81 $access,
82 $toolbar,
83 $placeholderDescriptionObject,
84 $DIC->ui()->factory(),
85 $DIC->ui()->renderer()
86 );
87 $this->tree = $tree ?? $DIC->repositoryTree();
88 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository\$settingsFormFactory, and ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository\$tree.

Member Function Documentation

◆ createForm()

ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository::createForm ( ilCertificateGUI  $certificateGUI)
Exceptions
FileAlreadyExistsException
FileNotFoundException
IOException
ilDatabaseException
ilException
ilWACException

Implements ilCertificateFormRepository.

Definition at line 98 of file CertificateSettingsCourseFormRepository.php.

99 {
100 $form = $this->settingsFormFactory->createForm($certificateGUI);
101
102 $objectLearningProgressSettings = new ilLPObjSettings($this->object->getId());
103
104 $mode = $objectLearningProgressSettings->getMode();
105 if (!$this->trackingHelper->enabledLearningProgress() || $mode === ilLPObjSettings::LP_MODE_DEACTIVATED) {
106 $subitems = new ilRepositorySelector2InputGUI($this->language->txt('objects'), 'subitems', true);
107
108 $formSection = new ilFormSectionHeaderGUI();
109 $formSection->setTitle($this->language->txt('cert_form_sec_add_features'));
110 $form->addItem($formSection);
111
112 $exp = $subitems->getExplorerGUI();
113 $exp->setSkipRootNode(true);
114 $exp->setRootId($this->object->getRefId());
115 $exp->setTypeWhiteList($this->getLPTypes($this->object->getRefId()));
116
117 $objectHelper = $this->objectHelper;
118 $lpHelper = $this->lpHelper;
119 $subitems->setTitleModifier(function ($id) use ($objectHelper, $lpHelper): string {
120 if (null === $id) {
121 return '';
122 }
123 $obj_id = $objectHelper->lookupObjId((int) $id);
124 $olp = $lpHelper->getInstance($obj_id);
125
126 $invalid_modes = $this->getInvalidLPModes();
127
128 $mode = $olp->getModeText($olp->getCurrentMode());
129
130 if (in_array($olp->getCurrentMode(), $invalid_modes, true)) {
131 $mode = '<strong>' . $mode . '</strong>';
132 }
133
134 return $objectHelper->lookupTitle($obj_id) . ' (' . $mode . ')';
135 });
136
137 $subitems->setRequired(true);
138 $form->addItem($subitems);
139 }
140
141 return $form;
142 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This class represents a section header in a property form.
This class represents a property form user interface.

References $id, ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository\getInvalidLPModes(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ilLPObjSettings\LP_MODE_DEACTIVATED, and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ fetchFormFieldData()

ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository::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 181 of file CertificateSettingsCourseFormRepository.php.

181 : array
182 {
183 $formFields = $this->settingsFormFactory->fetchFormFieldData($content);
184
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'] = [];
191 }
192
193 return $formFields;
194 }

◆ getInvalidLPModes()

ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository::getInvalidLPModes ( )
private
Returns
int[]

Definition at line 225 of file CertificateSettingsCourseFormRepository.php.

225 : array
226 {
227 $invalid_modes = [
230 ];
231
232 // without active LP the following modes cannot be supported
233 if (!$this->trackingHelper->enabledLearningProgress()) {
234 // status cannot be set without active LP
235 //$invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL;
238
239 // mode cannot be configured without active LP
240 $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION;
243 $invalid_modes[] = ilLPObjSettings::LP_MODE_SCORM;
244 $invalid_modes[] = ilLPObjSettings::LP_MODE_VISITS; // ?
245 }
246
247 return $invalid_modes;
248 }

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_BY_TUTOR, ilLPObjSettings\LP_MODE_SCORM, ilLPObjSettings\LP_MODE_UNDEFINED, and ilLPObjSettings\LP_MODE_VISITS.

Referenced by ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository\createForm(), and ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository\save().

+ Here is the caller graph for this function:

◆ save()

ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository::save ( array  $formFields)
Exceptions
ilException

Implements ilCertificateFormRepository.

Definition at line 147 of file CertificateSettingsCourseFormRepository.php.

147 : void
148 {
149 $invalidModes = $this->getInvalidLPModes();
150
151 $titlesOfObjectsWithInvalidModes = [];
152 $refIds = $formFields['subitems'] ?? [];
153
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);
160 }
161 }
162
163 if ($titlesOfObjectsWithInvalidModes !== []) {
164 $message = sprintf(
165 $this->language->txt('certificate_learning_progress_must_be_active'),
166 implode(', ', $titlesOfObjectsWithInvalidModes)
167 );
168
169 throw new ilException($message);
170 }
171
172 $this->setting->set(
173 'cert_subitems_' . $this->object->getId(),
174 json_encode($formFields['subitems'] ?? [], JSON_THROW_ON_ERROR)
175 );
176 }
Base class for ILIAS Exception handling.
$message
Definition: xapiexit.php:31
$refId
Definition: xapitoken.php:58

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

+ Here is the call graph for this function:

Field Documentation

◆ $settingsFormFactory

readonly ilCertificateSettingsFormRepository ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository::$settingsFormFactory
private

◆ $tree

readonly ilTree ILIAS\Course\Certificate\CertificateSettingsCourseFormRepository::$tree
private

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