ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Test9DBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Test\Setup;
22
24{
25 protected \ilDBInterface $db;
26
27 public function prepare(\ilDBInterface $db): void
28 {
29 $this->db = $db;
30 }
31
32 public function step_1(): void
33 {
34 if ($this->db->tableColumnExists('tst_tests', 'show_examview_pdf')) {
35 $this->db->dropTableColumn('tst_tests', 'show_examview_pdf');
36 }
37 }
38
39 public function step_2(): void
40 {
41 if (!$this->db->tableExists('manscoring_done')) {
42 $this->db->createTable('manscoring_done', [
43 'active_id' => [
44 'type' => 'integer',
45 'length' => 8,
46 'notnull' => true
47 ],
48 'done' => [
49 'type' => 'integer',
50 'length' => 1,
51 'notnull' => true,
52 'default' => 0
53 ]
54 ]);
55 $this->db->addPrimaryKey('manscoring_done', ['active_id']);
56 }
57 }
58
62 public function step_3(): void
63 {
64 if ($this->db->tableColumnExists('tst_tests', 'char_selector_availability')) {
65 $this->db->dropTableColumn('tst_tests', 'char_selector_availability');
66 }
67
68 if ($this->db->tableColumnExists('tst_tests', 'char_selector_definition')) {
69 $this->db->dropTableColumn('tst_tests', 'char_selector_definition');
70 }
71 }
72
73 public function step_4(): void
74 {
75 if (!$this->db->tableColumnExists('tst_tests', 'introduction_page_id')) {
76 $this->db->addTableColumn(
77 'tst_tests',
78 'introduction_page_id',
79 [
80 'type' => 'integer',
81 'length' => 8
82 ]
83 );
84 }
85 if (!$this->db->tableColumnExists('tst_tests', 'concluding_remarks_page_id')) {
86 $this->db->addTableColumn(
87 'tst_tests',
88 'concluding_remarks_page_id',
89 [
90 'type' => 'integer',
91 'length' => 8
92 ]
93 );
94 }
95 }
96
97 public function step_5(): void
98 {
99 if ($this->db->tableColumnExists('tst_tests', 'show_examview_html')) {
100 $this->db->dropTableColumn(
101 'tst_tests',
102 'show_examview_html'
103 );
104 }
105 if ($this->db->tableColumnExists('tst_tests', 'showinfo')) {
106 $this->db->dropTableColumn(
107 'tst_tests',
108 'showinfo'
109 );
110 }
111 if ($this->db->tableColumnExists('tst_tests', 'forcejs')) {
112 $this->db->dropTableColumn(
113 'tst_tests',
114 'forcejs'
115 );
116 }
117 if ($this->db->tableColumnExists('tst_tests', 'enable_archiving')) {
118 $this->db->dropTableColumn(
119 'tst_tests',
120 'enable_archiving'
121 );
122 }
123 if ($this->db->tableColumnExists('tst_tests', 'customstyle')) {
124 $this->db->dropTableColumn(
125 'tst_tests',
126 'customstyle'
127 );
128 }
129 if ($this->db->tableColumnExists('tst_tests', 'enabled_view_mode')) {
130 $this->db->dropTableColumn(
131 'tst_tests',
132 'enabled_view_mode'
133 );
134 }
135 }
136
137 public function step_6(): void
138 {
139 if ($this->db->tableColumnExists('tst_tests', 'allowedusers')) {
140 $this->db->dropTableColumn('tst_tests', 'allowedusers');
141 }
142
143 if ($this->db->tableColumnExists('tst_tests', 'alloweduserstimegap')) {
144 $this->db->dropTableColumn('tst_tests', 'alloweduserstimegap');
145 }
146
147 if ($this->db->tableColumnExists('tst_tests', 'limit_users_enabled')) {
148 $this->db->dropTableColumn('tst_tests', 'limit_users_enabled');
149 }
150 }
151
152 public function step_7(): void
153 {
154 if ($this->db->tableExists('tst_dyn_quest_set_cfg')) {
155 $this->db->dropTable('tst_dyn_quest_set_cfg');
156 }
157 if ($this->db->tableExists('tst_seq_qst_tracking')) {
158 $this->db->dropTable('tst_seq_qst_tracking');
159 }
160 if ($this->db->tableExists('tst_seq_qst_answstatus')) {
161 $this->db->dropTable('tst_seq_qst_answstatus');
162 }
163 if ($this->db->tableExists('tst_seq_qst_postponed')) {
164 $this->db->dropTable('tst_seq_qst_postponed');
165 }
166 }
167
168 public function step_8(): void
169 {
170 if ($this->db->tableColumnExists('tst_tests', 'redirection_url')) {
171 $this->db->modifyTableColumn(
172 'tst_tests',
173 'redirection_url',
174 [
175 'type' => 'text',
176 'length' => 4000,
177 'notnull' => false,
178 'default' => null
179 ]
180 );
181 }
182 }
183
184 public function step_9(): void
185 {
186 if (!$this->db->tableColumnExists('tst_tests', 'show_questionlist')) {
187 $this->db->addTableColumn(
188 'tst_tests',
189 'show_questionlist',
190 [
191 'type' => 'integer',
192 'length' => 1
193 ]
194 );
195 }
196 }
197
198 public function step_10(): void
199 {
200 if ($this->db->tableColumnExists('tst_tests', 'sign_submission')) {
201 $this->db->dropTableColumn(
202 'tst_tests',
203 'sign_submission'
204 );
205 }
206 }
207
208 public function step_11(): void
209 {
210 if ($this->db->tableColumnExists('tst_tests', 'show_summary')) {
211 $this->db->renameTableColumn(
212 'tst_tests',
213 'show_summary',
214 'usr_pass_overview_mode'
215 );
216 }
217 }
218
219 public function step_12(): void
220 {
221 if (!$this->db->tableColumnExists('tst_tests', 'show_questionlist')) {
222 $this->db->addTableColumn(
223 'tst_tests',
224 'show_questionlist',
225 [
226 'type' => 'integer',
227 'length' => 1
228 ]
229 );
230 }
231 }
232
233 public function step_13(): void
234 {
235 if (!$this->db->tableColumnExists('tst_tests', 'hide_info_tab')) {
236 $this->db->addTableColumn('tst_tests', 'hide_info_tab', [
237 'type' => 'integer',
238 'length' => 1,
239 'default' => 0,
240 'notnull' => true
241 ]);
242 }
243
244 if (!$this->db->tableColumnExists('tst_tests', 'conditions_checkbox_enabled')) {
245 $this->db->addTableColumn('tst_tests', 'conditions_checkbox_enabled', [
246 'type' => 'integer',
247 'length' => 1,
248 'default' => 0,
249 'notnull' => true
250 ]);
251 }
252 }
253
254 public function step_14(): void
255 {
256 if ($this->db->tableColumnExists('tst_tests', 'hide_info_tab')) {
257 $this->db->modifyTableColumn('tst_tests', 'hide_info_tab', [
258 'type' => 'integer',
259 'length' => 1,
260 'default' => 0,
261 'notnull' => true
262 ]);
263 }
264
265 if ($this->db->tableColumnExists('tst_tests', 'conditions_checkbox_enabled')) {
266 $this->db->modifyTableColumn('tst_tests', 'conditions_checkbox_enabled', [
267 'type' => 'integer',
268 'length' => 1,
269 'default' => 0,
270 'notnull' => true
271 ]);
272 }
273 }
274
275 public function step_15(): void
276 {
277 if ($this->db->tableColumnExists('tst_tests', 'result_tax_filters')) {
278 $this->db->dropTableColumn('tst_tests', 'result_tax_filters');
279 }
280 }
281
282 public function step_16(): void
283 {
284 if ($this->db->tableColumnExists('tst_tests', 'show_cancel')) {
285 $this->db->modifyTableColumn(
286 'tst_tests',
287 'show_cancel',
288 [
289 'type' => 'text',
290 'length' => 1,
291 'default' => '0'
292 ]
293 );
294 }
295 }
296
297 public function step_17(): void
298 {
299 if ($this->db->tableColumnExists('tst_tests', 'use_previous_answers')) {
300 $this->db->modifyTableColumn(
301 'tst_tests',
302 'use_previous_answers',
303 [
304 'type' => 'text',
305 'length' => 1,
306 'default' => '0'
307 ]
308 );
309 }
310 }
311
312
313 public function step_18(): void
314 {
315 if ($this->db->tableColumnExists('tst_tests', 'show_cancel')) {
316 $this->db->renameTableColumn(
317 'tst_tests',
318 'show_cancel',
319 'suspend_test_allowed'
320 );
321 }
322 }
323
324 public function step_19(): void
325 {
326 if (!$this->db->tableExists('tst_qst_var_presented')) {
327 $this->db->createTable('tst_qst_var_presented', [
328 'question_id' => [
329 'type' => 'integer',
330 'length' => 8,
331 'notnull' => true
332 ],
333 'active_id' => [
334 'type' => 'integer',
335 'length' => 8,
336 'notnull' => true
337 ],
338 'pass' => [
339 'type' => 'integer',
340 'length' => 8,
341 'notnull' => true
342 ],
343 'variable' => [
344 'type' => 'text',
345 'length' => 32,
346 'notnull' => true
347 ],
348 'value' => [
349 'type' => 'text',
350 'length' => 64,
351 'notnull' => true
352 ]
353 ]);
354 $this->db->addPrimaryKey(
355 'tst_qst_var_presented',
356 ['question_id','active_id','pass','variable']
357 );
358 }
359 }
360
361 public function step_20(): void
362 {
363 $this->db->manipulate('UPDATE tst_pass_result SET points = 0 WHERE points < 0');
364 $this->db->manipulate('UPDATE tst_result_cache SET reached_points = 0 WHERE reached_points < 0');
365 }
366
367 public function step_22(): void
368 {
369 $this->db->modifyTableColumn(
370 'tst_tests',
371 'starting_time',
372 [
373 'length' => 8
374 ]
375 );
376 $this->db->modifyTableColumn(
377 'tst_tests',
378 'ending_time',
379 [
380 'length' => 8
381 ]
382 );
383 }
384}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
step_3()
Drop the test settings for the special character seletor.
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...