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