Fix LP export to chamilo format see BT#10885

pull/2500/head
jmontoyaa 8 years ago
parent d8d9088e54
commit 92059474b2
  1. 40
      main/lp/learnpath.class.php
  2. 8
      main/lp/learnpathItem.class.php
  3. 4
      main/lp/lp_controller.php
  4. 2
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/CkEditor.php
  5. 2
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php

@ -2423,10 +2423,10 @@ class learnpath
} }
// @todo remove this query and load the row info as a parameter // @todo remove this query and load the row info as a parameter
$tbl_learnpath = Database::get_course_table(TABLE_LP_MAIN); $table = Database::get_course_table(TABLE_LP_MAIN);
// Get current prerequisite // Get current prerequisite
$sql = "SELECT id, prerequisite, subscribe_users, publicated_on, expired_on $sql = "SELECT id, prerequisite, subscribe_users, publicated_on, expired_on
FROM $tbl_learnpath FROM $table
WHERE iid = $lp_id"; WHERE iid = $lp_id";
$rs = Database::query($sql); $rs = Database::query($sql);
$now = time(); $now = time();
@ -13031,6 +13031,42 @@ EOD;
} }
} }
$courseInfo = api_get_course_info();
foreach ($itemList['document'] as $documentId) {
$documentInfo = DocumentManager::get_document_data_by_id($documentId, api_get_course_id());
$items = DocumentManager::get_resources_from_source_html(
$documentInfo['absolute_path'],
true,
TOOL_DOCUMENT
);
if (!empty($items)) {
foreach ($items as $item) {
// Get information about source url
$url = $item[0]; // url
$scope = $item[1]; // scope (local, remote)
$type = $item[2]; // type (rel, abs, url)
$origParseUrl = parse_url($url);
$realOrigPath = isset($origParseUrl['path']) ? $origParseUrl['path'] : null;
if ($scope == 'local') {
if ($type == 'abs' || $type == 'rel') {
$documentFile = strstr($realOrigPath, 'document');
if (strpos($realOrigPath, $documentFile) !== false) {
$documentFile = str_replace('document', '', $documentFile);
$itemDocumentId = DocumentManager::get_document_id($courseInfo, $documentFile);
// Document found! Add it to the list
if ($itemDocumentId) {
$itemList['document'][] = $itemDocumentId;
}
}
}
}
}
}
}
$courseBuilder->build_documents( $courseBuilder->build_documents(
api_get_session_id(), api_get_session_id(),
$this->get_course_int_id(), $this->get_course_int_id(),

@ -1046,17 +1046,15 @@ class learnpathItem
if ($recursivity > $max) { if ($recursivity > $max) {
return []; return [];
} }
if (!isset($type)) {
$type = $this->get_type(); $type = empty($type) ? $this->get_type() : $type;
}
if (!isset($abs_path)) { if (!isset($abs_path)) {
$path = $this->get_file_path(); $path = $this->get_file_path();
$abs_path = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$path; $abs_path = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$path;
} }
$files_list = []; $files_list = [];
$type = $this->get_type();
switch ($type) { switch ($type) {
case TOOL_DOCUMENT: case TOOL_DOCUMENT:
case TOOL_QUIZ: case TOOL_QUIZ:

@ -860,10 +860,6 @@ switch ($action) {
} }
break; break;
case 'export_to_course_build': case 'export_to_course_build':
if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) {
api_not_allowed();
}
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
if (!$lp_found) { if (!$lp_found) {
require 'lp_list.php'; require 'lp_list.php';

@ -97,6 +97,8 @@ class CkEditor extends Editor
/** /**
* @param array $templates * @param array $templates
*
* @return string
*/ */
public function formatTemplates($templates) public function formatTemplates($templates)
{ {

@ -2799,7 +2799,7 @@ class CourseRestorer
// if is an sco // if is an sco
$old_prerequisite[$new_item_id] = $item['prerequisite']; $old_prerequisite[$new_item_id] = $item['prerequisite'];
} else { } else {
$old_prerequisite[$new_item_id] = $new_item_ids[$item['prerequisite']]; $old_prerequisite[$new_item_id] = isset($new_item_ids[$item['prerequisite']]) ? $new_item_ids[$item['prerequisite']] : '';
} }
} }

Loading…
Cancel
Save