ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExerciseDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19declare(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 public function step_18(): void
248 {
249 if (!$this->db->tableColumnExists('exc_returned', 'rid')) {
250 $this->db->addTableColumn(
251 'exc_returned',
252 'rid',
253 [
254 'type' => 'text',
255 'notnull' => false,
256 'length' => 64,
257 'default' => ''
258 ]
259 );
260 }
261 }
262
263 public function step_19(): void
264 {
265 if (!$this->db->tableExists('exc_crit_file')) {
266 $this->db->createTable(
267 'exc_crit_file',
268 [
269 "ass_id" => [
270 'type' => 'integer',
271 'notnull' => true,
272 'length' => 4,
273 'default' => 0
274 ],
275 "giver_id" => [
276 'type' => 'integer',
277 'notnull' => true,
278 'length' => 4,
279 'default' => 0
280 ],
281 "peer_id" => [
282 'type' => 'integer',
283 'notnull' => true,
284 'length' => 4,
285 'default' => 0
286 ],
287 "criteria_id" => [
288 'type' => 'integer',
289 'notnull' => true,
290 'length' => 4,
291 'default' => 0
292 ],
293 "rid" => [
294 'type' => 'text',
295 'notnull' => true,
296 'length' => 64,
297 'default' => ""
298 ],
299 ]
300 );
301 $this->db->addPrimaryKey('exc_crit_file', ['ass_id', 'giver_id','peer_id','criteria_id']);
302 }
303 }
304
305 public function step_20(): void
306 {
307 $this->db->manipulate("UPDATE exc_returned SET rid = NULL WHERE rid = " . $this->db->quote("", "text"));
308 }
309
310 public function step_21(): void
311 {
312 if (!$this->db->tableColumnExists('exc_assignment_peer', 'migrated')) {
313 $this->db->addTableColumn(
314 'exc_assignment_peer',
315 'migrated',
316 [
317 'type' => 'integer',
318 'notnull' => true,
319 'length' => 1,
320 'default' => 0
321 ]
322 );
323 }
324 }
325
326}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...