ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.SettingsMainGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29use ILIAS\UI\Factory as UIFactory;
30use ILIAS\UI\Renderer as UIRenderer;
31use ILIAS\ILIASObject\Properties\Properties as ObjectProperties;
32use ILIAS\UI\Component\Modal\Interruptive as InterruptiveModal;
37use Psr\Http\Message\ServerRequestInterface;
39
48{
49 public const CMD_SHOW_FORM = 'showForm';
50 public const CMD_SAVE_FORM = 'saveForm';
51 public const CMD_CONFIRMED_SAVE_FORM = 'confirmedSaveForm';
52 public const CMD_SHOW_RESET_TPL_CONFIRM = 'showResetTemplateConfirmation';
53 public const CMD_CONFIRMED_RESET_TPL = 'confirmedResetTemplate';
54
55 private const GENERAL_SETTINGS_SECTION_LABEL = 'general_settings';
56 private const AVAILABILITY_SETTINGS_SECTION_LABEL = 'availability settings';
57 private const PRESENTATION_SETTINGS_SECTION_LABEL = 'presentation_settings';
58 private const INTRODUCTION_SETTINGS_SECTION_LABEL = 'introduction_settings';
59 private const ACCESS_SETTINGS_LABEL = 'access_settings';
60 private const TEST_BEHAVIOUR_SETTINGS_LABEL = 'test_behaviour_settings';
61 private const QUESTION_BEHAVIOUR_SETTINGS_LABEL = 'question_behaviour_settings';
62 private const PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL = 'participants_functionality_settings';
63 private const FINISH_TEST_SETTINGS_LABEL = 'finish_test_settings';
64 private const ECS_FUNCTIONALITY_SETTINGS_LABEL = 'ecs_settings';
65 private const ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL = 'additional_functionality_settings';
66
67 protected ObjectProperties $object_properties;
70
71 private \ilTestQuestionSetConfigFactory $testQuestionSetConfigFactory;
72
73 public function __construct(
74 private readonly \ilGlobalTemplateInterface $tpl,
75 private readonly \ilCtrlInterface $ctrl,
76 private readonly \ilAccessHandler $access,
77 private readonly \ilLanguage $lng,
78 private readonly \ilTree $tree,
79 private readonly \ilDBInterface $db,
80 private readonly \ilObjectDataCache $object_data_cache,
81 private readonly \ilSetting $settings,
82 private readonly UIFactory $ui_factory,
83 private readonly UIRenderer $ui_renderer,
84 private readonly Refinery $refinery,
85 private readonly ServerRequestInterface $request,
86 private readonly \ilComponentRepository $component_repository,
87 private readonly \ilObjUser $active_user,
88 private readonly \ilObjTestGUI $test_gui,
89 private readonly TestLogger $logger,
90 private readonly GeneralQuestionPropertiesRepository $questionrepository
91 ) {
92 $this->object_properties = $this->test_gui->getTestObject()->getObjectProperties();
93 $this->main_settings = $this->test_gui->getTestObject()->getMainSettings();
94 $this->main_settings_repository = $this->test_gui->getTestObject()->getMainSettingsRepository();
95 $this->testQuestionSetConfigFactory = new \ilTestQuestionSetConfigFactory(
96 $this->tree,
97 $this->db,
98 $this->lng,
99 $this->logger,
100 $this->component_repository,
101 $this->test_gui->getTestObject(),
102 $this->questionrepository
103 );
104
105 $this->lng->loadLanguageModule('validation');
106 $this->lng->loadLanguageModule('rep');
107
108 parent::__construct($this->test_gui->getTestObject());
109 }
110
114 public function executeCommand()
115 {
116 if (!$this->access->checkAccess('write', '', $this->test_gui->getRefId())) {
117 $this->tpl->setOnScreenMessage('info', $this->lng->txt('cannot_edit_test'), true);
118 $this->ctrl->redirectByClass([\ilRepositoryGUI::class, \ilObjTestGUI::class, \ilInfoScreenGUI::class]);
119 }
120
121 $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM);
122 $this->$cmd();
123
124 $this->object_data_cache->deleteCachedEntry($this->test_object->getId());
125 }
126
127 private function showForm(?StandardForm $form = null, ?InterruptiveModal $modal = null): void
128 {
129 if ($form === null) {
130 $form = $this->buildForm();
131 }
132
133 $rendered_modal = '';
134 if ($modal !== null) {
135 $rendered_modal = $this->ui_renderer->render($modal);
136 }
137
138 $this->tpl->setContent($this->ui_renderer->render($form) . $rendered_modal);
139 }
140
141 private function confirmedSaveForm(): void
142 {
143 $form = $this->buildForm()->withRequest($this->request);
144 $data = $form->getData();
145 if ($data === null) {
146 $this->showForm($form);
147 return;
148 }
149
150 $current_question_set_type = $this->main_settings->getGeneralSettings()->getQuestionSetType();
151 $current_question_config = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
152 $new_question_set_type = $data[self::GENERAL_SETTINGS_SECTION_LABEL]['question_set_type'];
153
154 if ($new_question_set_type !== $current_question_set_type
155 && $current_question_config->doesQuestionSetRelatedDataExist()) {
157 $this->test_object->getObjectProperties()->getPropertyIsOnline()->withOffline();
158 $this->testQuestionSetConfigFactory->getQuestionSetConfig()->removeQuestionSetRelatedData();
159 }
160
161 if ($this->anonymityChanged($data[self::GENERAL_SETTINGS_SECTION_LABEL]['anonymity'])) {
162 $this->logger->deleteParticipantInteractionsForTest($this->test_object->getRefId());
163 }
164
165 $this->finalizeSave($data);
166 }
167
168
169 private function saveForm(): void
170 {
171 try {
172 $form = $this->buildForm()->withRequest($this->request);
173 $data = $form->getData();
174 } catch (InvalidArgumentException) {
175 $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
176 return;
177 }
178
179 if ($data === null) {
180 $this->showForm($form);
181 return;
182 }
183
184 $current_question_set_type = $this->main_settings->getGeneralSettings()->getQuestionSetType();
185 $current_question_config = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
186 $new_question_set_type = $data[self::GENERAL_SETTINGS_SECTION_LABEL]['question_set_type'];
187
188 if ($new_question_set_type === null) {
189 $this->tpl->setOnScreenMessage('info', $this->lng->txt('tst_settings_form_reload_needed'));
190 $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
191 return;
192 }
193
194 $question_set_modal_required = $new_question_set_type !== $current_question_set_type
195 && $current_question_config->doesQuestionSetRelatedDataExist();
196 $anonymity_modal_required = $this->anonymityChanged(
197 $data[self::GENERAL_SETTINGS_SECTION_LABEL]['anonymity']
198 );
199
200 if ($question_set_modal_required || $anonymity_modal_required) {
201 $modal = $this->populateConfirmationModal(
202 $question_set_modal_required ? $current_question_set_type : null,
203 $question_set_modal_required ? $new_question_set_type : null,
204 $anonymity_modal_required
205 );
206 $this->showForm($form, $modal);
207 return;
208 }
209
210 $this->finalizeSave($data);
211 }
212
213 private function finalizeSave(array $data): void
214 {
215 $this->performSaveForm($data);
216 $additional_information = $this->getObjectDataArrayForLog()
217 + $this->main_settings->getArrayForLog($this->logger->getAdditionalInformationGenerator());
218 if ($this->logger->isLoggingEnabled()) {
219 $this->logger->logTestAdministrationInteraction(
220 $this->logger->getInteractionFactory()->buildTestAdministrationInteraction(
221 $this->test_object->getRefId(),
222 $this->active_user->getId(),
223 TestAdministrationInteractionTypes::MAIN_SETTINGS_MODIFIED,
224 $additional_information
225 )
226 );
227 }
228
229 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
230 $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
231 }
232
233 private function anonymityChanged(bool $anonymity_form_data): bool
234 {
235 return $this->main_settings->getGeneralSettings()->getAnonymity() === false
236 && $anonymity_form_data === true
237 && $this->logger->testHasParticipantInteractions($this->test_object->getRefId());
238 }
239
240 private function getObjectDataArrayForLog(): array
241 {
242 $title_and_description = $this->object_properties->getPropertyTitleAndDescription();
243 $log_array = [
244 AdditionalInformationGenerator::KEY_TEST_TITLE => $title_and_description->getTitle(),
245 AdditionalInformationGenerator::KEY_TEST_DESCRIPTION => $title_and_description->getDescription(),
247 ->getAdditionalInformationGenerator()->getTrueFalseTagForBool(
248 $this->object_properties->getPropertyIsOnline()->getIsOnline()
249 )
250 ];
251
252 return $log_array;
253 }
254
255 private function buildForm(): StandardForm
256 {
258 $input_factory = $this->ui_factory->input();
260
261 $environment['participant_data_exists'] = $this->test_object->participantDataExist();
262 $environment['user_date_format'] = $this->active_user->getDateTimeFormat();
263 $environment['user_time_zone'] = $this->active_user->getTimeZone();
264
265 $main_inputs = [
266 self::GENERAL_SETTINGS_SECTION_LABEL => $this->getGeneralSettingsSection($environment),
267 self::AVAILABILITY_SETTINGS_SECTION_LABEL => $this->getAvailabilitySettingsSection(),
268 self::PRESENTATION_SETTINGS_SECTION_LABEL => $this->getPresentationSettingsSection(),
269 self::INTRODUCTION_SETTINGS_SECTION_LABEL => $this->main_settings->getIntroductionSettings()
270 ->toForm($lng, $input_factory->field(), $refinery),
271 self::ACCESS_SETTINGS_LABEL => $this->main_settings->getAccessSettings()
272 ->toForm($lng, $input_factory->field(), $refinery, $environment),
273 self::TEST_BEHAVIOUR_SETTINGS_LABEL => $this->main_settings->getTestBehaviourSettings()
274 ->toForm($lng, $input_factory->field(), $refinery, $environment),
275 self::QUESTION_BEHAVIOUR_SETTINGS_LABEL => $this->main_settings->getQuestionBehaviourSettings()
276 ->toForm($lng, $input_factory->field(), $refinery, $environment),
277 self::PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL => $this->main_settings->getParticipantFunctionalitySettings()
278 ->toForm($lng, $input_factory->field(), $refinery, $environment),
279 self::FINISH_TEST_SETTINGS_LABEL => $this->main_settings->getFinishingSettings()
280 ->toForm($lng, $input_factory->field(), $refinery)
281 ];
282
283 $inputs = array_merge($main_inputs, $this->getAdditionalFunctionalitySettingsSections($environment));
284
285 return $input_factory->container()->form()->standard(
286 $this->ctrl->getFormActionByClass(self::class, self::CMD_SAVE_FORM),
287 $inputs
288 )->withAdditionalTransformation($this->getFormConstraints());
289 }
290
291 private function getFormConstraints(): Constraint
292 {
293 return $this->refinery->custom()->constraint(
294 function (array $vs): bool {
295 return $vs[self::PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL]['postponed_questions_behaviour'] === false
296 || !($vs[self::QUESTION_BEHAVIOUR_SETTINGS_LABEL]['lock_answers']['lock_answer_on_next_question']
297 ?? $this->main_settings->getQuestionBehaviourSettings()->getLockAnswerOnNextQuestionEnabled());
298 },
299 $this->lng->txt('tst_settings_conflict_postpone_and_lock')
300 );
301 }
302
304 ?string $current_question_set_type,
305 ?string $new_question_set_type,
306 bool $anonymity_modal_required
307 ): InterruptiveModal {
308 $message = '';
309
310 if ($current_question_set_type !== null) {
311 $message .= sprintf(
312 $this->lng->txt('tst_change_quest_set_type_from_old_to_new_with_conflict'),
313 $this->test_object->getQuestionSetTypeTranslation($this->lng, $current_question_set_type),
314 $this->test_object->getQuestionSetTypeTranslation($this->lng, $new_question_set_type)
315 );
316 }
317
318 if ($current_question_set_type === \ilObjTest::QUESTION_SET_TYPE_FIXED
319 && $this->test_object->hasQuestionsWithoutQuestionpool()) {
320 $message .= '<br /><br />' . $this->lng->txt('tst_nonpool_questions_get_lost_warning');
321 }
322
323 if ($anonymity_modal_required) {
324 if ($message !== '') {
325 $message .= '<br /><br />';
326 }
327 $message .= $this->lng->txt('log_participant_data_delete_warning');
328 }
329
330 $this->tpl->addJavaScript('assets/js/settings_confirmation.js');
331 $on_load_code = static function (string $id): string {
332 return 'il.test.confirmSettings.init(' . $id . ')';
333 };
334
335 $modal = $this->ui_factory->modal()->interruptive(
336 $this->lng->txt('confirm'),
337 $message,
338 $this->ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_SAVE_FORM)
339 )->withActionButtonLabel($this->lng->txt('confirm'))
340 ->withAdditionalOnLoadCode($on_load_code);
341
342 return $modal->withOnLoad($modal->getShowSignal());
343 }
344
345 private function performSaveForm(array $data)
346 {
347 $old_online_status = $this->test_object->getObjectProperties()->getPropertyIsOnline()->getIsOnline();
348 $this->test_object->getObjectProperties()->storePropertyTitleAndDescription(
349 $data[self::GENERAL_SETTINGS_SECTION_LABEL]['title_and_description']
350 );
351 $general_settings = $this->getGeneralSettingsForStorage($data[self::GENERAL_SETTINGS_SECTION_LABEL]);
352
353 $this->saveAvailabilitySettingsSection($data[self::AVAILABILITY_SETTINGS_SECTION_LABEL]);
354 $this->savePresentationSettingsSection($data[self::PRESENTATION_SETTINGS_SECTION_LABEL]);
355
356 $introduction_settings = $this->getIntroductionSettingsForStorage(
357 $data[self::INTRODUCTION_SETTINGS_SECTION_LABEL]
358 );
359 $access_settings = $this->getAccessSettingsForStorage(
360 $data[self::ACCESS_SETTINGS_LABEL]
361 );
362 $test_behaviour_settings = $this->getTestBehaviourSettingsForStorage(
363 $data[self::TEST_BEHAVIOUR_SETTINGS_LABEL]
364 );
365 $question_behaviour_settings = $this->getQuestionBehaviourSettingsForStorage(
366 $data[self::QUESTION_BEHAVIOUR_SETTINGS_LABEL]
367 );
368 $participant_functionality_settings = $this->getParticipantsFunctionalitySettingsForStorage(
369 $data[self::PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL]
370 );
371
372 $finishing_settings = $this->getFinishingSettingsForStorage($data[self::FINISH_TEST_SETTINGS_LABEL]);
373
374 if (array_key_exists(self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL, $data)
375 || array_key_exists(self::ECS_FUNCTIONALITY_SETTINGS_LABEL, $data)) {
376 $this->saveAdditionalFunctionalitySettingsSection($data);
377 }
378
379 $additional_settings = $this->getAdditionalFunctionalitySettingsForStorage(
380 $data[self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL] ?? []
381 );
382
383 $settings = new MainSettings(
384 $this->main_settings->getId(),
385 $general_settings,
386 $introduction_settings,
387 $access_settings,
388 $test_behaviour_settings,
389 $question_behaviour_settings,
390 $participant_functionality_settings,
391 $finishing_settings,
392 $additional_settings
393 );
394 $this->main_settings_repository->store($settings);
395 $this->main_settings = $this->main_settings_repository->getFor($this->test_object->getTestId());
396 $this->test_object->read();
397 $this->test_object->addToNewsOnOnline(
398 $old_online_status,
399 $this->test_object->getObjectProperties()->getPropertyIsOnline()->getIsOnline()
400 );
401 }
402
403 private function getGeneralSettingsSection(array $environment): Section
404 {
405 $field_factory = $this->ui_factory->input()->field();
406
407 $inputs['title_and_description'] = $this->test_object->getObjectProperties()->getPropertyTitleAndDescription()
408 ->toForm($this->lng, $field_factory, $this->refinery);
409 $inputs += $this->main_settings->getGeneralSettings()
410 ->toForm($this->lng, $field_factory, $this->refinery, $environment);
411
412 return $field_factory->section(
413 $inputs,
414 $this->lng->txt('tst_general_properties')
415 );
416 }
417
421 private function getGeneralSettingsForStorage(array $section): SettingsGeneral
422 {
423 if ($this->test_object->participantDataExist()) {
424 return $this->main_settings->getGeneralSettings();
425 }
426
427 return $this->main_settings->getGeneralSettings()
428 ->withQuestionSetType($section['question_set_type'])
429 ->withAnonymity($section['anonymity']);
430 }
431
433 {
434 $input_factory = $this->ui_factory->input();
435
436 $inputs['is_online'] = $this->getIsOnlineSettingInput();
437
438 return $input_factory->field()->section(
439 $inputs,
440 $this->lng->txt('rep_activation_availability')
441 );
442 }
443
445 {
446 $field_factory = $this->ui_factory->input()->field();
447
448 $question_set_config_complete = $this->test_object->isComplete(
449 $this->testQuestionSetConfigFactory->getQuestionSetConfig()
450 );
451
452 $is_online = $this->test_object->getObjectProperties()->getPropertyIsOnline()
453 ->toForm($this->lng, $field_factory, $this->refinery);
454
455 if (sizeof(\ilObject::_getAllReferences($this->test_object->getId())) > 1) {
456 $is_online = $is_online->withByline(
457 $is_online->getByline() . ' ' . $this->lng->txt('rep_activation_online_object_info')
458 );
459 }
460
461 if (!$question_set_config_complete) {
462 $is_online = $is_online
463 ->withByline($this->lng->txt('cannot_switch_to_online_no_questions_andor_no_mark_steps'))
464 ->withDisabled(true);
465 }
466
467 return $is_online;
468 }
469
470 private function saveAvailabilitySettingsSection(array $section): void
471 {
472 $this->test_object->getObjectProperties()->storePropertyIsOnline($section['is_online']);
473 }
474
476 {
477 $input_factory = $this->ui_factory->input();
478
479 $custom_icon_input = $this->test_object->getObjectProperties()->getPropertyIcon()
480 ->toForm($this->lng, $input_factory->field(), $this->refinery);
481
482 if ($custom_icon_input !== null) {
483 $inputs['custom_icon'] = $custom_icon_input;
484 }
485 $inputs['tile_image'] = $this->test_object->getObjectProperties()->getPropertyTileImage()
486 ->toForm($this->lng, $input_factory->field(), $this->refinery);
487
488 return $input_factory->field()->section(
489 $inputs,
490 $this->lng->txt('tst_presentation_settings_section')
491 );
492 }
493
494 protected function savePresentationSettingsSection(array $section): void
495 {
496 if (array_key_exists('custom_icon', $section)) {
497 $this->test_object->getObjectProperties()->storePropertyIcon($section['custom_icon']);
498 }
499 $this->test_object->getObjectProperties()->storePropertyTileImage($section['tile_image']);
500 }
501
503 {
504 return $this->main_settings->getIntroductionSettings()
505 ->withIntroductionEnabled($section['introduction_enabled'])
506 ->withExamConditionsCheckboxEnabled($section['conditions_checkbox_enabled']);
507 }
508
509 private function getAccessSettingsForStorage(array $section): SettingsAccess
510 {
511 $access_settings = $this->main_settings->getAccessSettings()
512 ->withStartTimeEnabled($section['access_window']['start_time_enabled'])
513 ->withStartTime($section['access_window']['start_time'])
514 ->withEndTimeEnabled($section['access_window']['end_time_enabled'])
515 ->withEndTime($section['access_window']['end_time'])
516 ->withPasswordEnabled($section['test_password']['password_enabled'])
517 ->withPassword($section['test_password']['password_value'])
518 ->withIpRangeFrom($section['ip_range']['ip_range_from'])
519 ->withIpRangeTo($section['ip_range']['ip_range_to'])
520 ->withFixedParticipants($section['fixed_participants_enabled']);
521
522 if ($this->test_object->participantDataExist()) {
523 return $access_settings;
524 }
525
526 return $access_settings->withStartTimeEnabled($section['access_window']['start_time_enabled'])
527 ->withStartTime($section['access_window']['start_time']);
528 }
529
531 {
532 $test_behaviour_settings = $this->main_settings->getTestBehaviourSettings()
533 ->withKioskMode($section['kiosk_mode'])
534 ->withExamIdInTestAttemptEnabled($section['show_exam_id']);
535
536 if ($this->test_object->participantDataExist()) {
537 return $test_behaviour_settings;
538 }
539
540 return $test_behaviour_settings
541 ->withNumberOfTries($section['limit_attempts']['number_of_available_attempts'])
542 ->withBlockAfterPassedEnabled($section['limit_attempts']['block_after_passed'])
543 ->withPassWaiting($section['force_waiting_between_attempts'])
544 ->withProcessingTimeEnabled($section['time_limit_for_completion']['processing_time_limit'])
545 ->withProcessingTime($section['time_limit_for_completion']['time_limit_for_completion_value'])
546 ->withResetProcessingTime($section['time_limit_for_completion']['reset_time_limit_for_completion_by_attempt']);
547 }
548
550 {
551 $question_behaviour_settings = $this->main_settings->getQuestionBehaviourSettings()
552 ->withQuestionTitleOutputMode($section['title_output'])
553 ->withAutosaveEnabled($section['autosave']['autosave_enabled'])
554 ->withAutosaveInterval($section['autosave']['autosave_interval'])
555 ->withShuffleQuestions($section['shuffle_questions']);
556
557 if ($this->test_object->participantDataExist()) {
558 return $question_behaviour_settings;
559 }
560
561 return $question_behaviour_settings
562 ->withInstantFeedbackPointsEnabled($section['instant_feedback']['enabled_feedback_types']['instant_feedback_points'])
563 ->withInstantFeedbackGenericEnabled($section['instant_feedback']['enabled_feedback_types']['instant_feedback_generic'])
564 ->withInstantFeedbackSpecificEnabled($section['instant_feedback']['enabled_feedback_types']['instant_feedback_specific'])
565 ->withInstantFeedbackSolutionEnabled($section['instant_feedback']['enabled_feedback_types']['instant_feedback_solution'])
566 ->withForceInstantFeedbackOnNextQuestion($section['instant_feedback']['feedback_on_next_question'])
567 ->withLockAnswerOnInstantFeedbackEnabled($section['lock_answers']['lock_answer_on_instant_feedback'])
568 ->withLockAnswerOnNextQuestionEnabled($section['lock_answers']['lock_answer_on_next_question']);
569 }
570
571
573 {
574 return $this->main_settings->getParticipantFunctionalitySettings()
575 ->withUsePreviousAnswerAllowed($section['use_previous_answers'])
576 ->withSuspendTestAllowed($section['allow_suspend_test'])
577 ->withPostponedQuestionsMoveToEnd($section['postponed_questions_behaviour'])
578 ->withUsrPassOverviewMode($section['usr_pass_overview'])
579 ->withQuestionMarkingEnabled($section['enable_question_marking'])
580 ->withQuestionListEnabled($section['enable_question_list']);
581 }
582
583 private function getFinishingSettingsForStorage(array $section): SettingsFinishing
584 {
585 $redirect_after_finish = $section['redirect_after_finish'];
586 return $this->main_settings->getFinishingSettings()
587 ->withShowAnswerOverview($section['show_answer_overview'])
588 ->withConcludingRemarksEnabled($section['show_concluding_remarks'])
589 ->withRedirectionMode($redirect_after_finish['redirect_mode'])
590 ->withRedirectionUrl($redirect_after_finish['redirect_url']);
591 }
592
593 protected function getAdditionalFunctionalitySettingsSections(array $environment): array
594 {
595 $sections = [];
596
597 $ecs = new \ilECSTestSettings($this->test_object);
598 $ecs_section = $ecs->getSettingsSection(
599 $this->ui_factory->input()->field(),
600 $this->refinery
601 );
602
603 if ($ecs_section !== null) {
604 $sections[self::ECS_FUNCTIONALITY_SETTINGS_LABEL] = $ecs_section;
605 }
606
607 $inputs['organisational_units_activation'] = $this->getOrganisationalUnitsActivationInput();
608
609 $inputs += $this->main_settings->getAdditionalSettings()->toForm(
610 $this->lng,
611 $this->ui_factory->input()->field(),
612 $this->refinery,
613 $environment
614 );
615
616 $inputs = array_filter($inputs, fn($v) => $v !== null);
617
618 if (count($inputs) > 0) {
619 $sections[self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL] = $this->ui_factory->input()->field()
620 ->section($inputs, $this->lng->txt('obj_features'));
621 }
622
623 return $sections;
624 }
625
627 {
628 $position_settings = \ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
629 $this->test_object->getType()
630 );
631 if (!$position_settings->isActive()) {
632 return null;
633 }
634
635 $enable_organisational_units_access = $this->ui_factory->input()->field()
636 ->checkbox(
637 $this->lng->txt('obj_orgunit_positions'),
638 $this->lng->txt('obj_orgunit_positions_info')
639 )->withValue(
640 (new \ilOrgUnitObjectPositionSetting($this->test_object->getId()))->isActive()
641 ?? $position_settings->getActivationDefault() === \ilOrgUnitObjectTypePositionSetting::DEFAULT_ON
642 );
643 if (!$position_settings->isChangeableForObject()) {
644 return $enable_organisational_units_access->withDisabled(true);
645 }
646 return $enable_organisational_units_access;
647 }
648
649 protected function saveAdditionalFunctionalitySettingsSection(array $sections): void
650 {
651 if (array_key_exists(self::ECS_FUNCTIONALITY_SETTINGS_LABEL, $sections)) {
652 $ecs = new \ilECSTestSettings($this->test_object);
653 $ecs->saveSettingsSection($sections[self::ECS_FUNCTIONALITY_SETTINGS_LABEL]);
654 }
655
656 if (!array_key_exists(self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL, $sections)) {
657 return;
658 }
659
660 $additional_settings_section = $sections[self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL];
661 if (array_key_exists('organisational_units_activation', $additional_settings_section)) {
662 $this->saveOrganisationalUnitsActivation($additional_settings_section['organisational_units_activation']);
663 }
664 }
665
666 protected function saveOrganisationalUnitsActivation(bool $activation): void
667 {
668 $position_settings = \ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
669 $this->test_object->getType()
670 );
671
672 if ($position_settings->isActive() && $position_settings->isChangeableForObject()) {
673 $orgu_object_settings = new \ilOrgUnitObjectPositionSetting($this->test_object->getId());
674 $orgu_object_settings->setActive(
675 $activation
676 );
677 $orgu_object_settings->update();
678 }
679 }
680
682 {
683 $additional_settings = $this->main_settings->getAdditionalSettings()->withHideInfoTab($section['hide_info_tab']);
684
685 if ($this->test_object->participantDataExist()) {
686 return $additional_settings;
687 }
688
689 if (!(new \ilSkillManagementSettings())->isActivated()) {
690 return $additional_settings->withSkillsServiceEnabled(false);
691 }
692
693 return $additional_settings->withSkillsServiceEnabled($section['skills_service_activation']);
694 }
695
696 private function buildDateOrNullFromILIASValue(?int $value): ?\DateTimeImmutable
697 {
698 if ($value === null || $value === 0) {
699 return null;
700 }
701
702 return \DateTimeImmutable::createFromFormat(
703 'U',
704 (string) $value
705 )->setTimezone(new \DateTimeZone($this->active_user->getTimeZone()));
706 }
707}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
@ilCtrl_Calls ILIAS\Test\Settings\MainSettings\SettingsMainGUI: ilPropertyFormGUI @ilCtrl_Calls ILIAS...
ilTestQuestionSetConfigFactory $testQuestionSetConfigFactory
__construct(private readonly \ilGlobalTemplateInterface $tpl, private readonly \ilCtrlInterface $ctrl, private readonly \ilAccessHandler $access, private readonly \ilLanguage $lng, private readonly \ilTree $tree, private readonly \ilDBInterface $db, private readonly \ilObjectDataCache $object_data_cache, private readonly \ilSetting $settings, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly Refinery $refinery, private readonly ServerRequestInterface $request, private readonly \ilComponentRepository $component_repository, private readonly \ilObjUser $active_user, private readonly \ilObjTestGUI $test_gui, private readonly TestLogger $logger, private readonly GeneralQuestionPropertiesRepository $questionrepository)
populateConfirmationModal(?string $current_question_set_type, ?string $new_question_set_type, bool $anonymity_modal_required)
showForm(?StandardForm $form=null, ?InterruptiveModal $modal=null)
language handling
Class ilObjTestGUI.
const QUESTION_SET_TYPE_FIXED
User class.
class ilObjectDataCache
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Setting Class.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
A constraint encodes some resrtictions on values.
Definition: Constraint.php:32
withByline(string $byline)
Get an input like this, but with an additional/replaced label.
This describes a standard form.
Definition: Standard.php:30
This describes checkbox inputs.
Definition: Checkbox.php:29
This describes section inputs.
Definition: Section.php:29
An entity that renders components to a string output.
Definition: Renderer.php:31
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilDBInterface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31