2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Leaning plan upgrade steps.
21 * @copyright 2015 Frédéric Massart - FMCorz.net
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
30 * @param int $oldversion
31 * @return bool always true
33 function xmldb_tool_lp_upgrade($oldversion) {
34 global $CFG, $DB, $OUTPUT;
36 $dbman = $DB->get_manager();
38 if ($oldversion < 2015052403) {
40 // Define index idnumber (unique) to be added to tool_lp_competency_framework.
41 $table = new xmldb_table('tool_lp_competency_framework');
42 $index = new xmldb_index('idnumber', XMLDB_INDEX_UNIQUE, array('idnumber'));
44 // Conditionally launch add index idnumber.
45 if (!$dbman->index_exists($table, $index)) {
46 $dbman->add_index($table, $index);
49 // Lp savepoint reached.
50 upgrade_plugin_savepoint(true, 2015052403, 'tool', 'lp');
53 if ($oldversion < 2015052404) {
55 // Define index idnumberframework (unique) to be added to tool_lp_competency.
56 $table = new xmldb_table('tool_lp_competency');
57 $index = new xmldb_index('idnumberframework', XMLDB_INDEX_UNIQUE, array('competencyframeworkid', 'idnumber'));
59 // Conditionally launch add index idnumberframework.
60 if (!$dbman->index_exists($table, $index)) {
61 $dbman->add_index($table, $index);
64 // Lp savepoint reached.
65 upgrade_plugin_savepoint(true, 2015052404, 'tool', 'lp');
68 if ($oldversion < 2015052405) {
70 // Define field contextid to be added to tool_lp_competency_framework.
71 $table = new xmldb_table('tool_lp_competency_framework');
72 $field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null,
73 context_system::instance()->id, 'shortname');
75 // Conditionally launch add field contextid.
76 if (!$dbman->field_exists($table, $field)) {
77 $dbman->add_field($table, $field);
80 // Lp savepoint reached.
81 upgrade_plugin_savepoint(true, 2015052405, 'tool', 'lp');
84 if ($oldversion < 2015052406) {
86 // Define field sortorder to be dropped from tool_lp_competency_framework.
87 $table = new xmldb_table('tool_lp_competency_framework');
88 $field = new xmldb_field('sortorder');
90 // Conditionally launch drop field sortorder.
91 if ($dbman->field_exists($table, $field)) {
92 $dbman->drop_field($table, $field);
95 // Lp savepoint reached.
96 upgrade_plugin_savepoint(true, 2015052406, 'tool', 'lp');
99 if ($oldversion < 2015052407) {
101 // Define field contextid to be added to tool_lp_template.
102 $table = new xmldb_table('tool_lp_template');
103 $field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null,
104 context_system::instance()->id, 'shortname');
106 // Conditionally launch add field contextid.
107 if (!$dbman->field_exists($table, $field)) {
108 $dbman->add_field($table, $field);
111 // Lp savepoint reached.
112 upgrade_plugin_savepoint(true, 2015052407, 'tool', 'lp');
115 if ($oldversion < 2015052408) {
117 // Define field sortorder to be dropped from tool_lp_template.
118 $table = new xmldb_table('tool_lp_template');
119 $field = new xmldb_field('sortorder');
121 // Conditionally launch drop field sortorder.
122 if ($dbman->field_exists($table, $field)) {
123 $dbman->drop_field($table, $field);
126 // Lp savepoint reached.
127 upgrade_plugin_savepoint(true, 2015052408, 'tool', 'lp');
130 if ($oldversion < 2015052412) {
132 // Define table tool_lp_related_competency to be created.
133 $table = new xmldb_table('tool_lp_related_competency');
135 // Adding fields to table tool_lp_related_competency.
136 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
137 $table->add_field('competencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
138 $table->add_field('relatedcompetencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
139 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
140 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
141 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
143 // Adding keys to table tool_lp_related_competency.
144 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
146 // Conditionally launch create table for tool_lp_related_competency.
147 if (!$dbman->table_exists($table)) {
148 $dbman->create_table($table);
151 // Lp savepoint reached.
152 upgrade_plugin_savepoint(true, 2015052412, 'tool', 'lp');
155 if ($oldversion < 2015052414) {
157 // Define field taxonomies to be added to tool_lp_competency_framework.
158 $table = new xmldb_table('tool_lp_competency_framework');
159 $field = new xmldb_field('taxonomies', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'visible');
161 // Conditionally launch add field taxonomies.
162 if (!$dbman->field_exists($table, $field)) {
163 $dbman->add_field($table, $field);
166 // Lp savepoint reached.
167 upgrade_plugin_savepoint(true, 2015052414, 'tool', 'lp');
170 if ($oldversion < 2015052416) {
172 // Define field idnumber to be dropped from tool_lp_template.
173 $table = new xmldb_table('tool_lp_template');
174 $field = new xmldb_field('idnumber');
176 // Conditionally launch drop field idnumber.
177 if ($dbman->field_exists($table, $field)) {
178 $dbman->drop_field($table, $field);
181 // Lp savepoint reached.
182 upgrade_plugin_savepoint(true, 2015052416, 'tool', 'lp');
185 if ($oldversion < 2015052420) {
187 // Define table tool_lp_user_competency to be created.
188 $table = new xmldb_table('tool_lp_user_competency');
190 // Adding fields to table tool_lp_user_competency.
191 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
192 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
193 $table->add_field('competencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
194 $table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
195 $table->add_field('reviewerid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
196 $table->add_field('proficiency', XMLDB_TYPE_INTEGER, '2', null, null, null, '0');
197 $table->add_field('grade', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
198 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
199 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
200 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
202 // Adding keys to table tool_lp_user_competency.
203 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
205 $index = new xmldb_index('useridcompetency', XMLDB_INDEX_UNIQUE, array('userid', 'competencyid'));
207 // Conditionally launch create table for tool_lp_user_competency.
208 if (!$dbman->table_exists($table)) {
209 $dbman->create_table($table);
212 // Conditionally launch add index useridcompetency.
213 if (!$dbman->index_exists($table, $index)) {
214 $dbman->add_index($table, $index);
217 // Lp savepoint reached.
218 upgrade_plugin_savepoint(true, 2015052420, 'tool', 'lp');
221 if ($oldversion < 2015052423) {
223 // Define table tool_lp_user_competency_plan to be created.
224 $table = new xmldb_table('tool_lp_user_competency_plan');
226 // Adding fields to table tool_lp_user_competency_plan.
227 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
228 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
229 $table->add_field('competencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
230 $table->add_field('planid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
231 $table->add_field('status', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0');
232 $table->add_field('reviewerid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
233 $table->add_field('proficiency', XMLDB_TYPE_INTEGER, '2', null, null, null, '0');
234 $table->add_field('grade', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
235 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
236 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
237 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
239 // Adding keys to table tool_lp_user_competency_plan.
240 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
242 $index = new xmldb_index('usercompetencyplan', XMLDB_INDEX_UNIQUE, array('userid', 'competencyid', 'planid'));
244 // Conditionally launch create table for tool_lp_user_competency_plan.
245 if (!$dbman->table_exists($table)) {
246 $dbman->create_table($table);
249 // Conditionally launch add index useridcompetency.
250 if (!$dbman->index_exists($table, $index)) {
251 $dbman->add_index($table, $index);
254 // Lp savepoint reached.
255 upgrade_plugin_savepoint(true, 2015052423, 'tool', 'lp');
258 if ($oldversion < 2015052424) {
260 // Define table tool_lp_plan_competency to be created.
261 $table = new xmldb_table('tool_lp_plan_competency');
263 // Adding fields to table tool_lp_plan_competency.
264 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
265 $table->add_field('planid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
266 $table->add_field('competencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
267 $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
268 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
269 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
270 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
272 // Adding keys to table tool_lp_user_competency.
273 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
275 // Index for table tool_lp_plan_competency.
276 $index = new xmldb_index('planidcompetencyid', XMLDB_INDEX_UNIQUE, array('planid', 'competencyid'));
278 // Conditionally launch create table for tool_lp_plan_competency.
279 if (!$dbman->table_exists($table)) {
280 $dbman->create_table($table);
283 // Conditionally launch add index planidcompetencyid.
284 if (!$dbman->index_exists($table, $index)) {
285 $dbman->add_index($table, $index);
288 // Lp savepoint reached.
289 upgrade_plugin_savepoint(true, 2015052424, 'tool', 'lp');
292 if ($oldversion < 2015052427) {
294 // Define fields status and reviewerid to be dropped from tool_lp_user_competency_plan.
295 $table = new xmldb_table('tool_lp_user_competency_plan');
296 $fieldstatus = new xmldb_field('status');
297 $fieldreviewerid = new xmldb_field('reviewerid');
299 // Conditionally launch drop field status.
300 if ($dbman->field_exists($table, $fieldstatus)) {
301 $dbman->drop_field($table, $fieldstatus);
304 // Conditionally launch drop field status.
305 if ($dbman->field_exists($table, $fieldreviewerid)) {
306 $dbman->drop_field($table, $fieldreviewerid);
309 // Lp savepoint reached.
310 upgrade_plugin_savepoint(true, 2015052427, 'tool', 'lp');
313 if ($oldversion < 2015111001) {
315 // Define field ruletype to be added to tool_lp_competency.
316 $table = new xmldb_table('tool_lp_competency');
317 $field = new xmldb_field('ruletype', XMLDB_TYPE_CHAR, '100', null, null, null, null, 'sortorder');
319 // Conditionally launch add field ruletype.
320 if (!$dbman->field_exists($table, $field)) {
321 $dbman->add_field($table, $field);
324 // Lp savepoint reached.
325 upgrade_plugin_savepoint(true, 2015111001, 'tool', 'lp');
328 if ($oldversion < 2015111002) {
330 // Define field ruleoutcome to be added to tool_lp_competency.
331 $table = new xmldb_table('tool_lp_competency');
332 $field = new xmldb_field('ruleoutcome', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'ruletype');
334 // Conditionally launch add field ruleoutcome.
335 if (!$dbman->field_exists($table, $field)) {
336 $dbman->add_field($table, $field);
339 // Lp savepoint reached.
340 upgrade_plugin_savepoint(true, 2015111002, 'tool', 'lp');
343 if ($oldversion < 2015111003) {
345 // Define field ruleconfig to be added to tool_lp_competency.
346 $table = new xmldb_table('tool_lp_competency');
347 $field = new xmldb_field('ruleconfig', XMLDB_TYPE_TEXT, null, null, null, null, null, 'ruleoutcome');
349 // Conditionally launch add field ruleconfig.
350 if (!$dbman->field_exists($table, $field)) {
351 $dbman->add_field($table, $field);
354 // Lp savepoint reached.
355 upgrade_plugin_savepoint(true, 2015111003, 'tool', 'lp');
358 if ($oldversion < 2015111004) {
360 // Define index ruleoutcome (not unique) to be added to tool_lp_competency.
361 $table = new xmldb_table('tool_lp_competency');
362 $index = new xmldb_index('ruleoutcome', XMLDB_INDEX_NOTUNIQUE, array('ruleoutcome'));
364 // Conditionally launch add index ruleoutcome.
365 if (!$dbman->index_exists($table, $index)) {
366 $dbman->add_index($table, $index);
369 // Lp savepoint reached.
370 upgrade_plugin_savepoint(true, 2015111004, 'tool', 'lp');
373 if ($oldversion < 2015111005) {
375 // Define table tool_lp_evidence to be created.
376 $table = new xmldb_table('tool_lp_evidence');
378 // Adding fields to table tool_lp_evidence.
379 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
380 $table->add_field('usercompetencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
381 $table->add_field('descidentifier', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
382 $table->add_field('desccomponent', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
383 $table->add_field('desca', XMLDB_TYPE_TEXT, null, null, null, null, null);
384 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
385 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
386 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
388 // Adding keys to table tool_lp_evidence.
389 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
391 // Adding indexes to table tool_lp_evidence.
392 $table->add_index('usercompetencyid', XMLDB_INDEX_NOTUNIQUE, array('usercompetencyid'));
394 // Conditionally launch create table for tool_lp_evidence.
395 if (!$dbman->table_exists($table)) {
396 $dbman->create_table($table);
399 // Lp savepoint reached.
400 upgrade_plugin_savepoint(true, 2015111005, 'tool', 'lp');
403 if ($oldversion < 2015111011) {
405 // Define index statusduedate (not unique) to be added to tool_lp_plan.
406 $table = new xmldb_table('tool_lp_plan');
407 $index = new xmldb_index('statusduedate', XMLDB_INDEX_NOTUNIQUE, array('status', 'duedate'));
409 // Conditionally launch add index statusduedate.
410 if (!$dbman->index_exists($table, $index)) {
411 $dbman->add_index($table, $index);
414 // Lp savepoint reached.
415 upgrade_plugin_savepoint(true, 2015111011, 'tool', 'lp');
418 if ($oldversion < 2015111012) {
420 // Define table tool_lp_template_cohort to be created.
421 $table = new xmldb_table('tool_lp_template_cohort');
423 // Adding fields to table tool_lp_template_cohort.
424 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
425 $table->add_field('templateid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
426 $table->add_field('cohortid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
427 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
428 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
429 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
431 // Adding keys to table tool_lp_template_cohort.
432 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
434 // Adding indexes to table tool_lp_template_cohort.
435 $table->add_index('templateid', XMLDB_INDEX_NOTUNIQUE, array('templateid'));
436 $table->add_index('templatecohortids', XMLDB_INDEX_UNIQUE, array('templateid', 'cohortid'));
438 // Conditionally launch create table for tool_lp_template_cohort.
439 if (!$dbman->table_exists($table)) {
440 $dbman->create_table($table);
443 // Lp savepoint reached.
444 upgrade_plugin_savepoint(true, 2015111012, 'tool', 'lp');
447 if ($oldversion < 2015111013) {
449 // Define field origtemplateid to be added to tool_lp_plan.
450 $table = new xmldb_table('tool_lp_plan');
451 $field = new xmldb_field('origtemplateid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'templateid');
453 // Conditionally launch add field origtemplateid.
454 if (!$dbman->field_exists($table, $field)) {
455 $dbman->add_field($table, $field);
458 // Lp savepoint reached.
459 upgrade_plugin_savepoint(true, 2015111013, 'tool', 'lp');
462 if ($oldversion < 2015111017) {
464 // Define field scaleid to be added to tool_lp_competency.
465 $table = new xmldb_table('tool_lp_competency');
466 $field = new xmldb_field('scaleid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'ruleconfig');
468 // Conditionally launch add field scaleid.
469 if (!$dbman->field_exists($table, $field)) {
470 $dbman->add_field($table, $field);
473 // Lp savepoint reached.
474 upgrade_plugin_savepoint(true, 2015111017, 'tool', 'lp');
477 if ($oldversion < 2015111018) {
479 // Define field scaleconfiguration to be added to tool_lp_competency.
480 $table = new xmldb_table('tool_lp_competency');
481 $field = new xmldb_field('scaleconfiguration', XMLDB_TYPE_TEXT, null, null, null, null, null, 'scaleid');
483 // Conditionally launch add field scaleconfiguration.
484 if (!$dbman->field_exists($table, $field)) {
485 $dbman->add_field($table, $field);
488 // Lp savepoint reached.
489 upgrade_plugin_savepoint(true, 2015111018, 'tool', 'lp');
492 if ($oldversion < 2015111020) {
494 // Define field url and grade to be added to tool_lp_evidence.
495 $table = new xmldb_table('tool_lp_evidence');
496 $fieldurl = new xmldb_field('url', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'desca');
497 $fieldgrade = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'url');
499 // Conditionally launch add field url.
500 if (!$dbman->field_exists($table, $fieldurl)) {
501 $dbman->add_field($table, $fieldurl);
504 // Conditionally launch add field grade.
505 if (!$dbman->field_exists($table, $fieldgrade)) {
506 $dbman->add_field($table, $fieldgrade);
509 // Lp savepoint reached.
510 upgrade_plugin_savepoint(true, 2015111020, 'tool', 'lp');
513 if ($oldversion < 2015111021) {
515 // Define field ruleoutcome to be added to tool_lp_course_competency.
516 $table = new xmldb_table('tool_lp_course_competency');
517 $field = new xmldb_field('ruleoutcome', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, 0, 'competencyid');
518 $index = new xmldb_index('courseidruleoutcome', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'ruleoutcome'));
520 // Conditionally launch add field ruleoutcome.
521 if (!$dbman->field_exists($table, $field)) {
522 $dbman->add_field($table, $field);
525 // Conditionally launch add index ruleoutcome.
526 if (!$dbman->index_exists($table, $index)) {
527 $dbman->add_index($table, $index);
530 // Lp savepoint reached.
531 upgrade_plugin_savepoint(true, 2015111021, 'tool', 'lp');
534 if ($oldversion < 2015111022) {
536 // Define field contextid to be added to tool_lp_evidence.
537 $table = new xmldb_table('tool_lp_evidence');
538 $field = new xmldb_field('contextid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'usercompetencyid');
540 // Conditionally launch add field contextid.
541 if (!$dbman->field_exists($table, $field)) {
542 $dbman->add_field($table, $field);
545 // Lp savepoint reached.
546 upgrade_plugin_savepoint(true, 2015111022, 'tool', 'lp');
549 if ($oldversion < 2015111023) {
551 // Define field action to be added to tool_lp_evidence.
552 $table = new xmldb_table('tool_lp_evidence');
553 $field = new xmldb_field('action', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null, 'contextid');
555 // Conditionally launch add field action.
556 if (!$dbman->field_exists($table, $field)) {
557 $dbman->add_field($table, $field);
560 // Lp savepoint reached.
561 upgrade_plugin_savepoint(true, 2015111023, 'tool', 'lp');
564 if ($oldversion < 2015111024) {
566 // Define field actionuserid to be added to tool_lp_evidence.
567 $table = new xmldb_table('tool_lp_evidence');
568 $field = new xmldb_field('actionuserid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'action');
570 // Conditionally launch add field actionuserid.
571 if (!$dbman->field_exists($table, $field)) {
572 $dbman->add_field($table, $field);
575 // Lp savepoint reached.
576 upgrade_plugin_savepoint(true, 2015111024, 'tool', 'lp');
579 if ($oldversion < 2015111027) {
581 // Define table tool_lp_user_evidence to be created.
582 $table = new xmldb_table('tool_lp_user_evidence');
584 // Adding fields to table tool_lp_user_evidence.
585 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
586 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
587 $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
588 $table->add_field('description', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
589 $table->add_field('descriptionformat', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
590 $table->add_field('url', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
591 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
592 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
593 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
595 // Adding keys to table tool_lp_user_evidence.
596 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
598 // Adding indexes to table tool_lp_user_evidence.
599 $table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
601 // Conditionally launch create table for tool_lp_user_evidence.
602 if (!$dbman->table_exists($table)) {
603 $dbman->create_table($table);
606 // Lp savepoint reached.
607 upgrade_plugin_savepoint(true, 2015111027, 'tool', 'lp');
610 if ($oldversion < 2015111029) {
612 // Define table tool_lp_user_evidence_comp to be created.
613 $table = new xmldb_table('tool_lp_user_evidence_comp');
615 // Adding fields to table tool_lp_user_evidence_comp.
616 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
617 $table->add_field('userevidenceid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
618 $table->add_field('competencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
619 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
620 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
621 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
623 // Adding keys to table tool_lp_user_evidence_comp.
624 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
626 // Adding indexes to table tool_lp_user_evidence_comp.
627 $table->add_index('userevidenceid', XMLDB_INDEX_NOTUNIQUE, array('userevidenceid'));
628 $table->add_index('userevidencecompids', XMLDB_INDEX_UNIQUE, array('userevidenceid', 'competencyid'));
630 // Conditionally launch create table for tool_lp_user_evidence_comp.
631 if (!$dbman->table_exists($table)) {
632 $dbman->create_table($table);
635 // Lp savepoint reached.
636 upgrade_plugin_savepoint(true, 2015111029, 'tool', 'lp');
639 if ($oldversion < 2015111030) {
641 // Define field visible to be removed from tool_lp_competency.
642 $table = new xmldb_table('tool_lp_competency');
643 $field = new xmldb_field('visible');
645 // Conditionally launch drop field visible.
646 if ($dbman->field_exists($table, $field)) {
647 $dbman->drop_field($table, $field);
650 // Lp savepoint reached.
651 upgrade_plugin_savepoint(true, 2015111030, 'tool', 'lp');
654 if ($oldversion < 2015111039) {
656 // Define table tool_lp_module_competency to be created.
657 $table = new xmldb_table('tool_lp_module_competency');
659 // Adding fields to table tool_lp_module_competency.
660 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
661 $table->add_field('cmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
662 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
663 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
664 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
665 $table->add_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
666 $table->add_field('competencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
667 $table->add_field('ruleoutcome', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null);
669 // Adding keys to table tool_lp_module_competency.
670 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
671 $table->add_key('cmidkey', XMLDB_KEY_FOREIGN, array('cmid'), 'id', array('course_modules'));
672 $table->add_key('competencyidkey', XMLDB_KEY_FOREIGN, array('competencyid'), 'tool_lp_competency', array('id'));
674 // Adding indexes to table tool_lp_module_competency.
675 $table->add_index('cmidruleoutcome', XMLDB_INDEX_NOTUNIQUE, array('cmid', 'ruleoutcome'));
677 // Conditionally launch create table for tool_lp_module_competency.
678 if (!$dbman->table_exists($table)) {
679 $dbman->create_table($table);
682 // Lp savepoint reached.
683 upgrade_plugin_savepoint(true, 2015111039, 'tool', 'lp');
686 if ($oldversion < 2015111041) {
688 // Define field reviewerid to be added to tool_lp_plan.
689 $table = new xmldb_table('tool_lp_plan');
690 $field = new xmldb_field('reviewerid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'duedate');
692 // Conditionally launch add field reviewerid.
693 if (!$dbman->field_exists($table, $field)) {
694 $dbman->add_field($table, $field);
697 // Lp savepoint reached.
698 upgrade_plugin_savepoint(true, 2015111041, 'tool', 'lp');
701 if ($oldversion < 2016020900) {
703 // Define field note to be added to tool_lp_evidence.
704 $table = new xmldb_table('tool_lp_evidence');
705 $field = new xmldb_field('note', XMLDB_TYPE_TEXT, null, null, null, null, null, 'grade');
707 // Conditionally launch add field note.
708 if (!$dbman->field_exists($table, $field)) {
709 $dbman->add_field($table, $field);
712 // Lp savepoint reached.
713 upgrade_plugin_savepoint(true, 2016020900, 'tool', 'lp');
716 if ($oldversion < 2016020901) {
718 // Define field note to be added to tool_lp_user_competency_plan.
719 $table = new xmldb_table('tool_lp_user_competency_plan');
720 $field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
722 // Conditionally launch add field note.
723 if (!$dbman->field_exists($table, $field)) {
724 $dbman->add_field($table, $field);
727 // Lp savepoint reached.
728 upgrade_plugin_savepoint(true, 2016020901, 'tool', 'lp');
731 if ($oldversion < 2016020902) {
733 // Define index cmidcompetencyid to be added to tool_lp_module_competency.
734 $table = new xmldb_table('tool_lp_module_competency');
735 $index = new xmldb_index('cmidcompetencyid', XMLDB_INDEX_NOTUNIQUE, array('cmid', 'competencyid'));
737 // Conditionally launch add index cmidcompetencyid.
738 if (!$dbman->index_exists($table, $index)) {
739 $dbman->add_index($table, $index);
742 // Lp savepoint reached.
743 upgrade_plugin_savepoint(true, 2016020902, 'tool', 'lp');
746 if ($oldversion < 2016020909) {
748 // Define index cmidcompetencyid (unique) to be dropped form tool_lp_module_competency.
749 $table = new xmldb_table('tool_lp_module_competency');
750 $index = new xmldb_index('cmidcompetencyid', XMLDB_INDEX_NOTUNIQUE, array('cmid', 'competencyid'));
752 // Conditionally launch drop index cmidcompetencyid.
753 if ($dbman->index_exists($table, $index)) {
754 $dbman->drop_index($table, $index);
757 // Lp savepoint reached.
758 upgrade_plugin_savepoint(true, 2016020909, 'tool', 'lp');
761 if ($oldversion < 2016020910) {
763 // Define index cmidcompetencyid (unique) to be added to tool_lp_module_competency.
764 $table = new xmldb_table('tool_lp_module_competency');
765 $index = new xmldb_index('cmidcompetencyid', XMLDB_INDEX_UNIQUE, array('cmid', 'competencyid'));
767 // Conditionally launch add index cmidcompetencyid.
768 if (!$dbman->index_exists($table, $index)) {
769 $dbman->add_index($table, $index);
772 // Lp savepoint reached.
773 upgrade_plugin_savepoint(true, 2016020910, 'tool', 'lp');
776 if ($oldversion < 2016020912) {
778 // Define table tool_lp_user_comp_course to be created.
779 $table = new xmldb_table('tool_lp_user_comp_course');
781 // Adding fields to table tool_lp_user_comp_course.
782 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
783 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
784 $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
785 $table->add_field('competencyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
786 $table->add_field('proficiency', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
787 $table->add_field('grade', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
788 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
789 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
790 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
792 // Adding keys to table tool_lp_user_comp_course.
793 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
795 // Adding indexes to table tool_lp_user_comp_course.
796 $table->add_index('useridcoursecomp', XMLDB_INDEX_UNIQUE, array('userid', 'courseid', 'competencyid'));
798 // Conditionally launch create table for tool_lp_user_comp_course.
799 if (!$dbman->table_exists($table)) {
800 $dbman->create_table($table);
803 // Lp savepoint reached.
804 upgrade_plugin_savepoint(true, 2016020912, 'tool', 'lp');
807 if ($oldversion < 2016020913) {
809 // Changing type of field scaleconfiguration on table tool_lp_competency_framework to text.
810 $table = new xmldb_table('tool_lp_competency_framework');
811 $field = new xmldb_field('scaleconfiguration', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, 'scaleid');
813 // Launch change of type for field scaleconfiguration.
814 $dbman->change_field_type($table, $field);
816 // Launch change of nullability for field scaleconfiguration.
817 $dbman->change_field_notnull($table, $field);
819 // Lp savepoint reached.
820 upgrade_plugin_savepoint(true, 2016020913, 'tool', 'lp');
823 if ($oldversion < 2016020917) {
824 // Define index courseidcompetencyid (unique) to be added to tool_lp_course_competency.
825 $table = new xmldb_table('tool_lp_course_competency');
826 $index = new xmldb_index('courseidcompetencyid', XMLDB_INDEX_UNIQUE, array('courseid', 'competencyid'));
827 // Conditionally launch add index cmidcompetencyid.
828 if (!$dbman->index_exists($table, $index)) {
829 $dbman->add_index($table, $index);
831 // Lp savepoint reached.
832 upgrade_plugin_savepoint(true, 2016020917, 'tool', 'lp');
835 if ($oldversion < 2016020923) {
837 // Define table tool_lp_coursecompsettings to be created.
838 $table = new xmldb_table('tool_lp_coursecompsettings');
840 // Adding fields to table tool_lp_coursecompsettings.
841 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
842 $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
843 $table->add_field('pushratingstouserplans', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
844 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
845 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
846 $table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
848 // Adding keys to table tool_lp_coursecompsettings.
849 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
850 $table->add_key('courseidlink', XMLDB_KEY_FOREIGN_UNIQUE, array('courseid'), 'course', array('id'));
852 // Conditionally launch create table for tool_lp_coursecompsettings.
853 if (!$dbman->table_exists($table)) {
854 $dbman->create_table($table);
857 // Lp savepoint reached.
858 upgrade_plugin_savepoint(true, 2016020923, 'tool', 'lp');