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
$tbl_learnpath = Database::get_course_table(TABLE_LP_MAIN);
$table = Database::get_course_table(TABLE_LP_MAIN);
// Get current prerequisite
$sql = "SELECT id, prerequisite, subscribe_users, publicated_on, expired_on
FROM $tbl_learnpath
FROM $table
WHERE iid = $lp_id";
$rs = Database::query($sql);
$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(
api_get_session_id(),
$this->get_course_int_id(),

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

@ -860,10 +860,6 @@ switch ($action) {
}
break;
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 (!$lp_found) {
require 'lp_list.php';

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

@ -2799,7 +2799,7 @@ class CourseRestorer
// if is an sco
$old_prerequisite[$new_item_id] = $item['prerequisite'];
} 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