blob: 949ec58e6ee28e07607ea94ff0a2d669d1bf9293 (
plain)
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
|
<?php
class ChangeCwConfig extends Migration
{
public function description()
{
return 'change courseware config';
}
public function up()
{
$db = DBManager::get();
$query = "UPDATE `config` SET `value` = '{}', `type` = 'array' WHERE `config`.`field` = 'COURSEWARE_SEQUENTIAL_PROGRESSION'";
$db->exec($query);
$query = "UPDATE `config` SET `value` = '{}', `type` = 'array' WHERE `config`.`field` = 'COURSEWARE_EDITING_PERMISSION'";
$db->exec($query);
$update_permission = $db->prepare("UPDATE `config_values` SET `value` = ? WHERE `field` = 'COURSEWARE_EDITING_PERMISSION' AND `range_id` = ?");
$find_root = $db->prepare("SELECT * FROM `cw_structural_elements` WHERE `parent_id` IS NULL AND `range_id` = ? ");
// get all COURSEWARE_EDITING_PERMISSION
$stmt = $db->prepare("SELECT * FROM `config_values` WHERE `field` = 'COURSEWARE_EDITING_PERMISSION'");
$stmt->execute();
$cw_permissions = $stmt->fetchAll();
foreach ($cw_permissions as $permission) {
$find_root->execute([$permission['range_id']]);
$root = $find_root->fetchAll();
$value = json_encode([$root[0]['id'] => $permission['value']], true);
$update_permission->execute([$value, $permission['range_id']]);
}
$update_progression = $db->prepare("UPDATE `config_values` SET `value` = ? WHERE `field` = 'COURSEWARE_SEQUENTIAL_PROGRESSION' AND `range_id` = ?");
// get all COURSEWARE_SEQUENTIAL_PROGRESSION
$stmt = $db->prepare("SELECT * FROM `config_values` WHERE `field` = 'COURSEWARE_SEQUENTIAL_PROGRESSION'");
$stmt->execute();
$cw_progressions = $stmt->fetchAll();
foreach ($cw_progressions as $progression) {
$find_root->execute([$progression['range_id']]);
$root = $find_root->fetchAll();
$value = json_encode([$root[0]['id'] => $progression['value']], true);
$update_progression->execute([$value, $progression['range_id']]);
}
}
public function down()
{
$db = \DBManager::get();
}
}
|