|
|
|
|
@ -356,7 +356,7 @@ class learnpath |
|
|
|
|
FROM $itemViewTable |
|
|
|
|
WHERE |
|
|
|
|
c_id = $course_id AND |
|
|
|
|
lp_view_id = ".$this->lp_view_id." AND |
|
|
|
|
lp_view_id = ".$this->get_view_id()." AND |
|
|
|
|
lp_item_id IN ('".$lp_item_id_list_to_string."') |
|
|
|
|
ORDER BY view_count DESC "; |
|
|
|
|
|
|
|
|
|
@ -1604,7 +1604,7 @@ class learnpath |
|
|
|
|
/** |
|
|
|
|
* Gets all the chapters belonging to the same parent as the item/chapter given |
|
|
|
|
* Can also be called as abstract method. |
|
|
|
|
* |
|
|
|
|
* @deprecated not used |
|
|
|
|
* @param int $id Item ID |
|
|
|
|
* |
|
|
|
|
* @return array A list of all the "brother items" (or an empty array on failure) |
|
|
|
|
@ -1612,9 +1612,6 @@ class learnpath |
|
|
|
|
public function getSiblingDirectories($id) |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::getSiblingDirectories()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($id) || $id != strval(intval($id))) { |
|
|
|
|
return []; |
|
|
|
|
@ -1649,7 +1646,7 @@ class learnpath |
|
|
|
|
/** |
|
|
|
|
* Gets all the items belonging to the same parent as the item given |
|
|
|
|
* Can also be called as abstract method. |
|
|
|
|
* |
|
|
|
|
* @deprecated not used |
|
|
|
|
* @param int $id Item ID |
|
|
|
|
* |
|
|
|
|
* @return array A list of all the "brother items" (or an empty array on failure) |
|
|
|
|
@ -1657,9 +1654,6 @@ class learnpath |
|
|
|
|
public function get_brother_items($id) |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_brother_items('.$id.')', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($id) || $id != strval(intval($id))) { |
|
|
|
|
return []; |
|
|
|
|
@ -1722,9 +1716,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_complete_items_count($failedStatusException = false) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_complete_items_count()', 0); |
|
|
|
|
} |
|
|
|
|
$i = 0; |
|
|
|
|
$completedStatusList = [ |
|
|
|
|
'completed', |
|
|
|
|
@ -1757,14 +1748,8 @@ class learnpath |
|
|
|
|
public function get_current_item_id() |
|
|
|
|
{ |
|
|
|
|
$current = 0; |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_current_item_id()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->current)) { |
|
|
|
|
$current = $this->current; |
|
|
|
|
} |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('In learnpath::get_current_item_id() - Returning '.$current, 0); |
|
|
|
|
$current = (int) $this->current; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $current; |
|
|
|
|
@ -1792,10 +1777,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_total_items_count() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_total_items_count()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return count($this->items); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1806,9 +1787,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function getTotalItemsCountWithoutDirs() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::getTotalItemsCountWithoutDirs()', 0); |
|
|
|
|
} |
|
|
|
|
$total = 0; |
|
|
|
|
$typeListNotToCount = self::getChapterTypes(); |
|
|
|
|
foreach ($this->items as $temp2) { |
|
|
|
|
@ -1912,7 +1890,7 @@ class learnpath |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$info = ''; |
|
|
|
|
$item_id = intval($item_id); |
|
|
|
|
$item_id = (int) $item_id; |
|
|
|
|
|
|
|
|
|
if (!empty($item_id) && is_object($this->items[$item_id])) { |
|
|
|
|
//if item is defined, return values from DB |
|
|
|
|
@ -1975,10 +1953,10 @@ class learnpath |
|
|
|
|
public function get_id() |
|
|
|
|
{ |
|
|
|
|
if (!empty($this->lp_id)) { |
|
|
|
|
return $this->lp_id; |
|
|
|
|
} else { |
|
|
|
|
return 0; |
|
|
|
|
return (int) $this->lp_id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -1988,10 +1966,7 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_last() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_last()', 0); |
|
|
|
|
} |
|
|
|
|
//This is just in case the lesson doesn't cointain a valid scheme, just to avoid "Notices" |
|
|
|
|
// This is just in case the lesson doesn't cointain a valid scheme, just to avoid "Notices" |
|
|
|
|
if (count($this->ordered_items) > 0) { |
|
|
|
|
$this->index = count($this->ordered_items) - 1; |
|
|
|
|
|
|
|
|
|
@ -2030,9 +2005,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_navigation_bar($idBar = null, $display = null) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_navigation_bar()', 0); |
|
|
|
|
} |
|
|
|
|
if (empty($idBar)) { |
|
|
|
|
$idBar = 'control-top'; |
|
|
|
|
} |
|
|
|
|
@ -2287,10 +2259,10 @@ class learnpath |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// There is no previous item. |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('get_previous_index() - there was no previous index available, reusing '.$index, 0); |
|
|
|
|
} |
|
|
|
|
// There is no previous item. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $index; |
|
|
|
|
@ -2303,9 +2275,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_previous_item_id() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_previous_item_id()', 0); |
|
|
|
|
} |
|
|
|
|
$new_index = $this->get_previous_index(); |
|
|
|
|
|
|
|
|
|
return $this->ordered_items[$new_index]; |
|
|
|
|
@ -2805,14 +2774,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_progress_bar_mode() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_progress_bar_mode()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->progress_bar_mode)) { |
|
|
|
|
return $this->progress_bar_mode; |
|
|
|
|
} else { |
|
|
|
|
return '%'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return '%'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -2822,14 +2788,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_theme() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_theme()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->theme)) { |
|
|
|
|
return $this->theme; |
|
|
|
|
} else { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -2839,14 +2802,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_lp_session_id() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_lp_session_id()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->lp_session_id)) { |
|
|
|
|
return (int) $this->lp_session_id; |
|
|
|
|
} else { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -2856,14 +2816,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_preview_image() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_preview_image()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->preview_image)) { |
|
|
|
|
return $this->preview_image; |
|
|
|
|
} else { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -2909,14 +2866,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_author() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_author()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->author)) { |
|
|
|
|
return $this->author; |
|
|
|
|
} else { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -3053,9 +3007,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_items_status_list() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_items_status_list()', 0); |
|
|
|
|
} |
|
|
|
|
$list = []; |
|
|
|
|
foreach ($this->ordered_items as $item_id) { |
|
|
|
|
$list[] = [ |
|
|
|
|
@ -3245,9 +3196,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_toc() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('learnpath::get_toc()', 0); |
|
|
|
|
} |
|
|
|
|
$toc = []; |
|
|
|
|
foreach ($this->ordered_items as $item_id) { |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
@ -3282,16 +3230,10 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_items_details_as_js($varname = 'olms.lms_item_types') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_items_details_as_js()', 0); |
|
|
|
|
} |
|
|
|
|
$toc = $varname.' = new Array();'; |
|
|
|
|
foreach ($this->ordered_items as $item_id) { |
|
|
|
|
$toc .= $varname."['i$item_id'] = '".$this->items[$item_id]->get_type()."';"; |
|
|
|
|
} |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('In learnpath::get_items_details_as_js() - TOC array: '.print_r($toc, true), 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $toc; |
|
|
|
|
} |
|
|
|
|
@ -3306,15 +3248,9 @@ class learnpath |
|
|
|
|
public function get_type($get_name = false) |
|
|
|
|
{ |
|
|
|
|
$res = false; |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_type()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->type) && (!$get_name)) { |
|
|
|
|
$res = $this->type; |
|
|
|
|
} |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('In learnpath::get_type() - Returning '.($res ? $res : 'false'), 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $res; |
|
|
|
|
} |
|
|
|
|
@ -3410,9 +3346,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function getParentToc($tree) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_html_toc()', 0); |
|
|
|
|
} |
|
|
|
|
if (empty($tree)) { |
|
|
|
|
$tree = $this->get_toc(); |
|
|
|
|
} |
|
|
|
|
@ -3488,9 +3421,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function getChildrenToc($tree, $id, $parent = true) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_html_toc()', 0); |
|
|
|
|
} |
|
|
|
|
if (empty($tree)) { |
|
|
|
|
$tree = $this->get_toc(); |
|
|
|
|
} |
|
|
|
|
@ -3558,9 +3488,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function getListArrayToc($toc_list = []) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_html_toc()', 0); |
|
|
|
|
} |
|
|
|
|
if (empty($toc_list)) { |
|
|
|
|
$toc_list = $this->get_toc(); |
|
|
|
|
} |
|
|
|
|
@ -3673,16 +3600,14 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_maker() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_maker()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->maker)) { |
|
|
|
|
return $this->maker; |
|
|
|
|
} else { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the learnpath name/title. |
|
|
|
|
* |
|
|
|
|
@ -3690,14 +3615,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_name() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_name()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->name)) { |
|
|
|
|
return $this->name; |
|
|
|
|
} else { |
|
|
|
|
return 'N/A'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 'N/A'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -4061,9 +3983,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_view($attempt_num = 0) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_view()', 0); |
|
|
|
|
} |
|
|
|
|
$search = ''; |
|
|
|
|
// Use $attempt_num to enable multi-views management (disabled so far). |
|
|
|
|
if ($attempt_num != 0 && intval(strval($attempt_num)) == $attempt_num) { |
|
|
|
|
@ -4109,14 +4028,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_view_id() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_view_id()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->lp_view_id)) { |
|
|
|
|
return $this->lp_view_id; |
|
|
|
|
} else { |
|
|
|
|
return 0; |
|
|
|
|
return (int) $this->lp_view_id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -4126,10 +4042,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_update_queue() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_update_queue()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $this->update_queue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -4140,14 +4052,10 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function get_user_id() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_user_id()', 0); |
|
|
|
|
} |
|
|
|
|
if (!empty($this->user_id)) { |
|
|
|
|
return $this->user_id; |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
return (int) $this->user_id; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -4157,9 +4065,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function has_audio() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 1) { |
|
|
|
|
error_log('In learnpath::has_audio()', 0); |
|
|
|
|
} |
|
|
|
|
$has = false; |
|
|
|
|
foreach ($this->items as $i => $item) { |
|
|
|
|
if (!empty($this->items[$i]->audio)) { |
|
|
|
|
@ -4595,9 +4500,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function previous() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::previous()', 0); |
|
|
|
|
} |
|
|
|
|
$this->last = $this->get_current_item_id(); |
|
|
|
|
$this->items[$this->last]->save( |
|
|
|
|
false, |
|
|
|
|
@ -5167,7 +5069,7 @@ class learnpath |
|
|
|
|
error_log('Saving current item ('.$this->current.') for later review', 0); |
|
|
|
|
} |
|
|
|
|
$sql = "UPDATE $table SET |
|
|
|
|
last_item = ".intval($this->get_current_item_id())." |
|
|
|
|
last_item = ".$this->get_current_item_id()." |
|
|
|
|
WHERE |
|
|
|
|
c_id = $course_id AND |
|
|
|
|
lp_id = ".$this->get_id()." AND |
|
|
|
|
@ -5192,9 +5094,6 @@ class learnpath |
|
|
|
|
user_id = ".$this->get_user_id()." ".$session_condition; |
|
|
|
|
// Ignore errors as some tables might not have the progress field just yet. |
|
|
|
|
Database::query($sql); |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log($sql); |
|
|
|
|
} |
|
|
|
|
$this->progress_db = $progress; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -5254,10 +5153,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_encoding($enc = 'UTF-8') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_encoding()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$enc = api_refine_encoding_id($enc); |
|
|
|
|
if (empty($enc)) { |
|
|
|
|
$enc = api_get_system_encoding(); |
|
|
|
|
@ -5287,21 +5182,18 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_jslib($lib = '') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_jslib()', 0); |
|
|
|
|
} |
|
|
|
|
$lp = $this->get_id(); |
|
|
|
|
|
|
|
|
|
if ($lp != 0) { |
|
|
|
|
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lib = Database::escape_string($lib); |
|
|
|
|
$sql = "UPDATE $tbl_lp SET js_lib = '$lib' |
|
|
|
|
WHERE iid = $lp"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
|
|
|
|
|
return $res; |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -5313,9 +5205,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_maker($name = '') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_maker()', 0); |
|
|
|
|
} |
|
|
|
|
if (empty($name)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -5325,9 +5214,6 @@ class learnpath |
|
|
|
|
$sql = "UPDATE $table SET |
|
|
|
|
content_maker = '".Database::escape_string($this->maker)."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new content_maker : '.$this->maker, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5342,9 +5228,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_name($name = null) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_name()', 0); |
|
|
|
|
} |
|
|
|
|
if (empty($name)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -5355,9 +5238,6 @@ class learnpath |
|
|
|
|
$sql = "UPDATE $lp_table SET |
|
|
|
|
name = '".Database::escape_string($this->name)."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new name : '.$this->name, 0); |
|
|
|
|
} |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
// If the lp is visible on the homepage, change his name there. |
|
|
|
|
if (Database::affected_rows($result)) { |
|
|
|
|
@ -5372,9 +5252,9 @@ class learnpath |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -5464,18 +5344,12 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_theme($name = '') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_theme()', 0); |
|
|
|
|
} |
|
|
|
|
$this->theme = $name; |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
$sql = "UPDATE $table |
|
|
|
|
SET theme = '".Database::escape_string($this->theme)."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new theme : '.$this->theme, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5490,19 +5364,12 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_preview_image($name = '') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_preview_image()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->preview_image = $name; |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
$sql = "UPDATE $table SET |
|
|
|
|
preview_image = '".Database::escape_string($this->preview_image)."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new preview image : '.$this->preview_image, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5517,17 +5384,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_author($name = '') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_author()', 0); |
|
|
|
|
} |
|
|
|
|
$this->author = $name; |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
$sql = "UPDATE $table SET author = '".Database::escape_string($name)."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new preview author : '.$this->author, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5542,9 +5403,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_hide_toc_frame($hide) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_hide_toc_frame()', 0); |
|
|
|
|
} |
|
|
|
|
if (intval($hide) == $hide) { |
|
|
|
|
$this->hide_toc_frame = $hide; |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
@ -5558,9 +5416,9 @@ class learnpath |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -5572,17 +5430,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_prerequisite($prerequisite) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_prerequisite()', 0); |
|
|
|
|
} |
|
|
|
|
$this->prerequisite = (int) $prerequisite; |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
$sql = "UPDATE $table SET prerequisite = '".$this->prerequisite."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new preview requisite : '.$this->requisite, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5597,9 +5449,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_proximity($name = '') |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_proximity()', 0); |
|
|
|
|
} |
|
|
|
|
if (empty($name)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -5610,9 +5459,6 @@ class learnpath |
|
|
|
|
$sql = "UPDATE $table SET |
|
|
|
|
content_local = '".Database::escape_string($name)."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new proximity : '.$this->proximity, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5640,9 +5486,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_use_max_score($use_max_score = 1) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_use_max_score()', 0); |
|
|
|
|
} |
|
|
|
|
$use_max_score = (int) $use_max_score; |
|
|
|
|
$this->use_max_score = $use_max_score; |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
@ -5650,10 +5493,6 @@ class learnpath |
|
|
|
|
$sql = "UPDATE $table SET |
|
|
|
|
use_max_score = '".$this->use_max_score."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
|
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new use_max_score : '.$this->use_max_score, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5670,10 +5509,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_expired_on($expired_on) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_expired_on()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
/** @var CLp $lp */ |
|
|
|
|
$lp = $em |
|
|
|
|
@ -5694,10 +5529,6 @@ class learnpath |
|
|
|
|
$em->persist($lp); |
|
|
|
|
$em->flush(); |
|
|
|
|
|
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new expired_on : '.$this->expired_on, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -5712,10 +5543,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_publicated_on($publicated_on) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_expired_on()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
/** @var CLp $lp */ |
|
|
|
|
$lp = $em |
|
|
|
|
@ -5735,10 +5562,6 @@ class learnpath |
|
|
|
|
$em->persist($lp); |
|
|
|
|
$em->flush(); |
|
|
|
|
|
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new publicated_on : '.$this->publicated_on, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -5749,17 +5572,11 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_modified_on() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_expired_on()', 0); |
|
|
|
|
} |
|
|
|
|
$this->modified_on = api_get_utc_datetime(); |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
$sql = "UPDATE $table SET modified_on = '".$this->modified_on."' |
|
|
|
|
WHERE iid = $lp_id"; |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('lp updated with new expired_on : '.$this->modified_on, 0); |
|
|
|
|
} |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
@ -5901,9 +5718,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function update_default_view_mode() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::update_default_view_mode()', 0); |
|
|
|
|
} |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$sql = "SELECT * FROM $table |
|
|
|
|
WHERE iid = ".$this->get_id(); |
|
|
|
|
@ -5932,10 +5746,6 @@ class learnpath |
|
|
|
|
$this->mode = $view_mode; |
|
|
|
|
|
|
|
|
|
return $view_mode; |
|
|
|
|
} else { |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('Problem in update_default_view() - could not find LP '.$this->get_id().' in DB', 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
@ -5948,9 +5758,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function update_default_scorm_commit() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::update_default_scorm_commit()', 0); |
|
|
|
|
} |
|
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$sql = "SELECT * FROM $lp_table |
|
|
|
|
WHERE iid = ".$this->get_id(); |
|
|
|
|
@ -5971,10 +5778,6 @@ class learnpath |
|
|
|
|
$this->force_commit = $force_return; |
|
|
|
|
|
|
|
|
|
return $force_return; |
|
|
|
|
} else { |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('Problem in update_default_scorm_commit() - could not find LP '.$this->get_id().' in DB', 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
@ -6023,9 +5826,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function update_reinit() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::update_reinit()', 0); |
|
|
|
|
} |
|
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$sql = "SELECT * FROM $lp_table |
|
|
|
|
WHERE iid = ".$this->get_id(); |
|
|
|
|
@ -6044,10 +5844,6 @@ class learnpath |
|
|
|
|
$this->prevent_reinit = $force; |
|
|
|
|
|
|
|
|
|
return $force; |
|
|
|
|
} else { |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('Problem in update_reinit() - could not find LP '.$this->get_id().' in DB', 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
@ -6165,9 +5961,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function set_seriousgame_mode() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_seriousgame_mode()', 0); |
|
|
|
|
} |
|
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$sql = "SELECT * FROM $lp_table |
|
|
|
|
WHERE iid = ".$this->get_id(); |
|
|
|
|
@ -6186,10 +5979,6 @@ class learnpath |
|
|
|
|
$this->seriousgame_mode = $force; |
|
|
|
|
|
|
|
|
|
return $force; |
|
|
|
|
} else { |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('Problem in set_seriousgame_mode() - could not find LP '.$this->get_id().' in DB', 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
@ -6202,9 +5991,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function update_scorm_debug() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::update_scorm_debug()', 0); |
|
|
|
|
} |
|
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$sql = "SELECT * FROM $lp_table |
|
|
|
|
WHERE iid = ".$this->get_id(); |
|
|
|
|
@ -6223,10 +6009,6 @@ class learnpath |
|
|
|
|
$this->scorm_debug = $force; |
|
|
|
|
|
|
|
|
|
return $force; |
|
|
|
|
} else { |
|
|
|
|
if ($this->debug > 2) { |
|
|
|
|
error_log('Problem in update_scorm_debug() - could not find LP '.$this->get_id().' in DB', 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
@ -6241,9 +6023,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function tree_array($array) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 1) { |
|
|
|
|
error_log('In learnpath::tree_array()', 0); |
|
|
|
|
} |
|
|
|
|
$array = $this->sort_tree_array($array); |
|
|
|
|
$this->create_tree_array($array); |
|
|
|
|
} |
|
|
|
|
@ -6260,10 +6039,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function create_tree_array($array, $parent = 0, $depth = -1, $tmp = []) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 1) { |
|
|
|
|
error_log('In learnpath::create_tree_array())', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (is_array($array)) { |
|
|
|
|
for ($i = 0; $i < count($array); $i++) { |
|
|
|
|
if ($array[$i]['parent_item_id'] == $parent) { |
|
|
|
|
@ -6336,10 +6111,6 @@ class learnpath |
|
|
|
|
*/ |
|
|
|
|
public function overview() |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::overview()', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$return = ''; |
|
|
|
|
$update_audio = isset($_GET['updateaudio']) ? $_GET['updateaudio'] : null; |
|
|
|
|
|
|
|
|
|
@ -7132,7 +6903,6 @@ class learnpath |
|
|
|
|
$lp_name = $this->name; |
|
|
|
|
} |
|
|
|
|
$creatorId = empty($creatorId) ? api_get_user_id() : $creatorId; |
|
|
|
|
|
|
|
|
|
$folder = self::generate_learning_path_folder($course, $creatorId); |
|
|
|
|
|
|
|
|
|
// Limits title size |
|
|
|
|
@ -7256,7 +7026,6 @@ class learnpath |
|
|
|
|
|
|
|
|
|
// stripslashes() before calling api_replace_dangerous_char() because $_POST['title'] |
|
|
|
|
// is already escaped twice when it gets here. |
|
|
|
|
|
|
|
|
|
$originalTitle = !empty($title) ? $title : $_POST['title']; |
|
|
|
|
if (!empty($title)) { |
|
|
|
|
$title = api_replace_dangerous_char(stripslashes($title)); |
|
|
|
|
@ -7284,7 +7053,6 @@ class learnpath |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Change the path of mp3 to absolute. |
|
|
|
|
|
|
|
|
|
// The first regexp deals with :// urls. |
|
|
|
|
$content = preg_replace( |
|
|
|
|
"|(flashvars=\"file=)([^:/]+)/|", |
|
|
|
|
@ -11917,7 +11685,6 @@ 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. |
|
|
|
|
@ -12439,9 +12206,6 @@ EOD; |
|
|
|
|
public function select_previous_item_id() |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::select_previous_item_id()', 0); |
|
|
|
|
} |
|
|
|
|
$table_lp_item = Database::get_course_table(TABLE_LP_ITEM); |
|
|
|
|
|
|
|
|
|
// Get the max order of the items |
|
|
|
|
@ -12532,17 +12296,14 @@ EOD; |
|
|
|
|
public function clear_prerequisites() |
|
|
|
|
{ |
|
|
|
|
$course_id = $this->get_course_int_id(); |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::clear_prerequisites()', 0); |
|
|
|
|
} |
|
|
|
|
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
//Cleaning prerequisites |
|
|
|
|
// Cleaning prerequisites |
|
|
|
|
$sql = "UPDATE $tbl_lp_item SET prerequisite = '' |
|
|
|
|
WHERE c_id = $course_id AND lp_id = $lp_id"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
|
//Cleaning mastery score for exercises |
|
|
|
|
// Cleaning mastery score for exercises |
|
|
|
|
$sql = "UPDATE $tbl_lp_item SET mastery_score = '' |
|
|
|
|
WHERE c_id = $course_id AND lp_id = $lp_id AND item_type = 'quiz'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
@ -12881,6 +12642,21 @@ EOD; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public function getCurrentAttempt() |
|
|
|
|
{ |
|
|
|
|
$attempt = $this->getItem($this->get_current_item_id()); |
|
|
|
|
if ($attempt) { |
|
|
|
|
$attemptId = $attempt->get_attempt_id(); |
|
|
|
|
|
|
|
|
|
return $attemptId; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
@ -12927,9 +12703,6 @@ EOD; |
|
|
|
|
*/ |
|
|
|
|
public function setSubscribeUsers($value) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::set_subscribe_users()', 0); |
|
|
|
|
} |
|
|
|
|
$this->subscribeUsers = (int) $value; |
|
|
|
|
$table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
@ -13428,10 +13201,6 @@ EOD; |
|
|
|
|
*/ |
|
|
|
|
public function isFirstOrLastItem($currentItemId) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::isFirstOrLastItem('.$currentItemId.')', 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$lpItemId = []; |
|
|
|
|
$typeListNotToVerify = self::getChapterTypes(); |
|
|
|
|
|
|
|
|
|
@ -13483,9 +13252,6 @@ EOD; |
|
|
|
|
*/ |
|
|
|
|
public function setAccumulateScormTime($value) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::setAccumulateScormTime()', 0); |
|
|
|
|
} |
|
|
|
|
$this->accumulateScormTime = (int) $value; |
|
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_MAIN); |
|
|
|
|
$lp_id = $this->get_id(); |
|
|
|
|
|