19declare(strict_types=1);
34use Psr\Http\Message\ServerRequestInterface;
42 private readonly UIFactory $ui_factory,
65 return $this->ui_factory->table()->action()->single(
66 $this->
lng->txt(
'personal_settings_apply'),
68 ->withParameter($action_token, self::
ACTION_ID)
76 array $selected_templates
78 $template = $this->checkSelectedTemplate($selected_templates);
79 $question_set_type_changed = $this->hasDifferentQuestionSetType($template->getSettingsId());
81 return $this->ui_factory->modal()->interruptive(
82 $this->
lng->txt(
'confirm'),
83 $this->lng->txt($question_set_type_changed ?
'personal_settings_apply_changed_confirmation' :
'personal_settings_apply_confirmation'),
84 $url_builder->
buildURI()->__toString()
87 $this->ui_factory->modal()->interruptiveItem()->standard(
88 (
string) $template->getId(),
91 sprintf($this->
lng->txt(
'personal_settings_apply_description'), $this->test_obj->getTitle()),
94 )->withActionButtonLabel($this->
lng->txt(
'apply'));
99 ServerRequestInterface $request,
100 array $selected_templates,
102 $template = $this->checkSelectedTemplate($selected_templates);
104 $old_question_set_config = $this->hasDifferentQuestionSetType($template->getSettingsId()) ?
105 $this->question_set_config_factory->getQuestionSetConfig() :
108 $test_settings_id = $this->test_obj->getMainSettings()->getId();
109 $main_settings = $this->main_settings_repository->getById($template->getSettingsId());
110 $score_settings = $this->score_settings_repository->getById($template->getSettingsId());
112 $mark_schema = $this->marks_repository->getMarkSchemaBySteps(
113 $this->
repository->lookupMarkSteps($template->getId())
116 $this->main_settings_repository->store($main_settings->withId($test_settings_id));
117 $this->score_settings_repository->store($score_settings->withId($test_settings_id));
118 $this->marks_repository->storeMarkSchema($mark_schema->withTestId($this->test_obj->getTestId()));
120 if ($old_question_set_config && $old_question_set_config->doesQuestionSetRelatedDataExist()) {
121 $old_question_set_config->removeQuestionSetRelatedData();
124 $this->tpl->setOnScreenMessage(
125 GlobalTemplate::MESSAGE_TYPE_SUCCESS,
126 $this->
lng->txt(
'personal_settings_apply_success'),
134 if (count($selected_templates) !== 1) {
135 throw new \InvalidArgumentException(
'personal_settings_invalid_selection');
139 if ($this->test_obj->evalTotalPersons() > 0) {
140 throw new \InvalidArgumentException(
'personal_settings_apply_not_possible');
143 return reset($selected_templates);
148 $template_main_settings = $this->main_settings_repository->getById($template_settings_id);
149 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...