|
|
|
@ -1588,31 +1588,6 @@ class learnpath |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Static admin function exporting a learnpath into a zip file |
|
|
|
|
* @param string Export type (scorm, zip, cd) |
|
|
|
|
* @param string Course code |
|
|
|
|
* @param integer Learnpath ID |
|
|
|
|
* @param string Zip file name |
|
|
|
|
* @return string Zip file path (or false on error) |
|
|
|
|
*/ |
|
|
|
|
public function export_lp($type, $course, $id, $zipname) |
|
|
|
|
{ |
|
|
|
|
if (empty($type) || empty($course) || empty($id) || empty($zipname)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$url = ''; |
|
|
|
|
switch ($type) { |
|
|
|
|
case 'scorm': |
|
|
|
|
break; |
|
|
|
|
case 'zip': |
|
|
|
|
break; |
|
|
|
|
case 'cdrom': |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return $url; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets all the chapters belonging to the same parent as the item/chapter given |
|
|
|
|
* Can also be called as abstract method |
|
|
|
@ -1814,8 +1789,7 @@ class learnpath |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the first element URL. |
|
|
|
|
* @return string URL to load into the viewer |
|
|
|
|
* Sets the first element URL. |
|
|
|
|
*/ |
|
|
|
|
public function first() |
|
|
|
|
{ |
|
|
|
@ -2835,7 +2809,11 @@ class learnpath |
|
|
|
|
foreach ($ids as $id) { |
|
|
|
|
$id = trim($id); |
|
|
|
|
if (isset ($this->refs_list[$id])) { |
|
|
|
|
$prereq = preg_replace('/[^a-zA-Z_0-9]('.$id.')[^a-zA-Z_0-9]/', 'ITEM_'.$this->refs_list[$id], $prereq); |
|
|
|
|
$prereq = preg_replace( |
|
|
|
|
'/[^a-zA-Z_0-9]('.$id.')[^a-zA-Z_0-9]/', |
|
|
|
|
'ITEM_'.$this->refs_list[$id], |
|
|
|
|
$prereq |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3018,7 +2996,7 @@ class learnpath |
|
|
|
|
while ($row = Database::fetch_array($res)) { |
|
|
|
|
$list[] = array( |
|
|
|
|
'order_id' => ($row['order_id'] + 1), |
|
|
|
|
'objective_id' => urldecode($row['objective_id']), // urldecode() because they often have %2F or stuff like that. |
|
|
|
|
'objective_id' => urldecode($row['objective_id']), // urldecode() because they often have %2F |
|
|
|
|
'score_raw' => $row['score_raw'], |
|
|
|
|
'score_max' => $row['score_max'], |
|
|
|
|
'score_min' => $row['score_min'], |
|
|
|
@ -3065,6 +3043,7 @@ class learnpath |
|
|
|
|
/** |
|
|
|
|
* Generate and return the table of contents for this learnpath. The JS |
|
|
|
|
* table returned is used inside of scorm_api.php |
|
|
|
|
* @param strin $varname |
|
|
|
|
* @return string A JS array vairiable construction |
|
|
|
|
*/ |
|
|
|
|
public function get_items_details_as_js($varname = 'olms.lms_item_types') |
|
|
|
@ -3180,9 +3159,10 @@ class learnpath |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Uses the table generated by get_toc() and returns an HTML-formatted string ready to display |
|
|
|
|
* @param array $toc_list |
|
|
|
|
* @return string HTML TOC ready to display |
|
|
|
|
*/ |
|
|
|
|
public function getListArrayToc($toc_list = null) |
|
|
|
|
public function getListArrayToc($toc_list = []) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_html_toc()', 0); |
|
|
|
@ -3289,8 +3269,8 @@ class learnpath |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $html; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the learnpath maker name - generally the editor's name |
|
|
|
|
* @return string Learnpath maker name |
|
|
|
@ -3756,21 +3736,6 @@ class learnpath |
|
|
|
|
return $has; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Logs a message into a file |
|
|
|
|
* @param string Message to log |
|
|
|
|
* @return boolean True on success, false on error or if msg empty |
|
|
|
|
*/ |
|
|
|
|
public function log($msg) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('New LP - In learnpath::log()', 0); |
|
|
|
|
} |
|
|
|
|
// TODO |
|
|
|
|
$this->error .= $msg; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Moves an item up and down at its level |
|
|
|
|
* @param integer Item to move up and down |
|
|
|
@ -4192,7 +4157,7 @@ class learnpath |
|
|
|
|
* to normal users. |
|
|
|
|
* Can be used as abstract |
|
|
|
|
* @param integer Learnpath ID |
|
|
|
|
* @param string New visibility |
|
|
|
|
* @param string $set_visibility New visibility |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
public static function toggle_visibility($lp_id, $set_visibility = 1) |
|
|
|
@ -6546,7 +6511,7 @@ class learnpath |
|
|
|
|
* @param int $parentId |
|
|
|
|
* @param int $creatorId creator id |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public function create_document( |
|
|
|
|
$courseInfo, |
|
|
|
@ -6792,6 +6757,7 @@ class learnpath |
|
|
|
|
* Displays the selected item, with a panel for manipulating the item |
|
|
|
|
* @param int $item_id |
|
|
|
|
* @param string $msg |
|
|
|
|
* @param bool $show_actions |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public function display_item($item_id, $msg = null, $show_actions = true) |
|
|
|
@ -8110,9 +8076,7 @@ class learnpath |
|
|
|
|
if (is_array($arrLP)) { |
|
|
|
|
reset($arrLP); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$arrHide = array(); |
|
|
|
|
|
|
|
|
|
// POSITION |
|
|
|
|
for ($i = 0; $i < count($arrLP); $i++) { |
|
|
|
|
if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { |
|
|
|
@ -8290,7 +8254,6 @@ class learnpath |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM $tbl_lp_item |
|
|
|
|
WHERE c_id = $course_id AND lp_id = ".$this->lp_id; |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$arrLP = array(); |
|
|
|
|
while ($row = Database::fetch_array($result)) { |
|
|
|
@ -8505,7 +8468,9 @@ class learnpath |
|
|
|
|
if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir' && |
|
|
|
|
$arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM |
|
|
|
|
) { |
|
|
|
|
if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
|
|
|
if (isset($extra_info['previous_item_id']) && |
|
|
|
|
$extra_info['previous_item_id'] == $arrLP[$i]['id'] |
|
|
|
|
) { |
|
|
|
|
$s_selected_position = $arrLP[$i]['id']; |
|
|
|
|
} elseif ($action == 'add') { |
|
|
|
|
$s_selected_position = $arrLP[$i]['id']; |
|
|
|
@ -8517,7 +8482,9 @@ class learnpath |
|
|
|
|
if (!$no_display_add) { |
|
|
|
|
$item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null; |
|
|
|
|
$edit = isset($_GET['edit']) ? $_GET['edit'] : null; |
|
|
|
|
if ($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true') { |
|
|
|
|
if ($extra_info == 'new' || $item_type == TOOL_DOCUMENT || |
|
|
|
|
$item_type == TOOL_LP_FINAL_ITEM || $edit == 'true' |
|
|
|
|
) { |
|
|
|
|
if (isset ($_POST['content'])) { |
|
|
|
|
$content = stripslashes($_POST['content']); |
|
|
|
|
} elseif (is_array($extra_info)) { |
|
|
|
@ -9511,7 +9478,6 @@ class learnpath |
|
|
|
|
{ |
|
|
|
|
$course_info = api_get_course_info(); |
|
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
|
|
|
|
|
|
$documentTree = DocumentManager::get_document_preview( |
|
|
|
|
$course_info, |
|
|
|
|
$this->lp_id, |
|
|
|
@ -9762,7 +9728,7 @@ class learnpath |
|
|
|
|
|
|
|
|
|
$linksHtmlCode = |
|
|
|
|
'<script> |
|
|
|
|
function toggle_tool(tool, id){ |
|
|
|
|
function toggle_tool(tool, id) { |
|
|
|
|
if(document.getElementById(tool+"_"+id+"_content").style.display == "none"){ |
|
|
|
|
document.getElementById(tool+"_"+id+"_content").style.display = "block"; |
|
|
|
|
document.getElementById(tool+"_"+id+"_opener").src = "' . Display::returnIconPath('remove.gif').'"; |
|
|
|
@ -10004,7 +9970,6 @@ class learnpath |
|
|
|
|
* @TODO The method might be redefined later on in the scorm class itself to avoid |
|
|
|
|
* creating a SCORM structure if there is one already. However, if the initial SCORM |
|
|
|
|
* path has been modified, it should use the generic method here below. |
|
|
|
|
* @TODO link this function with the export_lp() function in the same class |
|
|
|
|
* @param string Optional name of zip file. If none, title of learnpath is |
|
|
|
|
* domesticated and trailed with ".zip" |
|
|
|
|
* @return string Returns the zip package string, or null if error |
|
|
|
@ -10356,7 +10321,6 @@ class learnpath |
|
|
|
|
}*/ |
|
|
|
|
$file_path = $_SERVER['DOCUMENT_ROOT'].$doc_info[0]; |
|
|
|
|
$file_path = str_replace('//', '/', $file_path); |
|
|
|
|
|
|
|
|
|
$abs_path = api_get_path(SYS_PATH).str_replace(api_get_path(WEB_PATH), '', $doc_info[0]); |
|
|
|
|
$current_dir = dirname($abs_path); |
|
|
|
|
$current_dir = str_replace('\\', '/', $current_dir); |
|
|
|
@ -10379,13 +10343,10 @@ class learnpath |
|
|
|
|
$current_dir = str_replace('\\', '/', $current_dir); |
|
|
|
|
$file_path = realpath($current_dir.$doc_info[0]); |
|
|
|
|
$file_path = str_replace('\\', '/', $file_path); |
|
|
|
|
|
|
|
|
|
//error_log($file_path.' <-> '.$main_path,0); |
|
|
|
|
if (strstr($file_path, $main_path) !== false) { |
|
|
|
|
// The calculated real path is really inside Chamilo's root path. |
|
|
|
|
// Reduce file path to what's under the DocumentRoot. |
|
|
|
|
$file_path = substr($file_path, strlen($root_path)); |
|
|
|
|
//error_log('Reduced path: '.$file_path, 0); |
|
|
|
|
$zip_files_abs[] = $file_path; |
|
|
|
|
$link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); |
|
|
|
|
$my_dep_file->setAttribute('href', 'document/'.$file_path); |
|
|
|
@ -11091,7 +11052,6 @@ EOD; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
@ -11330,6 +11290,7 @@ EOD; |
|
|
|
|
*/ |
|
|
|
|
public static function moveUpCategory($id) |
|
|
|
|
{ |
|
|
|
|
$id = (int) $id; |
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
/** @var CLpCategory $item */ |
|
|
|
|
$item = $em->find('ChamiloCourseBundle:CLpCategory', $id); |
|
|
|
@ -11346,6 +11307,7 @@ EOD; |
|
|
|
|
*/ |
|
|
|
|
public static function moveDownCategory($id) |
|
|
|
|
{ |
|
|
|
|
$id = (int) $id; |
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
/** @var CLpCategory $item */ |
|
|
|
|
$item = $em->find('ChamiloCourseBundle:CLpCategory', $id); |
|
|
|
@ -11404,6 +11366,7 @@ EOD; |
|
|
|
|
*/ |
|
|
|
|
public static function getCategory($id) |
|
|
|
|
{ |
|
|
|
|
$id = (int) $id; |
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
$item = $em->find('ChamiloCourseBundle:CLpCategory', $id); |
|
|
|
|
|
|
|
|
@ -11920,7 +11883,7 @@ EOD; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a forum for this learning path |
|
|
|
|
* @param type $forumCategoryId |
|
|
|
|
* @param int $forumCategoryId |
|
|
|
|
* @return int The forum ID if was created. Otherwise return false |
|
|
|
|
*/ |
|
|
|
|
public function createForum($forumCategoryId) |
|
|
|
|