123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- exit;
- require_once '../../main/inc/global.inc.php';
- $courseId = 0;
- $lpId = 0;
- $tblCLp = Database::get_course_table(TABLE_LP_MAIN);
- $tblCLpItem = Database::get_course_table(TABLE_LP_ITEM);
- $course = api_get_course_info_by_id($courseId);
- $lp = Database::fetch_assoc(
- Database::query("SELECT path FROM $tblCLp WHERE c_id = $courseId AND id = $lpId")
- );
- $items = Database::store_result(
- Database::query("SELECT id, c_id, lp_id, path FROM $tblCLpItem WHERE c_id = $courseId AND lp_id = $lpId"),
- 'ASSOC'
- );
- $scormDir = api_get_path(SYS_COURSE_PATH) . $course['path'] . '/scorm/' . $lp['path'] . '/';
- foreach ($items as $item) {
- $fixedDirectory = "document/learning_path/{$lp['path']}/";
- $oldPath = $scormDir . $item['path'];
- $newPath = $scormDir . str_replace('document/', $fixedDirectory, $item['path']);
- if (!file_exists($oldPath) && file_exists($newPath)) {
- $sql = "
- UPDATE $tblCLpItem
- SET path = REPLACE(path, 'document/', '$fixedDirectory')
- WHERE c_id = {$item['c_id']} AND lp_id = {$item['lp_id']} AND id = {$item['id']}
- ";
- Database::query($sql);
- echo "Executing: $sql" . PHP_EOL;
- }
- }
|