ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Test\Settings\Templates\PersonalSettingsCreateAction Class Reference
+ Collaboration diagram for ILIAS\Test\Settings\Templates\PersonalSettingsCreateAction:

Public Member Functions

 __construct (private readonly UIFactory $ui_factory, private readonly Language $lng, private readonly \ilObjUser $user, private readonly PersonalSettingsRepository $repository, private readonly MainSettingsRepository $main_settings_repository, private readonly ScoreSettingsRepository $score_settings_repository, private readonly MarksRepository $marks_repository,)
 
 buildModal (string $url)
 
 perform (int $test_id, ServerRequestInterface $request)
 

Detailed Description

Definition at line 31 of file PersonalSettingsCreateAction.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Settings\Templates\PersonalSettingsCreateAction::__construct ( private readonly UIFactory  $ui_factory,
private readonly Language  $lng,
private readonly \ilObjUser  $user,
private readonly PersonalSettingsRepository  $repository,
private readonly MainSettingsRepository  $main_settings_repository,
private readonly ScoreSettingsRepository  $score_settings_repository,
private readonly MarksRepository  $marks_repository 
)

Definition at line 33 of file PersonalSettingsCreateAction.php.

41 {
42 }

Member Function Documentation

◆ buildModal()

ILIAS\Test\Settings\Templates\PersonalSettingsCreateAction::buildModal ( string  $url)

Definition at line 44 of file PersonalSettingsCreateAction.php.

44 : RoundTrip
45 {
46 $input_factory = $this->ui_factory->input();
47
48 $inputs = [
49 'name' => $input_factory->field()->text($this->lng->txt('title'))
50 ->withLabel($this->lng->txt('title'))
51 ->withRequired(true),
52 'author' => $input_factory->field()->text($this->lng->txt('author'))
53 ->withRequired(true)
54 ->withValue($this->user->getFullname()),
55 'description' => $input_factory->field()->textarea($this->lng->txt('description')),
56 ];
57
58 $explanation = $this->ui_factory->messageBox()->info(
59 $this->lng->txt('personal_settings_explanation')
60 );
61
62 return $this->ui_factory->modal()->roundtrip(
63 $this->lng->txt('personal_settings_create'),
64 [$explanation],
65 $inputs,
66 $url
67 )->withSubmitLabel($this->lng->txt('personal_settings_save'));
68 }
$url
Definition: shib_logout.php:68

References ILIAS\UI\Implementation\Component\Input\$inputs, $url, ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by ILIAS\Test\Settings\Templates\PersonalSettingsCreateAction\perform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ perform()

ILIAS\Test\Settings\Templates\PersonalSettingsCreateAction::perform ( int  $test_id,
ServerRequestInterface  $request 
)

Definition at line 70 of file PersonalSettingsCreateAction.php.

70 : void
71 {
72 $container = $this->buildModal('')->withRequest($request);
73 $data = $container->getData();
74
75 // 1. Resolve error messages on validation failure
76 if ($data === null) {
77 $inputs = $container->getInputs();
78
79 if ($inputs['name']->getValue() === '') {
80 throw new \InvalidArgumentException('personal_settings_required_title');
81 }
82
83 if ($inputs['author']->getValue() === '') {
84 throw new \InvalidArgumentException('personal_settings_required_author');
85 }
86 }
87
88 // 2. Create a new template
89 $template = $this->repository->create(
90 $data['name'],
91 $data['description'] ?? '',
92 $data['author']
93 );
94
95 // 3. Clone settings from test for the new template
96 $this->main_settings_repository->store(
97 $this->main_settings_repository->getFor($test_id)->withId($template->getSettingsId())
98 );
99 $this->score_settings_repository->store(
100 $this->score_settings_repository->getFor($test_id)->withId($template->getSettingsId())
101 );
102
103 // 4. Clone the mark schema of the test and create references for the template
104 $mark_schema = $this->marks_repository->getMarkSchemaFor($test_id);
105 $mark_ids = $this->marks_repository->storeMarkSchema($mark_schema->withTestId(-1));
106 $this->repository->associateMarkSteps($template->getId(), $mark_ids);
107 }
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49
$container
@noRector
Definition: wac.php:37

References $container, $data, ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\Test\Settings\Templates\PersonalSettingsCreateAction\buildModal(), ILIAS\UI\Implementation\Component\Input\getValue(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

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