@@ -45,6 +45,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
45
45
if (!$ dbman ->field_exists ($ table , $ field2 )) {
46
46
$ dbman ->add_field ($ table , $ field2 );
47
47
}
48
+ upgrade_mod_savepoint (true , 2014012401 , 'turnitintooltwo ' );
48
49
}
49
50
50
51
if ($ oldversion < 2014012404 ) {
@@ -54,6 +55,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
54
55
if (!$ dbman ->field_exists ($ table , $ field )) {
55
56
$ dbman ->add_field ($ table , $ field );
56
57
}
58
+ upgrade_mod_savepoint (true , 2014012404 , 'turnitintooltwo ' );
57
59
}
58
60
59
61
if ($ oldversion < 2014012405 ) {
@@ -89,6 +91,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
89
91
if (!$ dbman ->index_exists ($ table , $ index )) {
90
92
$ dbman ->add_index ($ table , $ index );
91
93
}
94
+ upgrade_mod_savepoint (true , 2014012405 , 'turnitintooltwo ' );
92
95
}
93
96
94
97
if ($ oldversion < 2014012412 ) {
@@ -97,6 +100,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
97
100
if (!$ dbman ->field_exists ($ table , $ field )) {
98
101
$ dbman ->add_field ($ table , $ field );
99
102
}
103
+ upgrade_mod_savepoint (true , 2014012412 , 'turnitintooltwo ' );
100
104
}
101
105
102
106
if ($ oldversion < 2015040101 ) {
@@ -115,6 +119,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
115
119
if (!$ dbman ->index_exists ($ table , $ index )) {
116
120
$ dbman ->add_index ($ table , $ index );
117
121
}
122
+ upgrade_mod_savepoint (true , 2015040101 , 'turnitintooltwo ' );
118
123
}
119
124
120
125
if ($ oldversion < 2015040104 ) {
@@ -128,6 +133,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
128
133
} else {
129
134
$ dbman ->change_field_unsigned ($ table , $ field );
130
135
}
136
+ upgrade_mod_savepoint (true , 2015040104 , 'turnitintooltwo ' );
131
137
}
132
138
133
139
if ($ oldversion < 2015040107 ) {
@@ -138,18 +144,21 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
138
144
if (!$ dbman ->field_exists ($ table , $ field )) {
139
145
$ dbman ->add_field ($ table , $ field );
140
146
}
147
+ upgrade_mod_savepoint (true , 2015040107 , 'turnitintooltwo ' );
141
148
}
142
149
143
150
if ($ oldversion < 2015040109 ) {
144
151
// Update URL for UK accounts.
145
152
$ apiurl = get_config ('turnitintooltwo ' , 'apiurl ' );
146
153
$ newurl = str_replace ('submit.ac.uk ' , 'api.turnitinuk.com ' , strtolower ($ apiurl ));
147
154
set_config ('apiurl ' , $ newurl , 'turnitintooltwo ' );
155
+ upgrade_mod_savepoint (true , 2015040109 , 'turnitintooltwo ' );
148
156
}
149
157
150
158
if ($ oldversion < 2015040111 ) {
151
159
// Update gradedisplay value to be consistent with V1 plugin.
152
160
$ DB ->set_field ("turnitintooltwo " , "gradedisplay " , 2 );
161
+ upgrade_mod_savepoint (true , 2015040111 , 'turnitintooltwo ' );
153
162
}
154
163
155
164
if ($ oldversion < 2016011101 ) {
@@ -165,6 +174,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
165
174
if (!$ dbman ->field_exists ($ table , $ field )) {
166
175
$ dbman ->add_field ($ table , $ field );
167
176
}
177
+ upgrade_mod_savepoint (true , 2016011101 , 'turnitintooltwo ' );
168
178
}
169
179
170
180
if ($ oldversion < 2016011107 ) {
@@ -175,6 +185,7 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
175
185
if (!$ dbman ->field_exists ($ table , $ field )) {
176
186
$ dbman ->add_field ($ table , $ field );
177
187
}
188
+ upgrade_mod_savepoint (true , 2016011107 , 'turnitintooltwo ' );
178
189
}
179
190
180
191
if ($ oldversion < 2017011301 ) {
@@ -236,6 +247,8 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
236
247
// Add hash as key after update.
237
248
$ key = new xmldb_key ('submission_hash ' , XMLDB_KEY_UNIQUE , array ('submission_hash ' ));
238
249
$ dbman ->add_key ($ table , $ key );
250
+
251
+ upgrade_mod_savepoint (true , 2017011301 , 'turnitintooltwo ' );
239
252
}
240
253
241
254
if ($ oldversion < 2017103001 ) {
@@ -251,7 +264,45 @@ function xmldb_turnitintooltwo_upgrade($oldversion) {
251
264
if (!$ dbman ->field_exists ($ table , $ field )) {
252
265
$ dbman ->add_field ($ table , $ field );
253
266
}
267
+ upgrade_mod_savepoint (true , 2017103001 , 'turnitintooltwo ' );
268
+ }
269
+
270
+ // This block is to solve a number of inconsistencies between the install and upgrade scripts
271
+ if ($ oldversion < 2020081401 ) {
272
+ $ table = new xmldb_table ('turnitintooltwo ' );
273
+ // Ensure default for institution check is 0.
274
+ $ field = new xmldb_field ('institution_check ' , XMLDB_TYPE_INTEGER , '1 ' , false , false , null , 0 , 'journalcheck ' );
275
+ if ($ dbman ->field_exists ($ table , $ field )) {
276
+ $ dbman ->change_field_default ($ table , $ field );
277
+ }
278
+
279
+ // Ensure needs_updating allows null and int length is 1.
280
+ $ field = new xmldb_field ('needs_updating ' , XMLDB_TYPE_INTEGER , '1 ' , null , false , null , 0 , 'allownonor ' );
281
+ if ($ dbman ->field_exists ($ table , $ field )) {
282
+ $ dbman ->change_field_notnull ($ table , $ field );
283
+ $ dbman ->change_field_precision ($ table , $ field );
284
+ }
285
+
286
+ $ table = new xmldb_table ('turnitintooltwo_parts ' );
287
+ // Ensure unanon length is 1.
288
+ $ field = new xmldb_field ('unanon ' , XMLDB_TYPE_INTEGER , '1 ' , null , XMLDB_NOTNULL , null , 0 , 'migrated ' );
289
+ if ($ dbman ->field_exists ($ table , $ field )) {
290
+ $ dbman ->change_field_precision ($ table , $ field );
291
+ }
292
+ // Ensure submitted length is 1.
293
+ $ field = new xmldb_field ('submitted ' , XMLDB_TYPE_INTEGER , '1 ' , null , XMLDB_NOTNULL , null , 0 , 'unanon ' );
294
+ if ($ dbman ->field_exists ($ table , $ field )) {
295
+ $ dbman ->change_field_precision ($ table , $ field );
296
+ }
297
+
298
+ $ table = new xmldb_table ('turnitintooltwo_users ' );
299
+ // Ensure user_agreement_accepted allows null.
300
+ $ field = new xmldb_field ('user_agreement_accepted ' , XMLDB_TYPE_INTEGER , '1 ' , false , false , null , 0 , 'instructor_rubrics ' );
301
+ if ($ dbman ->field_exists ($ table , $ field )) {
302
+ $ dbman ->change_field_notnull ($ table , $ field );
303
+ }
304
+ upgrade_mod_savepoint (true , 2020081401 , 'turnitintooltwo ' );
254
305
}
255
306
256
307
return true ;
257
- }
308
+ }
0 commit comments