ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestSettingsChangeConfirmationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30{
31 private ?string $oldQuestionSetType;
32 private ?string $newQuestionSetType;
34
35 public function __construct(
36 private readonly RequestDataCollector $request_data_collector,
37 protected readonly ilObjTest $testOBJ
38 ) {
40 }
41
42 public function setOldQuestionSetType(string $oldQuestionSetType): void
43 {
44 $this->oldQuestionSetType = $oldQuestionSetType;
45 }
46
47 public function getOldQuestionSetType(): ?string
48 {
50 }
51
52 public function setNewQuestionSetType(string $newQuestionSetType): void
53 {
54 $this->newQuestionSetType = $newQuestionSetType;
55 }
56
57 public function getNewQuestionSetType(): string
58 {
60 }
61
66 {
67 $this->questionLossInfoEnabled = $questionLossInfoEnabled;
68 }
69
70 public function isQuestionLossInfoEnabled(): bool
71 {
73 }
74
75 private function buildHeaderText(): string
76 {
77 $headerText = sprintf(
78 $this->lng->txt('tst_change_quest_set_type_from_old_to_new_with_conflict'),
79 $this->testOBJ->getQuestionSetTypeTranslation($this->lng, $this->getOldQuestionSetType()),
80 $this->testOBJ->getQuestionSetTypeTranslation($this->lng, $this->getNewQuestionSetType())
81 );
82
83 if ($this->isQuestionLossInfoEnabled()) {
84 $headerText .= '<br /><br />' . $this->lng->txt('tst_nonpool_questions_get_lost_warning');
85 }
86
87 return $headerText;
88 }
89
90 public function build(): void
91 {
92 $this->setHeaderText($this->buildHeaderText());
93 }
94
95 public function populateParametersFromPost(): void
96 {
97 foreach ($this->request_data_collector->getPostKeys() as $key) {
98 if ($key !== 'cmd') {
99 $value = $this->request_data_collector->raw($key);
100
101 if (is_array($value)) {
102 foreach ($value as $k => $v) {
103 $this->addHiddenItem("{$key}[{$k}]", $v);
104 }
105 } elseif (is_string($value)) {
106 $this->addHiddenItem($key, $value);
107 }
108 }
109 }
110 }
111
112 public function populateParametersFromPropertyForm(ilPropertyFormGUI $form, $timezone): void
113 {
114 foreach ($form->getInputItemsRecursive() as $key => $item) {
115 switch ($item->getType()) {
116 case 'section_header':
117
118 continue 2;
119
120 case 'datetime':
121
122 $datetime = $item->getDate();
123 if ($datetime instanceof ilDateTime && !$datetime->isNull()) {
124 $parts = explode(' ', $datetime->get(IL_CAL_DATETIME));
125 if ($datetime instanceof ilDate) {
126 $this->addHiddenItem($item->getPostVar(), $parts[0]);
127 } else {
128 $this->addHiddenItem($item->getPostVar(), $parts[0] . ' ' . $parts[1]);
129 }
130 } else {
131 $this->addHiddenItem($item->getPostVar(), '');
132 }
133
134 break;
135
136 case 'duration':
137
138 $this->addHiddenItem("{$item->getPostVar()}[MM]", (string) $item->getMonths());
139 $this->addHiddenItem("{$item->getPostVar()}[dd]", (string) $item->getDays());
140 $this->addHiddenItem("{$item->getPostVar()}[hh]", (string) $item->getHours());
141 $this->addHiddenItem("{$item->getPostVar()}[mm]", (string) $item->getMinutes());
142 $this->addHiddenItem("{$item->getPostVar()}[ss]", (string) $item->getSeconds());
143
144 break;
145
146 case 'dateduration':
147
148 foreach (["start", "end"] as $type) {
149 $postVar = $item->getPostVar() . '[' . $type . ']';
150 $datetime = $item->{'get' . ucfirst($type)}();
151
152 if ($datetime instanceof ilDateTime && !$datetime->isNull()) {
153 $parts = explode(' ', $datetime->get(IL_CAL_DATETIME));
154 if ($datetime instanceof ilDate) {
155 $this->addHiddenItem($postVar, $parts[0]);
156 } else {
157 $this->addHiddenItem($postVar, $parts[0] . ' ' . $parts[1]);
158 }
159 } else {
160 $this->addHiddenItem($postVar, '');
161 }
162 }
163
164 break;
165
166 case 'checkboxgroup':
167
168 if (is_array($item->getValue())) {
169 foreach ($item->getValue() as $option) {
170 $this->addHiddenItem("{$item->getPostVar()}[]", $option);
171 }
172 }
173
174 break;
175
176 case 'select':
177
178 $value = $item->getValue();
179 if (!is_array($value)) {
180 $value = [$value];
181 }
182 foreach ($value as $option) {
183 $this->addHiddenItem("{$item->getPostVar()}[]", $option);
184 }
185
186 break;
187
188 case 'checkbox':
189
190 if ($item->getChecked()) {
191 $this->addHiddenItem($item->getPostVar(), '1');
192 }
193
194 break;
195
196 default:
197
198 $this->addHiddenItem($item->getPostVar(), (string) $item->getValue());
199 }
200 }
201 }
202}
$datetime
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setHeaderText(string $a_headertext)
addHiddenItem(string $a_post_var, string $a_value)
@classDescription Date and time handling
Class for single dates.
This class represents a property form user interface.
getInputItemsRecursive()
returns a flat array of all input items including the possibly existing subitems recursively
populateParametersFromPropertyForm(ilPropertyFormGUI $form, $timezone)
__construct(private readonly RequestDataCollector $request_data_collector, protected readonly ilObjTest $testOBJ)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc