ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateSettingsCourseFormRepository Class Reference
+ Inheritance diagram for ilCertificateSettingsCourseFormRepository:
+ Collaboration diagram for ilCertificateSettingsCourseFormRepository:

Public Member Functions

 __construct (\ilObject $object, string $certificatePath, ilLanguage $language, ilTemplate $template, ilCtrl $controller, ilAccess $access, ilToolbarGUI $toolbar, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilObjectLP $learningProgressObject=null, ilCertificateSettingsFormRepository $settingsFromFactory=null, ilCertificateObjUserTrackingHelper $trackingHelper=null, ilCertificateObjectHelper $objectHelper=null, ilCertificateObjectLPHelper $lpHelper=null, ilTree $tree=null, ilSetting $setting=null)
 
 createForm (ilCertificateGUI $certificateGUI, ilCertificate $certificateObject)
 
 save (array $formFields)
 
 fetchFormFieldData (string $content)
 

Private Member Functions

 getLPTypes (int $a_parent_ref_id)
 
 getInvalidLPModes ()
 

Private Attributes

 $language
 
 $settingsFromFactory
 
 $object
 
 $learningProgressObject
 
 $trackingHelper
 
 $objectHelper
 
 $lpHelper
 
 $tree
 
 $setting
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateSettingsCourseFormRepository::__construct ( \ilObject  $object,
string  $certificatePath,
ilLanguage  $language,
ilTemplate  $template,
ilCtrl  $controller,
ilAccess  $access,
ilToolbarGUI  $toolbar,
ilCertificatePlaceholderDescription  $placeholderDescriptionObject,
ilObjectLP  $learningProgressObject = null,
ilCertificateSettingsFormRepository  $settingsFromFactory = null,
ilCertificateObjUserTrackingHelper  $trackingHelper = null,
ilCertificateObjectHelper  $objectHelper = null,
ilCertificateObjectLPHelper  $lpHelper = null,
ilTree  $tree = null,
ilSetting  $setting = null 
)
Parameters
ilObject$object
string$certificatePath
ilLanguage$language
ilTemplate$template
ilCtrl$controller
ilAccess$access
ilToolbarGUI$toolbar
ilCertificatePlaceholderDescription$placeholderDescriptionObject
ilObjectLP | null$learningProgressObject
ilCertificateSettingsFormRepository | null$settingsFromFactory
ilCertificateObjUserTrackingHelper | null$trackingHelper
ilCertificateObjectHelper | null$objectHelper
ilCertificateObjectLPHelper | null$lpHelper
ilTree | null$tree
ilSetting | null$setting

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

References $DIC, $language, $learningProgressObject, $lpHelper, $object, $objectHelper, $setting, $settingsFromFactory, $template, $trackingHelper, $tree, ilObject\getId(), and ilObjectLP\getInstance().

87  {
88  $this->object = $object;
89 
90  $this->language = $language;
91 
92  if (null === $settingsFromFactory) {
93  $settingsFromFactory = new ilCertificateSettingsFormRepository(
94  $object->getId(),
95  $certificatePath,
96  $language,
97  $template,
98  $controller,
99  $access,
100  $toolbar,
101  $placeholderDescriptionObject
102  );
103  }
104  $this->settingsFromFactory = $settingsFromFactory;
105 
106  if (null === $learningProgressObject) {
107  $learningProgressObject = ilObjectLP::getInstance($this->object->getId());
108  }
109  $this->learningProgressObject = $learningProgressObject;
110 
111  if (null === $trackingHelper) {
112  $trackingHelper = new ilCertificateObjUserTrackingHelper();
113  }
114  $this->trackingHelper = $trackingHelper;
115 
116  if (null === $objectHelper) {
117  $objectHelper = new ilCertificateObjectHelper();
118  }
119  $this->objectHelper = $objectHelper;
120 
121  if (null === $lpHelper) {
122  $lpHelper = new ilCertificateObjectLPHelper();
123  }
124  $this->lpHelper = $lpHelper;
125 
126  if (null === $tree) {
127  global $DIC;
128  $tree = $DIC['tree'];
129  }
130  $this->tree = $tree;
131 
132  if (null === $setting) {
133  $setting = new ilSetting('crs');
134  }
135  $this->setting = $setting;
136  }
$template
global $DIC
Definition: saml.php:7
static getInstance($a_obj_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ createForm()

ilCertificateSettingsCourseFormRepository::createForm ( ilCertificateGUI  $certificateGUI,
ilCertificate  $certificateObject 
)
Parameters
ilCertificateGUI$certificateGUI
ilCertificate$certificateObject
Returns
ilPropertyFormGUI
Exceptions

Implements ilCertificateFormRepository.

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

References $form, $id, $lpHelper, $objectHelper, getInvalidLPModes(), getLPTypes(), ilLPObjSettings\getMode(), ilLPObjSettings\LP_MODE_DEACTIVATED, and ilFormPropertyGUI\setTitle().

152  {
153  $form = $this->settingsFromFactory->createForm($certificateGUI, $certificateObject);
154 
155  $objectLearningProgressSettings = new ilLPObjSettings($this->object->getId());
156 
157  $mode = $objectLearningProgressSettings->getMode();
158  if (!$this->trackingHelper->enabledLearningProgress() || $mode == ilLPObjSettings::LP_MODE_DEACTIVATED) {
159  $subitems = new ilRepositorySelector2InputGUI($this->language->txt('objects'), 'subitems', true);
160 
161  $formSection = new \ilFormSectionHeaderGUI();
162  $formSection->setTitle($this->language->txt('cert_form_sec_add_features'));
163  $form->addItem($formSection);
164 
165  $exp = $subitems->getExplorerGUI();
166  $exp->setSkipRootNode(true);
167  $exp->setRootId($this->object->getRefId());
168  $exp->setTypeWhiteList($this->getLPTypes($this->object->getId()));
169 
172  $subitems->setTitleModifier(function ($id) use ($objectHelper, $lpHelper) {
173  if (null === $id) {
174  return '';
175  }
176  $obj_id = $objectHelper->lookupObjId((int) $id);
177  $olp = $lpHelper->getInstance($obj_id);
178 
179  $invalid_modes = $this->getInvalidLPModes();
180 
181  $mode = $olp->getModeText($olp->getCurrentMode());
182 
183  if (in_array($olp->getCurrentMode(), $invalid_modes)) {
184  $mode = '<strong>' . $mode . '</strong>';
185  }
186  return $objectHelper->lookupTitle($obj_id) . ' (' . $mode . ')';
187  });
188 
189  $subitems->setRequired(true);
190  $form->addItem($subitems);
191  }
192 
193  return $form;
194  }
if(!array_key_exists('StateId', $_REQUEST)) $id
if(isset($_POST['submit'])) $form
setTitle($a_title)
Set Title.
+ Here is the call graph for this function:

◆ fetchFormFieldData()

ilCertificateSettingsCourseFormRepository::fetchFormFieldData ( string  $content)
Parameters
string$content
Returns
array|mixed

Implements ilCertificateFormRepository.

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

231  {
232  $formFields = $this->settingsFromFactory->fetchFormFieldData($content);
233 
234  $formFields['subitems'] = json_decode($this->setting->get('cert_subitems_' . $this->object->getId(), json_encode(array())));
235  if ($formFields['subitems'] === 'null' || $formFields['subitems'] === null) {
236  $formFields['subitems'] = array();
237  }
238  return $formFields;
239  }

◆ getInvalidLPModes()

ilCertificateSettingsCourseFormRepository::getInvalidLPModes ( )
private
Returns
array

Definition at line 270 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().

271  {
272  $invalid_modes = array(
275  );
276 
277  // without active LP the following modes cannot be supported
278  if (!$this->trackingHelper->enabledLearningProgress()) {
279  // status cannot be set without active LP
280  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL;
281  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR;
283 
284  // mode cannot be configured without active LP
285  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION;
286  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_MOBS;
287  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_TLT;
288  $invalid_modes[] = ilLPObjSettings::LP_MODE_SCORM;
289  $invalid_modes[] = ilLPObjSettings::LP_MODE_VISITS; // ?
290  }
291 
292  return $invalid_modes;
293  }
+ Here is the caller graph for this function:

◆ getLPTypes()

ilCertificateSettingsCourseFormRepository::getLPTypes ( int  $a_parent_ref_id)
private
Parameters
int$a_parent_ref_id
Returns
array

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

References $result, and $root.

Referenced by createForm().

245  : array
246  {
247  $result = array();
248 
249  $root = $this->tree->getNodeData($a_parent_ref_id);
250  $sub_items = $this->tree->getSubTree($root);
251  array_shift($sub_items); // remove root
252 
253  foreach ($sub_items as $node) {
254  if ($this->lpHelper->isSupportedObjectType($node['type'])) {
255  $class = $this->lpHelper->getTypeClass($node['type']);
256  $modes = $class::getDefaultModes($this->trackingHelper->enabledLearningProgress());
257 
258  if (sizeof($modes) > 1) {
259  $result[] = $node['type'];
260  }
261  }
262  }
263 
264  return $result;
265  }
$result
$root
Definition: sabredav.php:45
+ Here is the caller graph for this function:

◆ save()

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

Implements ilCertificateFormRepository.

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

References $learningProgressObject, $message, and getInvalidLPModes().

200  {
201  $invalidModes = $this->getInvalidLPModes();
202 
203  $titlesOfObjectsWithInvalidModes = array();
204  $refIds = array();
205  if (isset($formFields['subitems'])) {
206  $refIds = $formFields['subitems'];
207  }
208 
209  foreach ($refIds as $refId) {
210  $objectId = $this->objectHelper->lookupObjId((int) $refId);
211  $learningProgressObject = $this->lpHelper->getInstance($objectId);
212  $currentMode = $learningProgressObject->getCurrentMode();
213  if (in_array($currentMode, $invalidModes)) {
214  $titlesOfObjectsWithInvalidModes[] = $this->objectHelper->lookupTitle($objectId);
215  }
216  }
217 
218  if (sizeof($titlesOfObjectsWithInvalidModes)) {
219  $message = sprintf($this->language->txt('certificate_learning_progress_must_be_active'), implode(', ', $titlesOfObjectsWithInvalidModes));
220  throw new ilException($message);
221  }
222 
223  $this->setting->set('cert_subitems_' . $this->object->getId(), json_encode($formFields['subitems']));
224  }
catch(Exception $e) $message
+ Here is the call graph for this function:

Field Documentation

◆ $language

ilCertificateSettingsCourseFormRepository::$language
private

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

Referenced by __construct().

◆ $learningProgressObject

ilCertificateSettingsCourseFormRepository::$learningProgressObject
private

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

Referenced by __construct(), and save().

◆ $lpHelper

ilCertificateSettingsCourseFormRepository::$lpHelper
private

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

Referenced by __construct(), and createForm().

◆ $object

ilCertificateSettingsCourseFormRepository::$object
private

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

Referenced by __construct().

◆ $objectHelper

ilCertificateSettingsCourseFormRepository::$objectHelper
private

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

Referenced by __construct(), and createForm().

◆ $setting

ilCertificateSettingsCourseFormRepository::$setting
private

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

Referenced by __construct().

◆ $settingsFromFactory

ilCertificateSettingsCourseFormRepository::$settingsFromFactory
private

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

Referenced by __construct().

◆ $trackingHelper

ilCertificateSettingsCourseFormRepository::$trackingHelper
private

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

Referenced by __construct().

◆ $tree

ilCertificateSettingsCourseFormRepository::$tree
private

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

Referenced by __construct().


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