ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilExerciseDBUpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 {
28  protected \ilDBInterface $db;
29 
30  public function prepare(\ilDBInterface $db): void
31  {
32  $this->db = $db;
33  }
34 
35  public function step_1(): void
36  {
37  if (!$this->db->indexExistsByFields('exc_assignment', ['exc_id'])) {
38  $this->db->addIndex('exc_assignment', ['exc_id'], 'i1');
39  }
40  }
41 
42  public function step_2(): void
43  {
44  if (!$this->db->indexExistsByFields('exc_members', ['usr_id'])) {
45  $this->db->addIndex('exc_members', ['usr_id'], 'i1');
46  }
47  }
48 
49  public function step_3(): void
50  {
51  if (!$this->db->indexExistsByFields('exc_assignment', ['deadline_mode', 'exc_id'])) {
52  $this->db->addIndex('exc_assignment', ['deadline_mode', 'exc_id'], 'i2');
53  }
54  }
55 
56  public function step_4(): void
57  {
58  if (!$this->db->indexExistsByFields('exc_ass_file_order', ['assignment_id'])) {
59  $this->db->addIndex('exc_ass_file_order', ['assignment_id'], 'i1');
60  }
61  }
62 
63  public function step_5(): void
64  {
65  if (!$this->db->indexExistsByFields('il_exc_team', ['id'])) {
66  $this->db->addIndex('il_exc_team', ['id'], 'i1');
67  }
68  }
69 
70  public function step_6(): void
71  {
72  if (!$this->db->tableColumnExists('exc_assignment', 'if_rcid')) {
73  $this->db->addTableColumn(
74  'exc_assignment',
75  'if_rcid',
76  [
77  'type' => 'text',
78  'notnull' => false,
79  'length' => 64,
80  'default' => ''
81  ]
82  );
83  }
84  }
85 
86  public function step_7(): void
87  {
88  if (!$this->db->tableColumnExists('exc_assignment_peer', 'id')) {
89  $this->db->addTableColumn('exc_assignment_peer', 'id', array(
90  'type' => 'integer',
91  'notnull' => true,
92  'length' => 4,
93  'default' => 0
94  ));
95  $this->db->createSequence('exc_assignment_peer');
96  }
97  }
98 
99  public function step_8(): void
100  {
101  $set = $this->db->queryF(
102  "SELECT * FROM exc_assignment_peer ",
103  [],
104  []
105  );
106  while ($rec = $this->db->fetchAssoc($set)) {
107  $next_id = $this->db->nextId("exc_assignment_peer");
108  $this->db->update(
109  "exc_assignment_peer",
110  [
111  "id" => ["integer", $next_id]
112  ],
113  [ // where
114  "ass_id" => ["integer", $rec["ass_id"]],
115  "giver_id" => ["integer", $rec["giver_id"]],
116  "peer_id" => ["integer", $rec["peer_id"]]
117  ]
118  );
119  }
120  }
121 
122  public function step_9(): void
123  {
124  $this->db->dropPrimaryKey("exc_assignment_peer");
125  $this->db->addPrimaryKey("exc_assignment_peer", ["id"]);
126  }
127 
128  public function step_10(): void
129  {
130  $this->db->addUniqueConstraint("exc_assignment_peer", array('ass_id', 'giver_id', 'peer_id'), 'c1');
131  }
132 
133  public function step_11(): void
134  {
135  $this->db->addIndex("exc_assignment_peer", ["ass_id"], "i1");
136  }
137 
138  public function step_12(): void
139  {
140  if (!$this->db->tableColumnExists('exc_idl', 'requested')) {
141  $this->db->addTableColumn('exc_idl', 'requested', array(
142  'type' => 'integer',
143  'notnull' => true,
144  'length' => 1,
145  'default' => 0
146  ));
147  }
148  }
149 
150  public function step_13(): void
151  {
152  if (!$this->db->tableColumnExists('exc_assignment', 'solution_rid')) {
153  $this->db->addTableColumn(
154  'exc_assignment',
155  'solution_rid',
156  [
157  'type' => 'text',
158  'notnull' => false,
159  'length' => 64,
160  'default' => ''
161  ]
162  );
163  }
164  }
165 
166  public function step_14(): void
167  {
168  if (!$this->db->tableColumnExists('exc_mem_ass_status', 'feedback_rcid')) {
169  $this->db->addTableColumn(
170  'exc_mem_ass_status',
171  'feedback_rcid',
172  [
173  'type' => 'text',
174  'notnull' => false,
175  'length' => 64,
176  'default' => ''
177  ]
178  );
179  }
180  }
181 
182  public function step_15(): void
183  {
184  if (!$this->db->tableExists('exc_team_data')) {
185  $this->db->createTable(
186  'exc_team_data',
187  [
188  "id" => [
189  'type' => 'integer',
190  'notnull' => true,
191  'length' => 4
192  ],
193  "feedback_rcid" => [
194  'type' => 'text',
195  'notnull' => false,
196  'length' => 64,
197  'default' => ''
198  ]
199  ]
200  );
201  }
202  $this->db->addPrimaryKey('exc_team_data', ["id"]);
203  }
204 
205  public function step_16(): void
206  {
207  $set = $this->db->queryF(
208  "SELECT DISTINCT il_exc_team.id FROM il_exc_team LEFT JOIN exc_team_data ON il_exc_team.id = exc_team_data.id WHERE exc_team_data.id IS NULL",
209  [],
210  []
211  );
212  while ($rec = $this->db->fetchAssoc($set)) {
213  $this->db->insert("exc_team_data", [
214  "id" => ["integer", (int) $rec["id"]],
215  ]);
216  }
217  }
218 
219  public function step_17(): void
220  {
221  if (!$this->db->tableExists('exc_multi_feedback')) {
222  $this->db->createTable(
223  'exc_multi_feedback',
224  [
225  "tutor_id" => [
226  'type' => 'integer',
227  'notnull' => true,
228  'length' => 4
229  ],
230  "ass_id" => [
231  'type' => 'integer',
232  'notnull' => true,
233  'length' => 4
234  ],
235  "zip_rid" => [
236  'type' => 'text',
237  'notnull' => false,
238  'length' => 64,
239  'default' => ''
240  ]
241  ]
242  );
243  }
244  $this->db->addPrimaryKey('exc_multi_feedback', ["tutor_id", "ass_id"]);
245  }
246 
247 }
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...