ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilTestQuestionPool9DBUpdateSteps.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('qpl_questionpool', 'nav_taxonomy')) {
33  $this->db->dropTableColumn('qpl_questionpool', 'nav_taxonomy');
34  }
35  }
36 
37  public function step_2(): void
38  {
39  if ($this->db->tableColumnExists('qpl_questions', 'working_time')) {
40  $this->db->dropTableColumn('qpl_questions', 'working_time');
41  }
42  }
43 
44  public function step_3(): void
45  {
46  if ($this->db->tableExists('qpl_sol_sug')) {
47  $this->db->manipulateF("DELETE FROM qpl_sol_sug WHERE type = %s", ['text'], ['text']);
48  }
49  }
50 
51  public function step_4(): void
52  {
53  $query = '
54  UPDATE object_data
55  INNER JOIN qpl_questionpool ON object_data.obj_id = qpl_questionpool.obj_fi
56  SET object_data.offline = IF(qpl_questionpool.isonline = 1, 0, 1)
57  WHERE object_data.type = %s
58  ';
59 
60  $this->db->manipulateF(
61  $query,
63  ['qpl']
64  );
65 
66  if ($this->db->tableColumnExists('qpl_questionpool', 'isonline')) {
67  $this->db->dropTableColumn('qpl_questionpool', 'isonline');
68  }
69  }
70 
71  public function step_5(): void
72  {
73  $this->db->modifyTableColumn(
74  'qpl_questions',
75  'author',
76  ['type' => 'text', 'length' => 512]
77  );
78  }
79 
80  public function step_6(): void
81  {
82  $this->db->modifyTableColumn(
83  'qpl_questions',
84  'title',
85  ['type' => 'text', 'length' => 124]
86  );
87  }
88 
89  public function step_7(): void
90  {
91  $table = 'tst_rnd_quest_set_qpls';
92  $table_column = 'pool_title';
93  if ($this->db->tableColumnExists($table, $table_column)) {
94  $this->db->modifyTableColumn(
95  $table,
96  $table_column,
97  ['type' => ilDBConstants::T_TEXT, 'length' => 255],
98  );
99  }
100  }
101 }