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