19 declare(strict_types=1);
93 $this->
tabs = $DIC->tabs();
94 $this->
toolbar = $DIC[
'ilToolbar'];
95 $this->
ui = $DIC->ui();
96 $this->tpl = $DIC->ui()->mainTemplate();
98 $this->request = $DIC->http()->request();
99 $this->object_data_cache = $DIC[
'ilObjDataCache'];
100 $this->
settings = $DIC[
'ilSetting'];
102 $this->main_settings = $this->test_gui->getTestObject()->getMainSettings();
103 $this->main_settings_repository = $this->test_gui->getTestObject()->getMainSettingsRepository();
109 $this->component_repository,
110 $this->test_gui->getTestObject(),
114 $this->
lng->loadLanguageModule(
'validation');
124 if (!$this->
access->checkAccess(
'write',
'', $this->test_gui->getRefId())) {
125 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'cannot_edit_test'),
true);
126 $this->
ctrl->redirect($this->test_gui,
'infoScreen');
129 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_FORM);
132 $this->object_data_cache->deleteCachedEntry($this->test_object->getId());
133 $this->test_gui->prepareOutput();
141 $this->
ui->factory()->link()->standard(
142 $this->
lng->txt(
'back'),
143 $this->
ctrl->getLinkTargetByClass(self::class,
'showForm')
147 $this->tpl->setContent(
148 $this->main_settings->getIntroductionSettings()->getIntroductionText()
155 $this->
ui->factory()->link()->standard(
156 $this->
lng->txt(
'back'),
157 $this->
ctrl->getLinkTargetByClass(self::class,
'showForm')
161 $this->tpl->setContent(
162 $this->main_settings->getFinishingSettings()->getConcludingRemarksText()
168 if ($form === null) {
172 if ($this->main_settings->getIntroductionSettings()->getIntroductionText() !==
'') {
174 $this->
ui->factory()->link()->standard(
175 $this->
lng->txt(
'show_old_introduction'),
176 $this->
ctrl->getLinkTargetByClass(self::class,
'showOldIntroduction')
181 if ($this->main_settings->getFinishingSettings()->getConcludingRemarksText() !==
'') {
183 $this->
ui->factory()->link()->standard(
184 $this->
lng->txt(
'show_old_concluding_remarks'),
185 $this->
ctrl->getLinkTargetByClass(self::class,
'showOldConcludingRemarks')
190 $rendered_modal =
'';
191 if ($modal !== null) {
192 $rendered_modal = $this->
ui->renderer()->render($modal);
195 $this->tpl->setContent($this->
ui->renderer()->render($form) . $rendered_modal);
200 $form = $this->
buildForm()->withRequest($this->request);
201 $data = $form->getData();
202 if (
$data === null) {
207 $data[self::AVAILABILITY_SETTINGS_SECTION_LABEL][
'is_online'] =
208 $this->test_object->getObjectProperties()->getPropertyIsOnline()->withOffline();
209 $this->testQuestionSetConfigFactory->getQuestionSetConfig()->removeQuestionSetRelatedData();
217 $form = $this->
buildForm()->withRequest($this->request);
218 $data = $form->getData();
219 if (
$data === null) {
224 $current_question_set_type = $this->main_settings->getGeneralSettings()->getQuestionSetType();
225 $current_question_config = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
226 $new_question_set_type =
$data[self::GENERAL_SETTINGS_SECTION_LABEL][
'question_set_type'];
228 if ($new_question_set_type !== $current_question_set_type
229 && $current_question_config->doesQuestionSetRelatedDataExist()) {
243 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
250 $input_factory = $this->
ui->factory()->input();
254 $user_format = $this->activeUser->getDateFormat();
256 $environment[
'participant_data_exists'] = $this->test_object->participantDataExist();
257 $environment[
'user_date_format'] = $data_factory->dateFormat()->withTime24($user_format);
258 $environment[
'user_time_zone'] = $this->activeUser->getTimeZone();
264 self::INTRODUCTION_SETTINGS_SECTION_LABEL => $this->main_settings->getIntroductionSettings()
266 self::ACCESS_SETTINGS_LABEL => $this->main_settings->getAccessSettings()
267 ->toForm(
$lng, $input_factory->field(),
$refinery, $environment),
268 self::TEST_BEHAVIOUR_SETTINGS_LABEL => $this->main_settings->getTestBehaviourSettings()
269 ->toForm(
$lng, $input_factory->field(),
$refinery, $environment),
270 self::QUESTION_BEHAVIOUR_SETTINGS_LABEL => $this->main_settings->getQuestionBehaviourSettings()
271 ->toForm(
$lng, $input_factory->field(),
$refinery, $environment),
272 self::PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL => $this->main_settings->getParticipantFunctionalitySettings()
273 ->toForm(
$lng, $input_factory->field(),
$refinery, $environment),
274 self::FINISH_TEST_SETTINGS_LABEL => $this->main_settings->getFinishingSettings()
280 return $input_factory->container()->form()->standard(
281 $this->
ctrl->getFormActionByClass(self::class, self::CMD_SAVE_FORM),
288 return $this->
refinery->custom()->constraint(
289 function (array $vs):
bool {
290 if ($vs[self::PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL][
'postponed_questions_behaviour'] ===
true 291 && $vs[self::QUESTION_BEHAVIOUR_SETTINGS_LABEL][
'lock_answers'][
'lock_answer_on_next_question']) {
296 $this->
lng->txt(
'tst_settings_conflict_postpone_and_lock')
301 string $current_question_set_type,
302 string $new_question_set_type
305 $this->
lng->txt(
'tst_change_quest_set_type_from_old_to_new_with_conflict'),
306 $this->test_object->getQuestionSetTypeTranslation($this->
lng, $current_question_set_type),
307 $this->test_object->getQuestionSetTypeTranslation($this->
lng, $new_question_set_type)
311 && $this->test_object->hasQuestionsWithoutQuestionpool()) {
312 $message .=
'<br /><br />' . $this->
lng->txt(
'tst_nonpool_questions_get_lost_warning');
315 $this->tpl->addJavaScript(
'./Modules/Test/templates/default/settings_confirmation.js');
316 $on_load_code =
static function (
string $id):
string {
317 return 'il.test.confirmSettings.init(' .
$id .
')';
320 $modal = $this->
ui->factory()->modal()->interruptive(
321 $this->
lng->txt(
'confirm'),
323 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_SAVE_FORM)
324 )->withActionButtonLabel($this->
lng->txt(
'confirm'))
327 return $modal->withOnLoad($modal->getShowSignal());
332 $old_online_status = $this->test_object->getObjectProperties()->getPropertyIsOnline()->getIsOnline();
333 $this->test_object->getObjectProperties()->storePropertyTitleAndDescription(
334 $data[self::GENERAL_SETTINGS_SECTION_LABEL][
'title_and_description']
342 $data[self::INTRODUCTION_SETTINGS_SECTION_LABEL]
345 $data[self::ACCESS_SETTINGS_LABEL]
348 $data[self::TEST_BEHAVIOUR_SETTINGS_LABEL]
351 $data[self::QUESTION_BEHAVIOUR_SETTINGS_LABEL]
354 $data[self::PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL]
359 if (array_key_exists(self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL, $data)
360 || array_key_exists(self::ECS_FUNCTIONALITY_SETTINGS_LABEL, $data)) {
365 $data[self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL] ?? []
369 $this->test_object->getTestId(),
371 $introduction_settings,
373 $test_behaviour_settings,
374 $question_behaviour_settings,
375 $participant_functionality_settings,
379 $this->main_settings_repository->store($settings);
380 $this->main_settings = $this->main_settings_repository->getFor($this->test_object->getTestId());
381 $this->test_object->read();
382 $this->test_object->addToNewsOnOnline(
384 $this->test_object->getObjectProperties()->getPropertyIsOnline()->getIsOnline()
390 if (!$this->test_object->participantDataExist() && !$this->test_object->getFixedParticipants()) {
391 foreach ($this->test_object->getInvitedUsers() as $usr_id => $usr_data) {
392 $this->test_object->disinviteUser($usr_id);
399 $field_factory = $this->
ui->factory()->input()->field();
401 $inputs[
'title_and_description'] = $this->test_object->getObjectProperties()->getPropertyTitleAndDescription()
402 ->toForm($this->
lng, $field_factory, $this->
refinery);
403 $inputs += $this->main_settings->getGeneralSettings()
404 ->toForm($this->
lng, $field_factory, $this->
refinery, $environment);
406 return $field_factory->section(
408 $this->
lng->txt(
'tst_general_properties')
417 if ($this->test_object->participantDataExist()) {
418 return $this->main_settings->getGeneralSettings();
421 return $this->main_settings->getGeneralSettings()
423 ->withAnonymity($section[
'anonymity']);
428 $input_factory = $this->
ui->factory()->input();
433 return $input_factory->field()->section(
435 $this->
lng->txt(
'rep_activation_availability')
441 $field_factory = $this->
ui->factory()->input()->field();
443 $question_set_config_complete = $this->test_object->isComplete(
444 $this->testQuestionSetConfigFactory->getQuestionSetConfig()
447 $is_online = $this->test_object->getObjectProperties()->getPropertyIsOnline()
448 ->toForm($this->
lng, $field_factory, $this->
refinery);
451 $is_online = $is_online->withByline(
452 $is_online->getByline() .
' ' . $this->
lng->txt(
'rep_activation_online_object_info')
456 if (!$question_set_config_complete) {
457 $is_online = $is_online
458 ->withByline($this->
lng->txt(
'cannot_switch_to_online_no_questions_andor_no_mark_steps'))
459 ->withDisabled(
true);
467 $field_factory = $this->
ui->factory()->input()->field();
473 $user_format = $this->activeUser->getDateFormat();
474 $format = $data_factory->dateFormat()->withTime24($user_format);
476 $inputs[
'time_span'] = $field_factory->duration($this->
lng->txt(
'rep_time_period'))
477 ->withTimezone($this->activeUser->getTimeZone())
478 ->withFormat($format)
480 ->withRequired(
true);
481 $inputs[
'activation_visibility'] = $field_factory->checkbox(
482 $this->
lng->txt(
'rep_activation_limited_visibility'),
483 $this->
lng->txt(
'tst_activation_limited_visibility_info')
486 return $field_factory->optionalGroup(
488 $this->
lng->txt(
'rep_time_based_availability')
495 return $this->
refinery->custom()->transformation(
496 static function (?array $vs): array {
499 'is_activation_limited' =>
false,
500 'activation_starting_time' => null,
501 'activation_ending_time' => null,
502 'activation_visibility' => false
506 $start = $vs[
'time_span'][
'start']->getTimestamp();
507 $end = $vs[
'time_span'][
'end']->getTimestamp();
510 'is_activation_limited' =>
true,
511 'activation_starting_time' => $start,
512 'activation_ending_time' => $end,
513 'activation_visibility' => $vs[
'activation_visibility']
522 if ($this->test_object->isActivationLimited()) {
525 DateTimeImmutable::createFromFormat(
527 (
string) $this->test_object->getActivationStartingTime()
528 )->setTimezone(
new DateTimeZone($this->activeUser->getTimeZone())),
529 DateTimeImmutable::createFromFormat(
531 (
string) $this->test_object->getActivationEndingTime()
532 )->setTimezone(
new DateTimeZone($this->activeUser->getTimeZone())),
534 'activation_visibility' => $this->test_object->getActivationVisibility()
542 $time_based_availability = $section[
'timebased_availability'];
544 $participant_data_exists = $this->test_object->participantDataExist();
545 $this->test_object->storeActivationSettings(
546 $participant_data_exists
547 ? $this->test_object->isActivationLimited()
548 : $time_based_availability[
'is_activation_limited'],
549 $participant_data_exists
550 ? $this->test_object->getActivationStartingTime()
551 : $time_based_availability[
'activation_starting_time'],
552 $time_based_availability[
'activation_ending_time'],
553 $time_based_availability[
'activation_visibility']
555 $this->test_object->getObjectProperties()->storePropertyIsOnline($section[
'is_online']);
560 $input_factory = $this->
ui->factory()->input();
562 $custom_icon_input = $this->test_object->getObjectProperties()->getPropertyIcon()
565 if ($custom_icon_input !== null) {
566 $inputs[
'custom_icon'] = $custom_icon_input;
568 $inputs[
'tile_image'] = $this->test_object->getObjectProperties()->getPropertyTileImage()
571 return $input_factory->field()->section(
573 $this->
lng->txt(
'tst_presentation_settings_section')
579 if (array_key_exists(
'custom_icon', $section)) {
580 $this->test_object->getObjectProperties()->storePropertyIcon($section[
'custom_icon']);
582 $this->test_object->getObjectProperties()->storePropertyTileImage($section[
'tile_image']);
587 return $this->main_settings->getIntroductionSettings()
589 ->withExamConditionsCheckboxEnabled($section[
'conditions_checkbox_enabled']);
594 $access_settings = $this->main_settings->getAccessSettings()
596 ->withStartTime($section[
'access_window'][
'start_time'])
597 ->withEndTimeEnabled($section[
'access_window'][
'end_time_enabled'])
598 ->withEndTime($section[
'access_window'][
'end_time'])
599 ->withPasswordEnabled($section[
'test_password'][
'password_enabled'])
600 ->withPassword($section[
'test_password'][
'password_value'])
601 ->withFixedParticipants($section[
'fixed_participants_enabled']);
603 if ($this->test_object->participantDataExist()) {
604 return $access_settings;
607 return $access_settings->withStartTimeEnabled($section[
'access_window'][
'start_time_enabled'])
608 ->withStartTime($section[
'access_window'][
'start_time']);
613 $test_behaviour_settings = $this->main_settings->getTestBehaviourSettings()
615 ->withExamIdInTestPassEnabled($section[
'show_exam_id']);
617 if ($this->test_object->participantDataExist()) {
618 return $test_behaviour_settings;
621 return $test_behaviour_settings
622 ->withNumberOfTries($section[
'limit_attempts'][
'number_of_available_attempts'])
623 ->withBlockAfterPassedEnabled($section[
'limit_attempts'][
'block_after_passed'])
624 ->withPassWaiting($section[
'force_waiting_between_attempts'])
625 ->withProcessingTimeEnabled($section[
'time_limit_for_completion'][
'processing_time_limit'])
626 ->withProcessingTime($section[
'time_limit_for_completion'][
'time_limit_for_completion_value'])
627 ->withResetProcessingTime($section[
'time_limit_for_completion'][
'reset_time_limit_for_completion_by_attempt']);
632 $question_behaviour_settings = $this->main_settings->getQuestionBehaviourSettings()
634 ->withAutosaveEnabled($section[
'autosave'][
'autosave_enabled'])
635 ->withAutosaveInterval($section[
'autosave'][
'autosave_interval'])
636 ->withShuffleQuestions($section[
'shuffle_questions']);
638 if ($this->test_object->participantDataExist()) {
639 return $question_behaviour_settings;
642 return $question_behaviour_settings
643 ->withQuestionHintsEnabled($section[
'offer_hints'])
644 ->withInstantFeedbackPointsEnabled($section[
'instant_feedback'][
'enabled_feedback_types'][
'instant_feedback_points'])
645 ->withInstantFeedbackGenericEnabled($section[
'instant_feedback'][
'enabled_feedback_types'][
'instant_feedback_generic'])
646 ->withInstantFeedbackSpecificEnabled($section[
'instant_feedback'][
'enabled_feedback_types'][
'instant_feedback_specific'])
647 ->withInstantFeedbackSolutionEnabled($section[
'instant_feedback'][
'enabled_feedback_types'][
'instant_feedback_solution'])
648 ->withForceInstantFeedbackOnNextQuestion($section[
'instant_feedback'][
'feedback_on_next_question'])
649 ->withLockAnswerOnInstantFeedbackEnabled($section[
'lock_answers'][
'lock_answer_on_instant_feedback'])
650 ->withLockAnswerOnNextQuestionEnabled($section[
'lock_answers'][
'lock_answer_on_next_question'])
651 ->withCompulsoryQuestionsEnabled($section[
'enable_compulsory_questions']);
657 return $this->main_settings->getParticipantFunctionalitySettings()
659 ->withSuspendTestAllowed($section[
'allow_suspend_test'])
660 ->withPostponedQuestionsMoveToEnd($section[
'postponed_questions_behaviour'])
661 ->withUsrPassOverviewMode($section[
'usr_pass_overview'])
662 ->withQuestionMarkingEnabled($section[
'enable_question_marking'])
663 ->withQuestionListEnabled($section[
'enable_question_list']);
668 $redirect_after_finish = $section[
'redirect_after_finish'];
669 $finish_notification = $section[
'finish_notification'];
670 return $this->main_settings->getFinishingSettings()
672 ->withConcludingRemarksEnabled($section[
'show_concluding_remarks'])
673 ->withRedirectionMode($redirect_after_finish[
'redirect_mode'])
674 ->withRedirectionUrl($redirect_after_finish[
'redirect_url'])
675 ->withMailNotificationContentType($finish_notification[
'notification_content_type'])
676 ->withAlwaysSendMailNotification($finish_notification[
'always_notify']);
684 $ecs_section = $ecs->getSettingsSection(
685 $this->
ui->factory()->input()->field(),
689 if ($ecs_section !== null) {
690 $sections[self::ECS_FUNCTIONALITY_SETTINGS_LABEL] = $ecs_section;
695 $inputs += $this->main_settings->getAdditionalSettings()->toForm(
697 $this->
ui->factory()->input()->field(),
705 $sections[self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL] = $this->
ui->factory()->input()->field()
706 ->section(
$inputs, $this->
lng->txt(
'obj_features'));
715 $this->test_object->getType()
717 if (!$position_settings->isActive()) {
721 $enable_organisational_units_access = $this->
ui->factory()->input()->field()
723 $this->
lng->txt(
'obj_orgunit_positions'),
724 $this->
lng->txt(
'obj_orgunit_positions_info')
729 if (!$position_settings->isChangeableForObject()) {
730 return $enable_organisational_units_access->withDisabled(
true);
732 return $enable_organisational_units_access;
737 if (array_key_exists(self::ECS_FUNCTIONALITY_SETTINGS_LABEL, $sections)) {
739 $ecs->saveSettingsSection($sections[self::ECS_FUNCTIONALITY_SETTINGS_LABEL]);
742 if (!array_key_exists(self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL, $sections)) {
746 $additional_settings_section = $sections[self::ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL];
747 if (array_key_exists(
'organisational_units_activation', $additional_settings_section)) {
755 $this->test_object->getType()
758 if ($position_settings->isActive() && $position_settings->isChangeableForObject()) {
763 $orgu_object_settings->update();
769 $additional_settings = $this->main_settings->getAdditionalSettings()->
withHideInfoTab($section[
'hide_info_tab']);
771 if ($this->test_object->participantDataExist()) {
772 return $additional_settings;
776 return $additional_settings->withSkillsServiceEnabled(
false);
779 return $additional_settings->withSkillsServiceEnabled($section[
'skills_service_activation']);
setActive(bool $a_status)
Set active for object.
ilGlobalTemplateInterface $tpl
const QUESTION_BEHAVIOUR_SETTINGS_LABEL
Readable part of repository interface to ilComponentDataDB.
getOrganisationalUnitsActivationInput()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ECS_FUNCTIONALITY_SETTINGS_LABEL
getTestBehaviourSettingsForStorage(array $section)
getAccessSettingsForStorage(array $section)
const CMD_SHOW_RESET_TPL_CONFIRM
ilObjTestMainSettings $main_settings
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withHideInfoTab(bool $hide_info_tab)
saveOrganisationalUnitsActivation(bool $activation)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ServerRequestInterface $request
getParticipantsFunctionalitySettingsForStorage(array $section)
ilObjectDataCache $object_data_cache
static _getAllReferences(int $id)
get all reference ids for object ID
const ADDITIONAL_FUNCTIONALITY_SETTINGS_LABEL
withIntroductionEnabled(bool $introduction_enabled)
A constraint encodes some resrtictions on values.
populateConfirmationModal(string $current_question_set_type, string $new_question_set_type)
withAdditionalOnLoadCode(Closure $binder)
const PARTICIPANTS_FUNCTIONALITY_SETTINGS_LABEL
removeAllParticipantsIfRequired()
executeCommand()
Command Execution.
getIsOnlineSettingInput()
saveAdditionalFunctionalitySettingsSection(array $sections)
showOldConcludingRemarks()
getGeneralSettingsForStorage(array $section)
getAdditionalFunctionalitySettingsForStorage(array $section)
__construct(protected ilObjTest $test_object)
getFinishingSettingsForStorage(array $section)
getTimebasedAvailabilityInputs()
savePresentationSettingsSection(array $section)
Provides fluid interface to RBAC services.
const ACCESS_SETTINGS_LABEL
const FINISH_TEST_SETTINGS_LABEL
saveAvailabilitySettingsSection(array $section)
ilObjTestSettingsMainGUI: ilPropertyFormGUI ilObjTestSettingsMainGUI: ilConfirmationGUI ilObjTestSe...
withQuestionSetType(string $question_set_type)
getAvailabilitySettingsSection()
getGeneralSettingsSection(array $environment)
const SUBTAB_ID_GENERAL_SETTINGS
withUsePreviousAnswerAllowed(bool $use_previous_answers_allowed)
const AVAILABILITY_SETTINGS_SECTION_LABEL
finalizeSave(array $data)
const INTRODUCTION_SETTINGS_SECTION_LABEL
const GENERAL_SETTINGS_SECTION_LABEL
withQuestionTitleOutputMode(int $question_title_output_mode)
const TEST_BEHAVIOUR_SETTINGS_LABEL
withKioskMode(int $kiosk_mode)
const CMD_CONFIRMED_SAVE_FORM
ilTestQuestionSetConfigFactory $testQuestionSetConfigFactory
showForm(StandardForm $form=null, InterruptiveModal $modal=null)
getTransformationForActivationLimitedOptionalGroup()
withShowAnswerOverview(bool $show_answer_overview)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getPresentationSettingsSection()
const QUESTION_SET_TYPE_FIXED
getAdditionalFunctionalitySettingsSections(array $environment)
withStartTimeEnabled(bool $start_time_enabled)
getIntroductionSettingsForStorage(array $section)
getValueForActivationLimitedOptionalGroup()
MainSettingsRepository $main_settings_repository
performSaveForm(array $data)
const PRESENTATION_SETTINGS_SECTION_LABEL
const CMD_SHOW_FORM
command constants
getQuestionBehaviourSettingsForStorage(array $section)
const CMD_CONFIRMED_RESET_TPL