From fbbfb3d7a79be1d6a0e7e5a267fea6df06263c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Fri, 2 Sep 2016 11:44:00 -0500 Subject: [PATCH] Added all the moodle docs to a new sub dir "Moodle Docs" in documents --- main/inc/lib/MoodleImport.php | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/main/inc/lib/MoodleImport.php b/main/inc/lib/MoodleImport.php index e1a9235eec..2405c7a5f8 100644 --- a/main/inc/lib/MoodleImport.php +++ b/main/inc/lib/MoodleImport.php @@ -36,12 +36,27 @@ class MoodleImport } $folder = api_get_unique_id(); - $destinationDir = api_get_path(SYS_ARCHIVE_PATH).$folder; + $destinationDir = api_get_path(SYS_ARCHIVE_PATH) . $folder; $coursePath = api_get_course_path(); + $sessionId = api_get_session_id(); + $groupId = api_get_group_id(); + $documentPath = api_get_path(SYS_COURSE_PATH) . $coursePath . '/document'; $courseInfo = api_get_course_info(); mkdir($destinationDir, api_get_permissions_for_new_directories(), true); + $newFolderData = create_unexisting_directory( + $courseInfo, + api_get_user_id(), + $sessionId, + $groupId, + null, + $documentPath, + '/moodle', + 'Moodle Docs', + 0 + ); + $package->extract( PCLZIP_OPT_PATH, $destinationDir @@ -145,7 +160,7 @@ class MoodleImport $questionInstance->updateTitle($moduleValues['question_instances'][$index]['name']); // Replace the path from @@PLUGINFILE@@ to a correct chamilo path - $moduleValues['question_instances'][$index]['questiontext'] = str_replace('@@PLUGINFILE@@', '/courses/' . $coursePath . '/document', $moduleValues['question_instances'][$index]['questiontext']); + $moduleValues['question_instances'][$index]['questiontext'] = str_replace('@@PLUGINFILE@@', '/courses/' . $coursePath . '/document/moodle', $moduleValues['question_instances'][$index]['questiontext']); $questionInstance->updateDescription($moduleValues['question_instances'][$index]['questiontext']); $questionInstance->updateLevel(1); $questionInstance->updateCategory(0); @@ -192,7 +207,7 @@ class MoodleImport DocumentManager::upload_document( $files, - '/', + '/moodle', $fileInfo['title'], '', null, @@ -243,7 +258,7 @@ class MoodleImport DocumentManager::upload_document( $files, - '/', + '/moodle', isset($fileInfo['title']) ? $fileInfo['title'] : pathinfo($fileInfo['filename'], PATHINFO_FILENAME), '', null, @@ -605,7 +620,7 @@ class MoodleImport $coursePath = api_get_course_path(); - $placeholder = str_replace('@@PLUGINFILE@@', '/courses/' . $coursePath . '/document', $currentQuestion['questiontext']); + $placeholder = str_replace('@@PLUGINFILE@@', '/courses/' . $coursePath . '/document/moodle', $currentQuestion['questiontext']); $optionsValues = []; @@ -850,7 +865,7 @@ class MoodleImport $currentAnswers = $correctAnswer.$othersAnswers; $currentAnswers = '['.substr($currentAnswers, 0, -1).'] '; - $answer['questiontext'] = str_replace('@@PLUGINFILE@@', '/courses/' . $coursePath . '/document', $answer['questiontext']); + $answer['questiontext'] = str_replace('@@PLUGINFILE@@', '/courses/' . $coursePath . '/document/moodle', $answer['questiontext']); $placeholder .= '

' . strip_tags($answer['questiontext']).' '.$currentAnswers . '

'; }