ILIAS  release_8 Revision v8.24
ilCertificateSettingsCourseFormRepository Class Reference
+ Inheritance diagram for ilCertificateSettingsCourseFormRepository:
+ Collaboration diagram for ilCertificateSettingsCourseFormRepository:

Public Member Functions

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

Private Member Functions

 getInvalidLPModes ()
 

Private Attributes

ilLanguage $language
 
ilCertificateSettingsFormRepository $settingsFormFactory
 
ilObjCourse $object
 
ilObjectLP $learningProgressObject
 
ilCertificateObjUserTrackingHelper $trackingHelper
 
ilCertificateObjectHelper $objectHelper
 
ilCertificateObjectLPHelper $lpHelper
 
ilTree $tree
 
ilSetting $setting
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

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

56 {
57 $this->object = $object;
58
59 $this->language = $language;
60
61 if (null === $settingsFormFactory) {
63 $object->getId(),
64 $certificatePath,
65 $hasAdditionalElements,
67 $ctrl,
68 $access,
69 $toolbar,
70 $placeholderDescriptionObject
71 );
72 }
73 $this->settingsFormFactory = $settingsFormFactory;
74
75 if (null === $learningProgressObject) {
77 }
78 $this->learningProgressObject = $learningProgressObject;
79
80 if (null === $trackingHelper) {
82 }
83 $this->trackingHelper = $trackingHelper;
84
85 if (null === $objectHelper) {
87 }
88 $this->objectHelper = $objectHelper;
89
90 if (null === $lpHelper) {
92 }
93 $this->lpHelper = $lpHelper;
94
95 if (null === $tree) {
96 global $DIC;
97 $tree = $DIC['tree'];
98 }
99 $this->tree = $tree;
100
101 if (null === $setting) {
102 $setting = new ilSetting('crs');
103 }
104 $this->setting = $setting;
105 }
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28

References $DIC, $language, $learningProgressObject, $lpHelper, $object, $objectHelper, $setting, $settingsFormFactory, $trackingHelper, $tree, ilObject\getId(), ilObjectLP\getInstance(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

Member Function Documentation

◆ createForm()

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

Implements ilCertificateFormRepository.

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

118 {
119 $form = $this->settingsFormFactory->createForm($certificateGUI);
120
121 $objectLearningProgressSettings = new ilLPObjSettings($this->object->getId());
122
123 $mode = $objectLearningProgressSettings->getMode();
124 if (!$this->trackingHelper->enabledLearningProgress() || $mode === ilLPObjSettings::LP_MODE_DEACTIVATED) {
125 $subitems = new ilRepositorySelector2InputGUI($this->language->txt('objects'), 'subitems', true);
126
127 $formSection = new ilFormSectionHeaderGUI();
128 $formSection->setTitle($this->language->txt('cert_form_sec_add_features'));
129 $form->addItem($formSection);
130
131 $exp = $subitems->getExplorerGUI();
132 $exp->setSkipRootNode(true);
133 $exp->setRootId($this->object->getRefId());
134 $exp->setTypeWhiteList($this->getLPTypes($this->object->getRefId()));
135
138 $subitems->setTitleModifier(function ($id) use ($objectHelper, $lpHelper) {
139 if (null === $id) {
140 return '';
141 }
142 $obj_id = $objectHelper->lookupObjId((int) $id);
143 $olp = $lpHelper->getInstance($obj_id);
144
145 $invalid_modes = $this->getInvalidLPModes();
146
147 $mode = $olp->getModeText($olp->getCurrentMode());
148
149 if (in_array($olp->getCurrentMode(), $invalid_modes, true)) {
150 $mode = '<strong>' . $mode . '</strong>';
151 }
152 return $objectHelper->lookupTitle($obj_id) . ' (' . $mode . ')';
153 });
154
155 $subitems->setRequired(true);
156 $form->addItem($subitems);
157 }
158
159 return $form;
160 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $id, $lpHelper, $objectHelper, ilCertificateObjectLPHelper\getInstance(), getInvalidLPModes(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ilCertificateObjectHelper\lookupObjId(), ilCertificateObjectHelper\lookupTitle(), ilLPObjSettings\LP_MODE_DEACTIVATED, and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ fetchFormFieldData()

ilCertificateSettingsCourseFormRepository::fetchFormFieldData ( string  $content)

Implements ilCertificateFormRepository.

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

196 : array
197 {
198 $formFields = $this->settingsFormFactory->fetchFormFieldData($content);
199
200 $formFields['subitems'] = json_decode($this->setting->get(
201 'cert_subitems_' . $this->object->getId(),
202 json_encode([], JSON_THROW_ON_ERROR)
203 ), true, 512, JSON_THROW_ON_ERROR);
204 if ($formFields['subitems'] === 'null' || $formFields['subitems'] === null) {
205 $formFields['subitems'] = [];
206 }
207 return $formFields;
208 }

◆ getInvalidLPModes()

ilCertificateSettingsCourseFormRepository::getInvalidLPModes ( )
private
Returns
int[]

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

240 : array
241 {
242 $invalid_modes = [
245 ];
246
247 // without active LP the following modes cannot be supported
248 if (!$this->trackingHelper->enabledLearningProgress()) {
249 // status cannot be set without active LP
250 $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL;
253
254 // mode cannot be configured without active LP
255 $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION;
258 $invalid_modes[] = ilLPObjSettings::LP_MODE_SCORM;
259 $invalid_modes[] = ilLPObjSettings::LP_MODE_VISITS; // ?
260 }
261
262 return $invalid_modes;
263 }

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

+ Here is the caller graph for this function:

◆ save()

ilCertificateSettingsCourseFormRepository::save ( array  $formFields)
Parameters
array$formFields
Exceptions
ilException

Implements ilCertificateFormRepository.

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

166 : void
167 {
168 $invalidModes = $this->getInvalidLPModes();
169
170 $titlesOfObjectsWithInvalidModes = [];
171 $refIds = $formFields['subitems'] ?? [];
172
173 foreach ($refIds as $refId) {
174 $objectId = $this->objectHelper->lookupObjId((int) $refId);
175 $learningProgressObject = $this->lpHelper->getInstance($objectId);
176 $currentMode = $learningProgressObject->getCurrentMode();
177 if (in_array($currentMode, $invalidModes, true)) {
178 $titlesOfObjectsWithInvalidModes[] = $this->objectHelper->lookupTitle($objectId);
179 }
180 }
181
182 if (count($titlesOfObjectsWithInvalidModes) > 0) {
183 $message = sprintf(
184 $this->language->txt('certificate_learning_progress_must_be_active'),
185 implode(', ', $titlesOfObjectsWithInvalidModes)
186 );
187 throw new ilException($message);
188 }
189
190 $this->setting->set(
191 'cert_subitems_' . $this->object->getId(),
192 json_encode($formFields['subitems'] ?? [], JSON_THROW_ON_ERROR)
193 );
194 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$message
Definition: xapiexit.php:32
$refId
Definition: xapitoken.php:58

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

+ Here is the call graph for this function:

Field Documentation

◆ $language

ilLanguage ilCertificateSettingsCourseFormRepository::$language
private

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

Referenced by __construct().

◆ $learningProgressObject

ilObjectLP ilCertificateSettingsCourseFormRepository::$learningProgressObject
private

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

Referenced by __construct(), and save().

◆ $lpHelper

ilCertificateObjectLPHelper ilCertificateSettingsCourseFormRepository::$lpHelper
private

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

Referenced by __construct(), and createForm().

◆ $object

ilObjCourse ilCertificateSettingsCourseFormRepository::$object
private

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

Referenced by __construct().

◆ $objectHelper

ilCertificateObjectHelper ilCertificateSettingsCourseFormRepository::$objectHelper
private

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

Referenced by __construct(), and createForm().

◆ $setting

ilSetting ilCertificateSettingsCourseFormRepository::$setting
private

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

Referenced by __construct().

◆ $settingsFormFactory

ilCertificateSettingsFormRepository ilCertificateSettingsCourseFormRepository::$settingsFormFactory
private

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

Referenced by __construct().

◆ $trackingHelper

ilCertificateObjUserTrackingHelper ilCertificateSettingsCourseFormRepository::$trackingHelper
private

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

Referenced by __construct().

◆ $tree

ilTree ilCertificateSettingsCourseFormRepository::$tree
private

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

Referenced by __construct().


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