19declare(strict_types=1);
34use Psr\Http\Message\ServerRequestInterface;
42 private readonly UIFactory $ui_factory,
64 return $this->ui_factory->table()->action()->single(
65 $this->
lng->txt(
'personal_settings_apply'),
67 ->withParameter($action_token, self::
ACTION_ID)
75 array $selected_templates
77 $template = $this->checkSelectedTemplate($selected_templates);
78 $question_set_type_changed = $this->hasDifferentQuestionSetType($template->getSettingsId());
80 return $this->ui_factory->modal()->interruptive(
81 $this->
lng->txt(
'confirm'),
82 $this->lng->txt($question_set_type_changed ?
'personal_settings_apply_changed_confirmation' :
'personal_settings_apply_confirmation'),
83 $url_builder->
buildURI()->__toString()
86 $this->ui_factory->modal()->interruptiveItem()->standard(
87 (
string) $template->getId(),
90 sprintf($this->
lng->txt(
'personal_settings_apply_description'), $this->test_obj->getTitle()),
93 )->withActionButtonLabel($this->
lng->txt(
'apply'));
98 ServerRequestInterface $request,
99 array $selected_templates,
101 $template = $this->checkSelectedTemplate($selected_templates);
103 $old_question_set_config = $this->hasDifferentQuestionSetType($template->getSettingsId()) ?
104 $this->question_set_config_factory->getQuestionSetConfig() :
107 $test_settings_id = $this->test_obj->getMainSettings()->getId();
108 $main_settings = $this->main_settings_repository->getById($template->getSettingsId());
109 $score_settings = $this->score_settings_repository->getById($template->getSettingsId());
111 $mark_schema = $this->marks_repository->getMarkSchemaBySteps(
112 $this->
repository->lookupMarkSteps($template->getId())
115 $this->main_settings_repository->store($main_settings->withId($test_settings_id));
116 $this->score_settings_repository->store($score_settings->withId($test_settings_id));
117 $this->marks_repository->storeMarkSchema($mark_schema->withTestId($this->test_obj->getTestId()));
119 if ($old_question_set_config && $old_question_set_config->doesQuestionSetRelatedDataExist()) {
120 $old_question_set_config->removeQuestionSetRelatedData();
123 $this->tpl->setOnScreenMessage(
124 GlobalTemplate::MESSAGE_TYPE_SUCCESS,
125 $this->
lng->txt(
'personal_settings_apply_success'),
133 if (count($selected_templates) !== 1) {
134 throw new \InvalidArgumentException(
'personal_settings_invalid_selection');
138 if ($this->test_obj->evalTotalPersons() > 0) {
139 throw new \InvalidArgumentException(
'personal_settings_apply_not_possible');
142 return reset($selected_templates);
147 $template_main_settings = $this->main_settings_repository->getById($template_settings_id);
148 return $template_main_settings->getGeneralSettings()->getQuestionSetType() !== $this->test_obj->getQuestionSetType();
Builds a Color from either hex- or rgb values.
hasDifferentQuestionSetType(int $template_settings_id)
buildModal(URLBuilder $url_builder, array $selected_templates)
__construct(private readonly Language $lng, private readonly UIFactory $ui_factory, private readonly \ilTestQuestionSetConfigFactory $question_set_config_factory, private readonly GlobalTemplate $tpl, private readonly \ilObjTest $test_obj, private readonly PersonalSettingsRepository $repository, private readonly MainSettingsRepository $main_settings_repository, private readonly ScoreSettingsRepository $score_settings_repository, private readonly MarksRepository $marks_repository,)
onSubmit(URLBuilder $url_builder, ServerRequestInterface $request, array $selected_templates,)
checkSelectedTemplate(array $selected_templates)
buildTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes commonalities between the different modals.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...