/
updatedb_helper.php
3245 lines (3006 loc) · 166 KB
/
updatedb_helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?PHP
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
*/
/* Rules:
- Never use models in the upgrade process - never ever!
- Use the provided addColumn, alterColumn, dropPrimaryKey etc. functions where applicable - they ensure cross-DB compatibility
- Never use foreign keys
- Do not use fancy database field types (like mediumtext, timestamp, etc) - only use the ones provided by Yii
- If you want to use database functions make sure they exist on all three supported database types
- Always prefix key names by using curly brackets {{ }}
*/
/**
* @param integer $iOldDBVersion The previous database version
* @param boolean $bSilent Run update silently with no output - this checks if the update can be run silently at all. If not it will not run any updates at all.
*/
function db_upgrade_all($iOldDBVersion, $bSilent = false)
{
/**
* If you add a new database version add any critical database version numbers to this array. See link
* @link https://manual.limesurvey.org/Database_versioning for explanations
* @var array $aCriticalDBVersions An array of cricital database version.
*/
$aCriticalDBVersions = array(310);
$aAllUpdates = range($iOldDBVersion + 1, Yii::app()->getConfig('dbversionnumber'));
// If trying to update silenty check if it is really possible
if ($bSilent && (count(array_intersect($aCriticalDBVersions, $aAllUpdates)) > 0)) {
return false;
}
// If DBVersion is older than 184 don't allow database update
If ($iOldDBVersion < 184) {
return false;
}
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $modifyoutput;
Yii::app()->loadHelper('database');
$sUserTemplateRootDir = Yii::app()->getConfig('userthemerootdir');
$sStandardTemplateRootDir = Yii::app()->getConfig('standardthemerootdir');
$oDB = Yii::app()->getDb();
$oDB->schemaCachingDuration = 0; // Deactivate schema caching
Yii::app()->setConfig('Updating', true);
try {
// LS 2.5 table start at 250
if ($iOldDBVersion < 250) {
$oTransaction = $oDB->beginTransaction();
createBoxes250();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>250), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 251) {
$oTransaction = $oDB->beginTransaction();
upgradeBoxesTable251();
// Update DBVersion
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>251), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 252) {
$oTransaction = $oDB->beginTransaction();
Yii::app()->db->createCommand()->addColumn('{{questions}}', 'modulename', 'string');
// Update DBVersion
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>252), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 253) {
$oTransaction = $oDB->beginTransaction();
upgradeSurveyTables253();
// Update DBVersion
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>253), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 254) {
$oTransaction = $oDB->beginTransaction();
upgradeSurveyTables254();
// Update DBVersion
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>254), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 255) {
$oTransaction = $oDB->beginTransaction();
upgradeSurveyTables255();
// Update DBVersion
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>255), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 256) {
$oTransaction = $oDB->beginTransaction();
upgradeTokenTables256();
alterColumn('{{participants}}', 'email', "text", false);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>256), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 257) {
$oTransaction = $oDB->beginTransaction();
switch (Yii::app()->db->driverName) {
case 'pgsql':
$sSubstringCommand = 'substr';
break;
default:
$sSubstringCommand = 'substring';
}
$oDB->createCommand("UPDATE {{templates}} set folder={$sSubstringCommand}(folder,1,50)")->execute();
dropPrimaryKey('templates');
alterColumn('{{templates}}', 'folder', "string(50)", false);
addPrimaryKey('templates', 'folder');
dropPrimaryKey('participant_attribute_names_lang');
alterColumn('{{participant_attribute_names_lang}}', 'lang', "string(20)", false);
addPrimaryKey('participant_attribute_names_lang', array('attribute_id', 'lang'));
//Fixes the collation for the complete DB, tables and columns
if (Yii::app()->db->driverName == 'mysql') {
fixMySQLCollations('utf8mb4', 'utf8mb4_unicode_ci');
// Also apply again fixes from DBVersion 181 again for case sensitive token fields
upgradeSurveyTables181('utf8mb4_bin');
upgradeTokenTables181('utf8mb4_bin');
}
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>257), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Remove adminimageurl from global settings
*/
if ($iOldDBVersion < 258) {
$oTransaction = $oDB->beginTransaction();
Yii::app()->getDb()->createCommand(
"DELETE FROM {{settings_global}} WHERE stg_name='adminimageurl'"
)->execute();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>258), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Add table for notifications
* @since 2016-08-04
* @author Olle Haerstedt
*/
if ($iOldDBVersion < 259) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->createTable('{{notifications}}', array(
'id' => 'pk',
'entity' => 'string(15) not null',
'entity_id' => 'integer not null',
'title' => 'string not null', // varchar(255) in postgres
'message' => 'text not null',
'status' => "string(15) not null default 'new' ",
'importance' => 'integer not null default 1',
'display_class' => "string(31) default 'default'",
'created' => 'datetime',
'first_read' => 'datetime'
));
$oDB->createCommand()->createIndex('{{notif_index}}', '{{notifications}}', 'entity, entity_id, status', false);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>259), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 260) {
$oTransaction = $oDB->beginTransaction();
alterColumn('{{participant_attribute_names}}', 'defaultname', "string(255)", false);
alterColumn('{{participant_attribute_names_lang}}', 'attribute_name', "string(255)", false);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>260), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 261) {
$oTransaction = $oDB->beginTransaction();
/*
* The hash value of a notification is used to calculate uniqueness.
* @since 2016-08-10
* @author Olle Haerstedt
*/
addColumn('{{notifications}}', 'hash', 'string(64)');
$oDB->createCommand()->createIndex('{{notif_hash_index}}', '{{notifications}}', 'hash', false);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>261), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 262) {
$oTransaction = $oDB->beginTransaction();
alterColumn('{{settings_global}}', 'stg_value', "text", false);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>262), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 263) {
$oTransaction = $oDB->beginTransaction();
// Dummy version update for hash column in installation SQL.
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>263), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Add seed column in all active survey tables
* Might take time to execute
* @since 2016-09-01
*/
if ($iOldDBVersion < 290) {
$oTransaction = $oDB->beginTransaction();
$aTables = dbGetTablesLike("survey\_%");
$oSchema = Yii::app()->db->schema;
foreach ($aTables as $sTableName) {
$oTableSchema = $oSchema->getTable($sTableName);
// Only update the table if it really is a survey response table - there are other tables that start the same
if (!in_array('lastpage', $oTableSchema->columnNames)) {
continue;
}
// If survey has active table, create seed column
Yii::app()->db->createCommand()->addColumn($sTableName, 'seed', 'string(31)');
// RAND is RANDOM in Postgres
switch (Yii::app()->db->driverName) {
case 'pgsql':
Yii::app()->db->createCommand("UPDATE {$sTableName} SET seed = ROUND(RANDOM() * 10000000)")->execute();
break;
default:
Yii::app()->db->createCommand("UPDATE {$sTableName} SET seed = ROUND(RAND() * 10000000, 0)")->execute();
break;
}
}
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>290), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Plugin JSON config file
* @since 2016-08-22
*/
if ($iOldDBVersion < 291) {
$oTransaction = $oDB->beginTransaction();
addColumn('{{plugins}}', 'version', 'string(32)');
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>291), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Survey menue table
* @since 2017-07-03
*/
if ($iOldDBVersion < 293) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>293), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Survey menue table update
* @since 2017-07-03
*/
if ($iOldDBVersion < 294) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>294), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Survey menue table update
* @since 2017-07-12
*/
if ($iOldDBVersion < 296) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>296), "stg_name='DBVersion'");
$oTransaction->commit();
}
/**
* Template tables
* @since 2017-07-12
*/
if ($iOldDBVersion < 298) {
$oTransaction = $oDB->beginTransaction();
upgradeTemplateTables298($oDB);
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>298), "stg_name='DBVersion'");
}
/**
* Template tables
* @since 2017-07-12
*/
if ($iOldDBVersion < 304) {
$oTransaction = $oDB->beginTransaction();
upgradeTemplateTables304($oDB);
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>304), "stg_name='DBVersion'");
}
/**
* Update to sidemenu rendering
*/
if ($iOldDBVersion < 305) {
$oTransaction = $oDB->beginTransaction();
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>305), "stg_name='DBVersion'");
}
/**
* Template tables
* @since 2017-07-12
*/
if ($iOldDBVersion < 306) {
$oTransaction = $oDB->beginTransaction();
createSurveyGroupTables306($oDB);
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>306), "stg_name='DBVersion'");
}
/**
* User settings table
* @since 2016-08-29
*/
if ($iOldDBVersion < 307) {
$oTransaction = $oDB->beginTransaction();
if (tableExists('{settings_user}')) {
$oDB->createCommand()->dropTable('{{settings_user}}');
}
$oDB->createCommand()->createTable('{{settings_user}}', array(
'id' => 'pk',
'uid' => 'integer NOT NULL',
'entity' => 'string(15)',
'entity_id' => 'string(31)',
'stg_name' => 'string(63) not null',
'stg_value' => 'text',
));
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>307), "stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Change dbfieldnames to be more functional
*/
if ($iOldDBVersion < 308) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>308), "stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Add survey template editing to menu
*/
if ($iOldDBVersion < 309) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>309), "stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Reset all surveymenu tables, because there were too many errors
*/
if ($iOldDBVersion < 310) {
$oTransaction = $oDB->beginTransaction();
reCreateSurveyMenuTable310($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>310), "stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Add template settings to survey groups
*/
if ($iOldDBVersion < 311) {
$oTransaction = $oDB->beginTransaction();
addColumn('{{surveys_groups}}', 'template', "string(128) DEFAULT 'default'");
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>311), "stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Add ltr/rtl capability to template configuration
*/
if ($iOldDBVersion < 312) {
$oTransaction = $oDB->beginTransaction();
// Already added in beta 2 but with wrong type
try { setTransactionBookmark(); $oDB->createCommand()->dropColumn('{{template_configuration}}', 'packages_ltr'); } catch (Exception $e) { rollBackToTransactionBookmark(); }
try { setTransactionBookmark(); $oDB->createCommand()->dropColumn('{{template_configuration}}', 'packages_rtl'); } catch (Exception $e) { rollBackToTransactionBookmark(); }
addColumn('{{template_configuration}}', 'packages_ltr', "text");
addColumn('{{template_configuration}}', 'packages_rtl', "text");
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>312), "stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Add ltr/rtl capability to template configuration
*/
if ($iOldDBVersion < 313) {
$oTransaction = $oDB->beginTransaction();
addColumn('{{surveymenu_entries}}', 'active', "boolean NOT NULL DEFAULT '0'");
addColumn('{{surveymenu}}', 'active', "boolean NOT NULL DEFAULT '0'");
$oDB->createCommand()->update('{{surveymenu_entries}}', array('active'=>1));
$oDB->createCommand()->update('{{surveymenu}}', array('active'=>1));
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>313), "stg_name='DBVersion'");
$oTransaction->commit();
}
/*
* Add ltr/rtl capability to template configuration
*/
if ($iOldDBVersion < 314) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{surveymenu_entries}}',
array('name'=>'resources', 'title'=>'Add/Edit resources to the survey', 'menu_title'=>'Resources', 'menu_description'=>'Add/Edit resources to the survey'),
'id=15'
);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>314), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 315) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{template_configuration}}',
array('packages_to_load'=>'["pjax"]'),
"templates_name='default' OR templates_name='material'"
);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>315), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 316) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->renameColumn('{{template_configuration}}', 'templates_name', 'template_name');
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>316), "stg_name='DBVersion'");
$oTransaction->commit();
}
//Transition of the password field to a TEXT type
if ($iOldDBVersion < 317) {
$oTransaction = $oDB->beginTransaction();
transferPasswordFieldToText($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>317), "stg_name='DBVersion'");
$oTransaction->commit();
}
//Rename order to sortorder
if ($iOldDBVersion < 318) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>318), "stg_name='DBVersion'");
$oTransaction->commit();
}
//force panelintegration to a full reload
if ($iOldDBVersion < 319) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{surveymenu_entries}}', array('data'=>'{"render": {"link": { "pjaxed": false}}}'), "name='panelintegration'");
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>319), "stg_name='DBVersion'");
$table = Yii::app()->db->schema->getTable('{{surveys_groups}}');
if (isset($table->columns['order'])) {
$oDB->createCommand()->renameColumn('{{surveys_groups}}', 'order', 'sortorder');
}
$table = Yii::app()->db->schema->getTable('{{templates}}');
if (isset($table->columns['extends_template_name'])) {
$oDB->createCommand()->renameColumn('{{templates}}', 'extends_template_name', 'extends');
}
$oTransaction->commit();
}
if ($iOldDBVersion < 320) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update('{{surveymenu_entries}}', array('action'=>'updatesurveylocalesettings_generalsettings'), "name='generalsettings'");
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>320), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 321) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update(
'{{surveymenu_entries}}',
array('data' => '{"render": {"isActive": true, "link": {"data": {"surveyid": ["survey", "sid"]}}}}'),
"name = 'statistics' OR name = 'responses'"
);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>321), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 322) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->createTable(
'{{tutorials}}', [
'tid' => 'pk',
'name' => 'string(128)',
'description' => 'text',
'active' => 'int DEFAULT 0',
'settings' => 'text',
'permission' => 'string(128) NOT NULL',
'permission_grade' => 'string(128) NOT NULL'
]
);
$oDB->createCommand()->createTable(
'{{tutorial_entries}}', [
'teid' => 'pk',
'tid' => 'int NOT NULL',
'title' => 'text',
'content' => 'text',
'settings' => 'text'
]
);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>322), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 323) {
$oTransaction = $oDB->beginTransaction();
dropPrimaryKey('labels', 'lid');
$oDB->createCommand()->addColumn('{{labels}}', 'id', 'pk');
$oDB->createCommand()->createIndex('{{idx4_labels}}', '{{labels}}', ['lid', 'sortorder', 'language'], false);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>323), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 324) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->insert('{{surveymenu_entries}}',
array(
'menu_id' => 1,
'ordering' => 16,
'name' => 'plugins',
'title' => 'Plugin settings',
'menu_title' => 'Plugins',
'menu_description' => 'Edit plugin settings',
'menu_icon' => 'plug',
'menu_icon_type' => 'fontawesome',
'action' => 'updatesurveylocalesettings',
'template' => 'editLocalSettings_main_view',
'partial' => '/admin/survey/subview/accordion/_plugin_panel',
'permission' => 'surveysettings',
'permission_grade' => 'read',
'data' => '',
'getdatamethod' => '_pluginTabSurvey',
'changed_at' => date('Y-m-d H:i:s'),
'changed_by' => 1,
'created_at' => date('Y-m-d H:i:s'),
'created_by' => 1,
'active' => 0
));
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>324), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 325) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->dropTable('{{templates}}');
$oDB->createCommand()->dropTable('{{template_configuration}}');
// templates
$oDB->createCommand()->createTable('{{templates}}', array(
'id' => "pk",
'name' => "string(150) NOT NULL",
'folder' => "string(45) NULL",
'title' => "string(100) NOT NULL",
'creation_date' => "datetime NULL",
'author' => "string(150) NULL",
'author_email' => "string(255) NULL",
'author_url' => "string(255) NULL",
'copyright' => "text ",
'license' => "text ",
'version' => "string(45) NULL",
'api_version' => "string(45) NOT NULL",
'view_folder' => "string(45) NOT NULL",
'files_folder' => "string(45) NOT NULL",
'description' => "text ",
'last_update' => "datetime NULL",
'owner_id' => "integer NULL",
'extends' => "string(150) NULL",
));
$oDB->createCommand()->createIndex('{{idx1_templates}}', '{{templates}}', 'name', false);
$oDB->createCommand()->createIndex('{{idx2_templates}}', '{{templates}}', 'title', false);
$oDB->createCommand()->createIndex('{{idx3_templates}}', '{{templates}}', 'owner_id', false);
$oDB->createCommand()->createIndex('{{idx4_templates}}', '{{templates}}', 'extends', false);
$headerArray = ['name', 'folder', 'title', 'creation_date', 'author', 'author_email', 'author_url', 'copyright', 'license', 'version', 'api_version', 'view_folder', 'files_folder', 'description', 'last_update', 'owner_id', 'extends'];
$oDB->createCommand()->insert("{{templates}}", array_combine($headerArray, ['default', 'default', 'Advanced Template', date('Y-m-d H:i:s'), 'Louis Gac', 'louis.gac@limesurvey.org', 'https://www.limesurvey.org/', 'Copyright (C) 2007-2017 The LimeSurvey Project Team\\r\\nAll rights reserved.', 'License: GNU/GPL License v2 or later, see LICENSE.php\\r\\n\\r\\nLimeSurvey is free software. This version may have been modified pursuant to the GNU General Public License, and as distributed it includes or is derivative of works licensed under the GNU General Public License or other free or open source software licenses. See COPYRIGHT.php for copyright notices and details.', '1.0', '3.0', 'views', 'files', "<strong>LimeSurvey Advanced Template</strong><br>A template with custom options to show what it's possible to do with the new engines. Each template provider will be able to offer its own option page (loaded from template)", null, 1, '']));
$oDB->createCommand()->insert("{{templates}}", array_combine($headerArray, ['material', 'material', 'Material Template', date('Y-m-d H:i:s'), 'Louis Gac', 'louis.gac@limesurvey.org', 'https://www.limesurvey.org/', 'Copyright (C) 2007-2017 The LimeSurvey Project Team\\r\\nAll rights reserved.', 'License: GNU/GPL License v2 or later, see LICENSE.php\\r\\n\\r\\nLimeSurvey is free software. This version may have been modified pursuant to the GNU General Public License, and as distributed it includes or is derivative of works licensed under the GNU General Public License or other free or open source software licenses. See COPYRIGHT.php for copyright notices and details.', '1.0', '3.0', 'views', 'files', '<strong>LimeSurvey Advanced Template</strong><br> A template extending default, to show the inheritance concept. Notice the options, differents from Default.<br><small>uses FezVrasta\'s Material design theme for Bootstrap 3</small>', null, 1, 'default']));
$oDB->createCommand()->insert("{{templates}}", array_combine($headerArray, ['monochrome', 'monochrome', 'Monochrome Templates', date('Y-m-d H:i:s'), 'Louis Gac', 'louis.gac@limesurvey.org', 'https://www.limesurvey.org/', 'Copyright (C) 2007-2017 The LimeSurvey Project Team\\r\\nAll rights reserved.', 'License: GNU/GPL License v2 or later, see LICENSE.php\\r\\n\\r\\nLimeSurvey is free software. This version may have been modified pursuant to the GNU General Public License, and as distributed it includes or is derivative of works licensed under the GNU General Public License or other free or open source software licenses. See COPYRIGHT.php for copyright notices and details.', '1.0', '3.0', 'views', 'files', '<strong>LimeSurvey Monochrome Templates</strong><br>A template with monochrome colors for easy customization.', null, 1, '']));
// template_configuration
$oDB->createCommand()->createTable('{{template_configuration}}', array(
'id' => "pk",
'template_name' => "string(150) NOT NULL",
'sid' => "integer NULL",
'gsid' => "integer NULL",
'uid' => "integer NULL",
'files_css' => "text",
'files_js' => "text",
'files_print_css' => "text",
'options' => "text ",
'cssframework_name' => "string(45) NULL",
'cssframework_css' => "text",
'cssframework_js' => "text",
'packages_to_load' => "text",
'packages_ltr' => "text",
'packages_rtl' => "text",
));
$oDB->createCommand()->createIndex('{{idx1_template_configuration}}', '{{template_configuration}}', 'template_name', false);
$oDB->createCommand()->createIndex('{{idx2_template_configuration}}', '{{template_configuration}}', 'sid', false);
$oDB->createCommand()->createIndex('{{idx3_template_configuration}}', '{{template_configuration}}', 'gsid', false);
$oDB->createCommand()->createIndex('{{idx4_template_configuration}}', '{{template_configuration}}', 'uid', false);
$headerArray = ['template_name', 'sid', 'gsid', 'uid', 'files_css', 'files_js', 'files_print_css', 'options', 'cssframework_name', 'cssframework_css', 'cssframework_js', 'packages_to_load', 'packages_ltr', 'packages_rtl'];
$oDB->createCommand()->insert("{{template_configuration}}", array_combine($headerArray, ['default', null, null, null, '{"add": ["css/animate.css","css/template.css"]}', '{"add": ["scripts/template.js", "scripts/ajaxify.js"]}', '{"add":"css/print_template.css"}', '{"ajaxmode":"on","brandlogo":"on", "brandlogofile": "./files/logo.png", "boxcontainer":"on", "backgroundimage":"off","animatebody":"off","bodyanimation":"fadeInRight","animatequestion":"off","questionanimation":"flipInX","animatealert":"off","alertanimation":"shake"}', 'bootstrap', '{"replace": [["css/bootstrap.css","css/flatly.css"]]}', '', '["pjax"]', '', '']));
$oDB->createCommand()->insert("{{template_configuration}}", array_combine($headerArray, ['material', null, null, null, '{"add": ["css/bootstrap-material-design.css", "css/ripples.min.css", "css/template.css"]}', '{"add": ["scripts/template.js", "scripts/material.js", "scripts/ripples.min.js", "scripts/ajaxify.js"]}', '{"add":"css/print_template.css"}', '{"ajaxmode":"on","brandlogo":"on", "brandlogofile": "./files/logo.png", "animatebody":"off","bodyanimation":"fadeInRight","animatequestion":"off","questionanimation":"flipInX","animatealert":"off","alertanimation":"shake"}', 'bootstrap', '{"replace": [["css/bootstrap.css","css/bootstrap.css"]]}', '', '["pjax"]', '', '']));
$oDB->createCommand()->insert("{{template_configuration}}", array_combine($headerArray, ['monochrome', null, null, null, '{"add":["css/animate.css","css/ajaxify.css","css/sea_green.css", "css/template.css"]}', '{"add":["scripts/template.js","scripts/ajaxify.js"]}', '{"add":"css/print_template.css"}', '{"ajaxmode":"on","brandlogo":"on","brandlogofile":".\/files\/logo.png","boxcontainer":"on","backgroundimage":"off","animatebody":"off","bodyanimation":"fadeInRight","animatequestion":"off","questionanimation":"flipInX","animatealert":"off","alertanimation":"shake"}', 'bootstrap', '{}', '', '["pjax"]', '', '']));
$oDB->createCommand()->update('{{surveymenu_entries}}', array('data'=>'{"render": {"link": { "data": {"surveyid": ["survey","sid"], "gsid":["survey","gsid"]}}}}'), "name='template_options'");
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>325), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 326) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->alterColumn('{{surveys}}', 'datecreated', 'datetime');
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>326), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 327) {
$oTransaction = $oDB->beginTransaction();
upgrade327($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>327), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 328) {
$oTransaction = $oDB->beginTransaction();
upgrade328($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>328), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 329) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->alterColumn('{{surveymenu_entries}}', 'name', 'string(168) NOT NULL');
$oDB->createCommand()->update('{{surveymenu_entries}}', array('name' => 'generalsettings_collapsed'), "name = 'generalsettings' AND menu_id = 2");
$oDB->createCommand()->update('{{surveymenu_entries}}', array('name' => 'surveypermissions_collapsed'), "name = 'surveypermissions' AND menu_id = 2");
$oDB->createCommand()->update('{{surveymenu_entries}}', array('name' => 'quotas_collapsed'), "name = 'quotas' AND menu_id = 2");
$oDB->createCommand()->update('{{surveymenu_entries}}', array('name' => 'assessments_collapsed'), "name = 'assessments' AND menu_id = 2");
$oDB->createCommand()->update('{{surveymenu_entries}}', array('name' => 'emailtemplates_collapsed'), "name = 'emailtemplates' AND menu_id = 2");
$oDB->createCommand()->update('{{surveymenu_entries}}', array('name' => 'tokens_collapsed'), "name = 'tokens' AND menu_id = 2");
$oDB->createCommand()->createIndex('{{surveymenu_entries_name}}', '{{surveymenu_entries}}', "name", true);
$oDB->createCommand()->addColumn('{{surveymenu}}', 'name', 'string(128) NULL');
$oDB->createCommand()->createIndex('{{surveymenu_name}}', '{{surveymenu}}', 'name', true);
$oDB->createCommand()->update('{{surveymenu}}', array('name' => 'mainmenu'), 'id = 1');
$oDB->createCommand()->update('{{surveymenu}}', array('name' => 'quickmenu'), 'id = 2');
$oDB->createCommand()->alterColumn('{{surveymenu}}', 'name', 'string(128) NOT NULL');
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>329), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 330) {
$oTransaction = $oDB->beginTransaction();
upgrade330($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>330), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 331) {
$oTransaction = $oDB->beginTransaction();
upgrade331($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>331), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 332) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->insert(
'{{surveymenu}}',
array(
'parent_id' => 1,
'survey_id' => null,
'ordering' => 0,
'level' => 1,
'name' => 'pluginmenu',
'title' => 'Plugin menu',
'description' => 'Plugins menu',
'changed_at' => date('Y-m-d H:i:s'),
'changed_by' => 0,
'created_at' => date('Y-m-d H:i:s'),
'created_by' => 0
)
);
$pluginMenuId = $oDB->getLastInsertID();
$oDB->createCommand()->update('{{surveymenu_entries}}', array(
'menu_id' => $pluginMenuId,
'title' => 'Simple plugins',
'menu_title' => 'Simple plugins',
'menu_description' => 'Edit simple plugin settings',
), "name='plugins'");
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>332), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 333) {
$oTransaction = $oDB->beginTransaction();
upgrade333($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>333), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 334) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->addColumn('{{tutorials}}', 'title', 'string(192)');
$oDB->createCommand()->addColumn('{{tutorials}}', 'icon', 'string(64)');
$oDB->createCommand()->update( '{{tutorials}}', [
'settings' => json_encode(array(
'debug' => true,
'orphan' => true,
'keyboard' => false,
'template' => "<div class='popover tour lstutorial__template--mainContainer'> <div class='arrow'></div> <h3 class='popover-title lstutorial__template--title'></h3> <div class='popover-content lstutorial__template--content'></div> <div class='popover-navigation lstutorial__template--navigation'> <div class='btn-group col-xs-8' role='group' aria-label='...'> <button class='btn btn-default col-xs-6' data-role='prev'>".gT('Previous')."</button> <button class='btn btn-primary col-xs-6' data-role='next'>".gT('Next')."</button> </div> <div class='col-xs-4'> <button class='btn btn-warning' data-role='end'>".gT('End tour')."</button> </div> </div></div>",
'onShown' => "(function(tour){ console.ls.log($('#notif-container').children()); $('#notif-container').children().remove(); })",
'onStart' => "(function(){var domaintobe=LS.data.baseUrl+(LS.data.urlFormat == 'path' ? '/admin/index' : '?r=admin/index'); if(window.location.href!=domaintobe){window.location.href=domaintobe;} })"
)),
'title' => 'First start tour',
'icon' => 'fa-rocket'
]);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>334), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 335) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update( '{{tutorial_entries}}', [
'settings' => json_encode(array(
'path' => ['/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}']],
'element' => '#sidebar',
'placement' => 'right',
'redirect' => false,
'prev' => '-1',
'onShow' => "(function(tour){
return Promise.resolve(tour);
})"
))
], 'teid=9');
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>335), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 336) {
$oTransaction = $oDB->beginTransaction();
$oDB->createCommand()->update( '{{tutorials}}', [
'settings' => json_encode(array(
'keyboard' => false,
'template' => "<div class='popover tour lstutorial__template--mainContainer'> <div class='arrow'></div> <h3 class='popover-title lstutorial__template--title'></h3> <div class='popover-content lstutorial__template--content'></div> <div class='popover-navigation lstutorial__template--navigation'> <div class='btn-group col-xs-8' role='group' aria-label='...'> <button class='btn btn-default col-xs-6' data-role='prev'>".gT('Previous')."</button> <button class='btn btn-primary col-xs-6' data-role='next'>".gT('Next')."</button> </div> <div class='col-xs-4'> <button class='btn btn-warning' data-role='end'>".gT('End tour')."</button> </div> </div></div>",
'onShown' => "(function(tour){ console.ls.log($('#notif-container').children()); $('#notif-container').children().remove(); })",
'onStart' => "(function(){var domaintobe=LS.data.baseUrl+(LS.data.urlFormat == 'path' ? '/admin/index' : '?r=admin/index'); if(window.location.href!=domaintobe){window.location.href=domaintobe;} })"
)),
], 'tid=1');
$oDB->createCommand()->update( '{{tutorial_entries}}', [
'settings' => json_encode(array (
'element' => '#lime-logo',
'path' => '/admin/index',
'placement' => 'bottom',
'redirect' => false,
'onShow' => "(function(tour){ $('#welcomeModal').modal('hide'); })"
))
], 'teid=1');
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>336), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 337) {
$oTransaction = $oDB->beginTransaction();
resetTutorials337($oDB);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>337), "stg_name='DBVersion'");
$oTransaction->commit();
}
if ($iOldDBVersion < 338) {
$oTransaction = $oDB->beginTransaction();
$rowToRemove = $oDB->createCommand()->select("position, id")->from("{{boxes}}")->where('ico=:ico',[':ico' => 'templates'])->queryRow();
$position = 6;
if($rowToRemove !== false){
$oDB->createCommand()->delete("{{boxes}}", 'id=:id', [':id' => $rowToRemove['id']]);
$position = $rowToRemove['position'];
}
$oDB->createCommand()->insert("{{boxes}}", ['position' => $position, 'url' => 'admin/themeoptions', 'title' => 'Themes', 'ico' => 'templates', 'desc' => 'Themes', 'page' => 'welcome', 'usergroup' => '-2']);
$oDB->createCommand()->update('{{settings_global}}', array('stg_value'=>338), "stg_name='DBVersion'");
$oTransaction->commit();
}
} catch (Exception $e) {
Yii::app()->setConfig('Updating', false);
$oTransaction->rollback();
// Activate schema caching
$oDB->schemaCachingDuration = 3600;
// Load all tables of the application in the schema
$oDB->schema->getTables();
// clear the cache of all loaded tables
$oDB->schema->refresh();
//echo '<br /><br />'.gT('An non-recoverable error happened during the update. Error details:')."<p>".htmlspecialchars($e->getMessage()).'</p><br />';
Yii::app()->user->setFlash('error', gT('An non-recoverable error happened during the update. Error details:')."<p>".htmlspecialchars($e->getMessage()).'</p><br />');
return false;
}
// Activate schema cache first - otherwise it won't be refreshed!
$oDB->schemaCachingDuration = 3600;
// Load all tables of the application in the schema
$oDB->schema->getTables();
// clear the cache of all loaded tables
$oDB->schema->refresh();
$oDB->active = false;
$oDB->active = true;
Yii::app()->db->schema->refresh();
// Force User model to refresh meta data (for updates from very old versions)
User::model()->refreshMetaData();
Survey::model()->refreshMetaData();
Notification::model()->refreshMetaData();
// Inform superadmin about update
$superadmins = User::model()->getSuperAdmins();
$currentDbVersion = $oDB->createCommand()->select('stg_value')->from('{{settings_global}}')->where("stg_name=:stg_name", array('stg_name'=>'DBVersion'))->queryRow();
Notification::broadcast(array(
'title' => gT('Database update'),
'message' => sprintf(gT('The database has been updated from version %s to version %s.'), $iOldDBVersion, $currentDbVersion['stg_value'])
), $superadmins);
fixLanguageConsistencyAllSurveys();
Yii::app()->setConfig('Updating', false);
return true;
}
/**
* @param $oDB
*
* @return void
*/
function resetTutorials337($oDB){
$oDB->createCommand()->truncateTable('{{tutorials}}');
$oDB->createCommand()->insert('{{tutorials}}', array(
'tid' => 1,
'name' => 'firstStartTour',
'title' => 'First start tour',
'icon' => 'fa-rocket',
'description' => 'The first start tour to get your first feeling into LimeSurvey',
'active' => 1,
'settings' => json_encode(array(
'keyboard' => false,
'orphan' => true,
'template' => "<div class='popover tour lstutorial__template--mainContainer'> <div class='arrow'></div> <h3 class='popover-title lstutorial__template--title'></h3> <div class='popover-content lstutorial__template--content'></div> <div class='popover-navigation lstutorial__template--navigation'> <div class='btn-group col-xs-8' role='group' aria-label='...'> <button class='btn btn-default col-xs-6' data-role='prev'>".gT('Previous')."</button> <button class='btn btn-primary col-xs-6' data-role='next'>".gT('Next')."</button> </div> <div class='col-xs-4'> <button class='btn btn-warning' data-role='end'>".gT('End tour')."</button> </div> </div></div>",
'onShown' => "(function(tour){ console.ls.log($('#notif-container').children()); $('#notif-container').children().remove(); })",
'onEnd' => "(function(tour){window.location.reload();})",
'endOnOrphan' => true,
)),
'permission' => 'survey',
'permission_grade' => 'create'
));
$oDB->createCommand()->truncateTable('{{tutorial_entries}}');
$oDB->createCommand()->truncateTable('{{tutorial_entry_relation}}');
$contentArrays = array(
array(
'teid' => 1,
'ordering' => 1,
'title' => 'Welcome to LimeSurvey!',
'content' => "This tour will help you to easily get a basic understanding of LimeSurvey."."<br/>"
."We would like to help you with a quick tour of the most essential functions and features.",
'settings' => json_encode(array (
'element' => '#lime-logo',
'path' => ['/admin/index'],
'placement' => 'bottom',
'redirect' => true,
'onShow' => "(function(tour){ $('#welcomeModal').modal('hide'); })"
))
),
array(
'teid' => 2,
'ordering' => 2,
'title' => 'The basic functions',
'content' => "The three top boxes are the most basic functions of LimeSurvey."."<br/>"
."From left to right it should be 'Create survey', 'List surveys' and 'Global settings'. Best we start by creating a survey."
.'<p class="alert bg-warning">'."Click on the 'Create survey' box - or 'Next' in this tutorial".'</p>',
'settings' => json_encode(array(
'element' => '.selector__create_survey',
'path' => ['/admin/index'],
'reflex' => true,
'onShow' => "(function(tour){ $('#welcomeModal').modal('hide'); })",
'onNext' => "(function(tour){
tour.setCurrentStep(2);
return new Promise(function(res,rej){});
})",
))
),
array(
'teid' => 3,
'ordering' => 3,
'title' => 'The survey title',
'content' => "This is the title of your survey."."<br/>"
."Your participants will see this title in the browser's title bar and on the welcome screen."
."<p class='bg-warning alert'>"."You have to put in at least a title for the survey to be saved.".'</p>',
'settings' => json_encode(array(
'path' => ['/admin/survey/sa/newsurvey'],
'element' => '#surveyls_title',
'redirect' => true,
'prev' => '-1',
))
),
array(
'teid' => 4,
'ordering' => 4,
'title' => 'The survey description',
'content' => "In this field you may type a short description of your survey."."<br/>"
."The text inserted here will be displayed on the welcome screen, which is the first thing that your respondents will see when they access your survey..".' '
."Describe your survey, but do not ask any question yet.",
'settings' => json_encode(array(
'element' => '#cke_description',
'path' => ['/admin/survey/sa/newsurvey'],
'placement' => 'top',
'redirect' => false,
))
),
array(
'teid' => 5,
'ordering' => 5,
'title' => 'Create a sample question and question group',
'content' => "We will be creating a question group and a question in this tutorial. There is need to automatically create it.",
'settings' => json_encode(array(
'element' => '.bootstrap-switch-id-createsample',
'path' => ['/admin/survey/sa/newsurvey'],
'redirect' => false,
))
),
array(
'teid' => 6,
'ordering' => 6,
'title' => 'The welcome message',
'content' => "This message is shown directly below the survey description on the welcome page. You may leave this blank for now but it is a good way to introduce your participants to the survey.",
'settings' => json_encode(array(
'element' => '#cke_welcome',
'placement' => 'top',
'path' => ['/admin/survey/sa/newsurvey'],
'redirect' => false,
))
),
array(
'teid' => 7,
'ordering' => 7,
'title' => 'The end message',
'content' => "This message is shown at the end of your survey to every participant. It's a great way to say thank you or give some links or hints where to go next.",