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