Use cid/sid in params

pull/3064/head
Julio 6 years ago
parent 81d71517d5
commit acb00941c4
  1. 232
      public/main/lp/learnpath.class.php
  2. 12
      public/main/lp/learnpathList.class.php
  3. 112
      public/main/lp/lp_controller.php
  4. 2
      public/main/lp/lp_stats.php
  5. 4
      public/main/lp/scorm_api.php

@ -201,10 +201,10 @@ class learnpath
// Selecting by view_count descending allows to get the highest view_count first. // Selecting by view_count descending allows to get the highest view_count first.
$sql = "SELECT * FROM $lp_table $sql = "SELECT * FROM $lp_table
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
lp_id = $lp_id AND lp_id = $lp_id AND
user_id = $user_id user_id = $user_id
$session $session
ORDER BY view_count DESC"; ORDER BY view_count DESC";
$res = Database::query($sql); $res = Database::query($sql);
@ -602,7 +602,7 @@ class learnpath
if (!empty($next)) { if (!empty($next)) {
$sql = "UPDATE $tbl_lp_item $sql = "UPDATE $tbl_lp_item
SET previous_item_id = $new_item_id SET previous_item_id = $new_item_id
WHERE c_id = $course_id AND id = $next AND item_type != '".TOOL_LP_FINAL_ITEM."'"; WHERE c_id = $course_id AND id = $next AND item_type != '".TOOL_LP_FINAL_ITEM."'";
Database::query($sql); Database::query($sql);
} }
@ -756,7 +756,7 @@ class learnpath
// There is already one such name, update the current one a bit. // There is already one such name, update the current one a bit.
$i++; $i++;
$name = $name.' - '.$i; $name = $name.' - '.$i;
$check_name = "SELECT * FROM $tbl_lp $check_name = "SELECT * FROM $tbl_lp
WHERE c_id = $course_id AND name = '".Database::escape_string($name)."' "; WHERE c_id = $course_id AND name = '".Database::escape_string($name)."' ";
$res_name = Database::query($check_name); $res_name = Database::query($check_name);
} }
@ -782,7 +782,7 @@ class learnpath
break; break;
case 'manual': case 'manual':
default: default:
$get_max = "SELECT MAX(display_order) $get_max = "SELECT MAX(display_order)
FROM $tbl_lp WHERE c_id = $course_id"; FROM $tbl_lp WHERE c_id = $course_id";
$res_max = Database::query($get_max); $res_max = Database::query($get_max);
if (Database::num_rows($res_max) < 1) { if (Database::num_rows($res_max) < 1) {
@ -831,7 +831,7 @@ class learnpath
Database::query($sql); Database::query($sql);
// Insert into item_property. // Insert into item_property.
api_item_property_update( /*api_item_property_update(
$courseInfo, $courseInfo,
TOOL_LEARNPATH, TOOL_LEARNPATH,
$id, $id,
@ -845,7 +845,7 @@ class learnpath
$courseInfo, $courseInfo,
$session_id, $session_id,
$userId $userId
); );*/
return $id; return $id;
} }
@ -1027,7 +1027,7 @@ class learnpath
WHERE c_id = $course_id AND lp_id = ".$this->lp_id; WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
Database::query($sql); Database::query($sql);
$sql = "DELETE FROM $lp_view $sql = "DELETE FROM $lp_view
WHERE c_id = $course_id AND lp_id = ".$this->lp_id; WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
Database::query($sql); Database::query($sql);
@ -1042,9 +1042,9 @@ class learnpath
$row = Database::fetch_array($res); $row = Database::fetch_array($res);
$path = $row['path']; $path = $row['path'];
$sql = "SELECT id FROM $lp $sql = "SELECT id FROM $lp
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
path = '$path' AND path = '$path' AND
iid != ".$this->lp_id; iid != ".$this->lp_id;
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) > 0) { if (Database::num_rows($res) > 0) {
@ -1079,7 +1079,7 @@ class learnpath
WHERE c_id = $course_id AND (link LIKE '$link%' AND image='scormbuilder.gif')"; WHERE c_id = $course_id AND (link LIKE '$link%' AND image='scormbuilder.gif')";
Database::query($sql); Database::query($sql);
$sql = "DELETE FROM $lp $sql = "DELETE FROM $lp
WHERE iid = ".$this->lp_id; WHERE iid = ".$this->lp_id;
Database::query($sql); Database::query($sql);
// Updates the display order of all lps. // Updates the display order of all lps.
@ -1127,12 +1127,12 @@ class learnpath
return false; return false;
} }
$lp_item = Database::get_course_table(TABLE_LP_ITEM); $lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT * FROM $lp_item $sql = "SELECT * FROM $lp_item
WHERE c_id = $course_id AND parent_item_id = $id"; WHERE c_id = $course_id AND parent_item_id = $id";
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database::fetch_array($res)) { while ($row = Database::fetch_array($res)) {
$num += $this->delete_children_items($row['iid']); $num += $this->delete_children_items($row['iid']);
$sql = "DELETE FROM $lp_item $sql = "DELETE FROM $lp_item
WHERE c_id = $course_id AND iid = ".$row['iid']; WHERE c_id = $course_id AND iid = ".$row['iid'];
Database::query($sql); Database::query($sql);
$num++; $num++;
@ -1185,15 +1185,15 @@ class learnpath
Database::query($sql_upd); Database::query($sql_upd);
// Now update all following items with new display order. // Now update all following items with new display order.
$sql_all = "UPDATE $lp_item SET display_order = display_order-1 $sql_all = "UPDATE $lp_item SET display_order = display_order-1
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
lp_id = $lp AND lp_id = $lp AND
parent_item_id = $parent AND parent_item_id = $parent AND
display_order > $display"; display_order > $display";
Database::query($sql_all); Database::query($sql_all);
//Removing prerequisites since the item will not longer exist //Removing prerequisites since the item will not longer exist
$sql_all = "UPDATE $lp_item SET prerequisite = '' $sql_all = "UPDATE $lp_item SET prerequisite = ''
WHERE c_id = $course_id AND prerequisite = $id"; WHERE c_id = $course_id AND prerequisite = $id";
Database::query($sql_all); Database::query($sql_all);
@ -1205,8 +1205,8 @@ class learnpath
// Remove from search engine if enabled. // Remove from search engine if enabled.
if (api_get_setting('search_enabled') === 'true') { if (api_get_setting('search_enabled') === 'true') {
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s $sql = 'SELECT * FROM %s
WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d
LIMIT 1'; LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $this->cc, TOOL_LEARNPATH, $lp, $id); $sql = sprintf($sql, $tbl_se_ref, $this->cc, TOOL_LEARNPATH, $lp, $id);
$res = Database::query($sql); $res = Database::query($sql);
@ -1215,8 +1215,8 @@ class learnpath
$di = new ChamiloIndexer(); $di = new ChamiloIndexer();
$di->remove_document($row2['search_did']); $di->remove_document($row2['search_did']);
} }
$sql = 'DELETE FROM %s $sql = 'DELETE FROM %s
WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d
LIMIT 1'; LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $this->cc, TOOL_LEARNPATH, $lp, $id); $sql = sprintf($sql, $tbl_se_ref, $this->cc, TOOL_LEARNPATH, $lp, $id);
Database::query($sql); Database::query($sql);
@ -1262,7 +1262,7 @@ class learnpath
} }
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT * FROM $tbl_lp_item $sql = "SELECT * FROM $tbl_lp_item
WHERE iid = $id"; WHERE iid = $id";
$res_select = Database::query($sql); $res_select = Database::query($sql);
$row_select = Database::fetch_array($res_select); $row_select = Database::fetch_array($res_select);
@ -1791,10 +1791,10 @@ class learnpath
$settings = api_get_configuration_value('lp_view_settings'); $settings = api_get_configuration_value('lp_view_settings');
$display = isset($settings['display']) ? $settings['display'] : false; $display = isset($settings['display']) ? $settings['display'] : false;
$reportingIcon = ' $reportingIcon = '
<a class="icon-toolbar" <a class="icon-toolbar"
id="stats_link" id="stats_link"
href="lp_controller.php?action=stats&'.api_get_cidreq(true).'&lp_id='.$lpId.'" href="lp_controller.php?action=stats&'.api_get_cidreq(true).'&lp_id='.$lpId.'"
onclick="window.parent.API.save_asset(); return true;" onclick="window.parent.API.save_asset(); return true;"
target="content_name" title="'.$reportingText.'"> target="content_name" title="'.$reportingText.'">
<span class="fa fa-info"></span><span class="sr-only">'.$reportingText.'</span> <span class="fa fa-info"></span><span class="sr-only">'.$reportingText.'</span>
</a>'; </a>';
@ -1815,13 +1815,13 @@ class learnpath
$nextIcon = ''; $nextIcon = '';
if ($hideArrows === false) { if ($hideArrows === false) {
$previousIcon = ' $previousIcon = '
<a class="icon-toolbar" id="scorm-previous" href="#" <a class="icon-toolbar" id="scorm-previous" href="#"
onclick="switch_item('.$mycurrentitemid.',\'previous\');return false;" title="'.$previousText.'"> onclick="switch_item('.$mycurrentitemid.',\'previous\');return false;" title="'.$previousText.'">
<span class="fa fa-chevron-left"></span><span class="sr-only">'.$previousText.'</span> <span class="fa fa-chevron-left"></span><span class="sr-only">'.$previousText.'</span>
</a>'; </a>';
$nextIcon = ' $nextIcon = '
<a class="icon-toolbar" id="scorm-next" href="#" <a class="icon-toolbar" id="scorm-next" href="#"
onclick="switch_item('.$mycurrentitemid.',\'next\');return false;" title="'.$nextText.'"> onclick="switch_item('.$mycurrentitemid.',\'next\');return false;" title="'.$nextText.'">
<span class="fa fa-chevron-right"></span><span class="sr-only">'.$nextText.'</span> <span class="fa fa-chevron-right"></span><span class="sr-only">'.$nextText.'</span>
</a>'; </a>';
@ -1831,9 +1831,9 @@ class learnpath
$navbar = ' $navbar = '
<span id="'.$barId.'" class="buttons"> <span id="'.$barId.'" class="buttons">
'.$reportingIcon.' '.$reportingIcon.'
'.$previousIcon.' '.$previousIcon.'
'.$nextIcon.' '.$nextIcon.'
<a class="icon-toolbar" id="view-embedded" <a class="icon-toolbar" id="view-embedded"
href="lp_controller.php?action=mode&mode=embedded" target="_top" title="'.$fullScreenText.'"> href="lp_controller.php?action=mode&mode=embedded" target="_top" title="'.$fullScreenText.'">
<span class="fa fa-columns"></span><span class="sr-only">'.$fullScreenText.'</span> <span class="fa fa-columns"></span><span class="sr-only">'.$fullScreenText.'</span>
</a> </a>
@ -1843,7 +1843,7 @@ class learnpath
<span id="'.$barId.'" class="buttons text-right"> <span id="'.$barId.'" class="buttons text-right">
'.$reportingIcon.' '.$reportingIcon.'
'.$previousIcon.' '.$previousIcon.'
'.$nextIcon.' '.$nextIcon.'
</span>'; </span>';
} }
@ -2052,7 +2052,7 @@ class learnpath
} }
// Getting all the information about the item. // Getting all the information about the item.
$sql = "SELECT lpi.audio, lpi.item_type, lp_view.status $sql = "SELECT lpi.audio, lpi.item_type, lp_view.status
FROM $tbl_lp_item as lpi FROM $tbl_lp_item as lpi
INNER JOIN $tbl_lp_item_view as lp_view INNER JOIN $tbl_lp_item_view as lp_view
ON (lpi.iid = lp_view.lp_item_id) ON (lpi.iid = lp_view.lp_item_id)
@ -2442,8 +2442,8 @@ class learnpath
{ {
$text = $percentage.$text_add; $text = $percentage.$text_add;
$output = '<div class="progress"> $output = '<div class="progress">
<div id="progress_bar_value" <div id="progress_bar_value"
class="progress-bar progress-bar-success" role="progressbar" class="progress-bar progress-bar-success" role="progressbar"
aria-valuenow="'.$percentage.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$text.';"> aria-valuenow="'.$percentage.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$text.';">
'.$text.' '.$text.'
</div> </div>
@ -4280,6 +4280,7 @@ class learnpath
$sql = "SELECT * FROM $tbl_lp $sql = "SELECT * FROM $tbl_lp
WHERE iid = $lp_id"; WHERE iid = $lp_id";
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
$name = Database::escape_string($row['name']); $name = Database::escape_string($row['name']);
@ -4562,17 +4563,16 @@ class learnpath
* *
* @return bool * @return bool
*/ */
public static function categoryIsPublished( public static function categoryIsPublished(CLpCategory $category, $courseId)
CLpCategory $category, {
$courseId return false;
) {
$link = self::getCategoryLinkForTool($category->getId()); $link = self::getCategoryLinkForTool($category->getId());
$em = Database::getManager(); $em = Database::getManager();
$tools = $em $tools = $em
->createQuery(" ->createQuery("
SELECT t FROM ChamiloCourseBundle:CTool t SELECT t FROM ChamiloCourseBundle:CTool t
WHERE t.course = :course AND WHERE t.course = :course AND
t.name = :name AND t.name = :name AND
t.image LIKE 'lp_category.%' AND t.image LIKE 'lp_category.%' AND
t.link LIKE :link t.link LIKE :link
@ -6106,9 +6106,9 @@ class learnpath
); );
} }
$delete_icon .= ' <a $delete_icon .= ' <a
href="'.$mainUrl.'&action=delete_item&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id.'" href="'.$mainUrl.'&action=delete_item&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id.'"
onclick="return confirmation(\''.addslashes($title).'\');" onclick="return confirmation(\''.addslashes($title).'\');"
class="btn btn-default">'; class="btn btn-default">';
$delete_icon .= Display::return_icon( $delete_icon .= Display::return_icon(
'delete.png', 'delete.png',
@ -6217,14 +6217,14 @@ class learnpath
Display::tag( Display::tag(
'div', 'div',
"<div class=\"btn-group btn-group-xs\"> "<div class=\"btn-group btn-group-xs\">
$previewIcon $previewIcon
$audio $audio
$edit_icon $edit_icon
$pluginCalendarIcon $pluginCalendarIcon
$forumIcon $forumIcon
$prerequisities_icon $prerequisities_icon
$move_item_icon $move_item_icon
$audio_icon $audio_icon
$orderIcons $orderIcons
$delete_icon $delete_icon
</div>", </div>",
@ -6858,7 +6858,7 @@ class learnpath
if (empty($documentInfo)) { if (empty($documentInfo)) {
// Try with iid // Try with iid
$table = Database::get_course_table(TABLE_DOCUMENT); $table = Database::get_course_table(TABLE_DOCUMENT);
$sql = "SELECT id, path FROM $table $sql = "SELECT id, path FROM $table
WHERE c_id = $course_id AND iid = $document_id AND path NOT LIKE '%_DELETED_%' "; WHERE c_id = $course_id AND iid = $document_id AND path NOT LIKE '%_DELETED_%' ";
$res_doc = Database::query($sql); $res_doc = Database::query($sql);
$row = Database::fetch_array($res_doc); $row = Database::fetch_array($res_doc);
@ -8294,7 +8294,7 @@ class learnpath
if ($action === 'add') { if ($action === 'add') {
if (is_numeric($extra_info)) { if (is_numeric($extra_info)) {
$extra_info = (int) $extra_info; $extra_info = (int) $extra_info;
$sql_doc = "SELECT path FROM $tbl_doc $sql_doc = "SELECT path FROM $tbl_doc
WHERE c_id = $course_id AND iid = ".$extra_info; WHERE c_id = $course_id AND iid = ".$extra_info;
$result = Database::query($sql_doc); $result = Database::query($sql_doc);
$path_file = Database::result($result, 0, 0); $path_file = Database::result($result, 0, 0);
@ -9066,7 +9066,7 @@ class learnpath
$item_url = stripslashes($extra_info['url']); $item_url = stripslashes($extra_info['url']);
} elseif (is_numeric($extra_info)) { } elseif (is_numeric($extra_info)) {
$extra_info = (int) $extra_info; $extra_info = (int) $extra_info;
$sql = "SELECT title, description, url $sql = "SELECT title, description, url
FROM $tbl_link FROM $tbl_link
WHERE c_id = $course_id AND iid = $extra_info"; WHERE c_id = $course_id AND iid = $extra_info";
$result = Database::query($sql); $result = Database::query($sql);
@ -9399,7 +9399,7 @@ class learnpath
$return = '<div class="actions">'; $return = '<div class="actions">';
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT * FROM $tbl_lp_item $sql = "SELECT * FROM $tbl_lp_item
WHERE iid = ".$item_id; WHERE iid = ".$item_id;
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_assoc($result); $row = Database::fetch_assoc($result);
@ -9466,9 +9466,9 @@ class learnpath
// Try with iid // Try with iid
$table = Database::get_course_table(TABLE_DOCUMENT); $table = Database::get_course_table(TABLE_DOCUMENT);
$sql = "SELECT path FROM $table $sql = "SELECT path FROM $table
WHERE WHERE
c_id = ".api_get_course_int_id()." AND c_id = ".api_get_course_int_id()." AND
iid = ".$row['path']." AND iid = ".$row['path']." AND
path NOT LIKE '%_DELETED_%'"; path NOT LIKE '%_DELETED_%'";
$result = Database::query($sql); $result = Database::query($sql);
$documentData = Database::fetch_array($result); $documentData = Database::fetch_array($result);
@ -9505,9 +9505,9 @@ class learnpath
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT * FROM ".$tbl_lp_item." $sql = "SELECT * FROM ".$tbl_lp_item."
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
lp_id = ".$this->lp_id." AND lp_id = ".$this->lp_id." AND
parent_item_id = 0 parent_item_id = 0
ORDER BY display_order ASC"; ORDER BY display_order ASC";
$res_zero = Database::query($sql); $res_zero = Database::query($sql);
@ -9554,12 +9554,12 @@ class learnpath
if (!id) { if (!id) {
return false; return false;
} }
var cbo = document.getElementById('previous'); var cbo = document.getElementById('previous');
for(var i = cbo.length - 1; i > 0; i--) { for(var i = cbo.length - 1; i > 0; i--) {
cbo.options[i] = null; cbo.options[i] = null;
} }
var k=0; var k=0;
for(var i = 1; i <= child_name[id].length; i++){ for(var i = 1; i <= child_name[id].length; i++){
var option = new Option(child_name[id][i - 1], child_value[id][i - 1]); var option = new Option(child_name[id][i - 1], child_value[id][i - 1]);
@ -9567,7 +9567,7 @@ class learnpath
cbo.options[i] = option; cbo.options[i] = option;
k = i; k = i;
} }
cbo.options[k].selected = true; cbo.options[k].selected = true;
$('#previous').selectpicker('refresh'); $('#previous').selectpicker('refresh');
}"; }";
@ -9757,55 +9757,55 @@ class learnpath
} }
$return .= '<td>'; $return .= '<td>';
$return .= '<input $return .= '<input
class="form-control" class="form-control"
size="4" maxlength="3" size="4" maxlength="3"
name="min_'.$item['id'].'" name="min_'.$item['id'].'"
type="number" type="number"
min="0" min="0"
step="1" step="1"
max="'.$item['max_score'].'" max="'.$item['max_score'].'"
value="'.$selectedMinScoreValue.'" value="'.$selectedMinScoreValue.'"
/>'; />';
$return .= '</td>'; $return .= '</td>';
$return .= '<td>'; $return .= '<td>';
$return .= '<input $return .= '<input
class="form-control" class="form-control"
size="4" size="4"
maxlength="3" maxlength="3"
name="max_'.$item['id'].'" name="max_'.$item['id'].'"
type="number" type="number"
min="0" min="0"
step="1" step="1"
max="'.$item['max_score'].'" max="'.$item['max_score'].'"
value="'.$selectedMaxScoreValue.'" value="'.$selectedMaxScoreValue.'"
/>'; />';
$return .= '</td>'; $return .= '</td>';
} }
if ($item['item_type'] == TOOL_HOTPOTATOES) { if ($item['item_type'] == TOOL_HOTPOTATOES) {
$return .= '<td>'; $return .= '<td>';
$return .= '<input $return .= '<input
size="4" size="4"
maxlength="3" maxlength="3"
name="min_'.$item['id'].'" name="min_'.$item['id'].'"
type="number" type="number"
min="0" min="0"
step="1" step="1"
max="'.$item['max_score'].'" max="'.$item['max_score'].'"
value="'.$selectedMinScoreValue.'" value="'.$selectedMinScoreValue.'"
/>'; />';
$return .= '</td>'; $return .= '</td>';
$return .= '<td>'; $return .= '<td>';
$return .= '<input $return .= '<input
size="4" size="4"
maxlength="3" maxlength="3"
name="max_'.$item['id'].'" name="max_'.$item['id'].'"
type="number" type="number"
min="0" min="0"
step="1" step="1"
max="'.$item['max_score'].'" max="'.$item['max_score'].'"
value="'.$selectedMaxScoreValue.'" value="'.$selectedMaxScoreValue.'"
/>'; />';
$return .= '</td>'; $return .= '</td>';
} }
@ -10011,10 +10011,10 @@ class learnpath
} }
$sql_quiz = "SELECT * FROM $tbl_quiz $sql_quiz = "SELECT * FROM $tbl_quiz
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
$activeCondition $activeCondition
$condition_session $condition_session
$categoryCondition $categoryCondition
$keywordCondition $keywordCondition
ORDER BY title ASC"; ORDER BY title ASC";
@ -10172,7 +10172,7 @@ class learnpath
'link.session_id' 'link.session_id'
); );
$sql = "SELECT $sql = "SELECT
link.id as link_id, link.id as link_id,
link.title as link_title, link.title as link_title,
link.session_id as link_session_id, link.session_id as link_session_id,
@ -11645,9 +11645,9 @@ EOD;
$max_order = $row_max_order->display_order; $max_order = $row_max_order->display_order;
// Get the previous item ID // Get the previous item ID
$sql = "SELECT iid as previous FROM $table_lp_item $sql = "SELECT iid as previous FROM $table_lp_item
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
lp_id = ".$this->lp_id." AND lp_id = ".$this->lp_id." AND
display_order = '$max_order' "; display_order = '$max_order' ";
$rs_max = Database::query($sql); $rs_max = Database::query($sql);
$row_max = Database::fetch_object($rs_max); $row_max = Database::fetch_object($rs_max);
@ -11988,7 +11988,7 @@ EOD;
// Delete link tool // Delete link tool
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$link = 'lp/lp_controller.php?cidReq='.$courseInfo['code'].'&id_session='.$sessionId.'&gidReq=0&gradebook=0&origin=&action=view_category&id='.$id; $link = 'lp/lp_controller.php?cid='.$courseInfo['real_id'].'&sid='.$sessionId.'&gidReq=0&gradebook=0&origin=&action=view_category&id='.$id;
// Delete tools // Delete tools
$sql = "DELETE FROM $tbl_tool $sql = "DELETE FROM $tbl_tool
WHERE c_id = ".$courseId." AND (link LIKE '$link%' AND image='lp_category.gif')"; WHERE c_id = ".$courseId." AND (link LIKE '$link%' AND image='lp_category.gif')";
@ -12687,7 +12687,7 @@ EOD;
$this->accumulateScormTime = (int) $value; $this->accumulateScormTime = (int) $value;
$lp_table = Database::get_course_table(TABLE_LP_MAIN); $lp_table = Database::get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id(); $lp_id = $this->get_id();
$sql = "UPDATE $lp_table $sql = "UPDATE $lp_table
SET accumulate_scorm_time = ".$this->accumulateScormTime." SET accumulate_scorm_time = ".$this->accumulateScormTime."
WHERE iid = $lp_id"; WHERE iid = $lp_id";
Database::query($sql); Database::query($sql);
@ -12918,7 +12918,7 @@ EOD;
$learningPathId = (int) $learningPathId; $learningPathId = (int) $learningPathId;
$id_in_path = (int) $id_in_path; $id_in_path = (int) $id_in_path;
$sql = "SELECT item_type, title, ref $sql = "SELECT item_type, title, ref
FROM $tbl_lp_item FROM $tbl_lp_item
WHERE c_id = $course_id AND lp_id = $learningPathId AND iid = $id_in_path"; WHERE c_id = $course_id AND lp_id = $learningPathId AND iid = $id_in_path";
$res_item = Database::query($sql); $res_item = Database::query($sql);
@ -13266,8 +13266,8 @@ EOD;
public function getAccumulateWorkTimeTotalCourse() public function getAccumulateWorkTimeTotalCourse()
{ {
$table = Database::get_course_table(TABLE_LP_MAIN); $table = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT SUM(accumulate_work_time) AS total $sql = "SELECT SUM(accumulate_work_time) AS total
FROM $table FROM $table
WHERE c_id = ".$this->course_int_id; WHERE c_id = ".$this->course_int_id;
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
@ -13310,8 +13310,8 @@ EOD;
$courseId = (int) $courseId; $courseId = (int) $courseId;
$table = Database::get_course_table(TABLE_LP_MAIN); $table = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT accumulate_work_time $sql = "SELECT accumulate_work_time
FROM $table FROM $table
WHERE c_id = $courseId AND id = $lpId"; WHERE c_id = $courseId AND id = $lpId";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
@ -13437,7 +13437,7 @@ EOD;
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = "SELECT * FROM $tbl_lp_item $sql = "SELECT * FROM $tbl_lp_item
WHERE c_id = $course_id AND lp_id = ".$this->lp_id; WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
if ($addParentCondition) { if ($addParentCondition) {

@ -110,22 +110,22 @@ class LearnpathList
$link = 'lp/lp_controller.php?action=view&lp_id='.$row->getId().'&id_session='.$session_id; $link = 'lp/lp_controller.php?action=view&lp_id='.$row->getId().'&id_session='.$session_id;
$oldLink = 'newscorm/lp_controller.php?action=view&lp_id='.$row->getId().'&id_session='.$session_id; $oldLink = 'newscorm/lp_controller.php?action=view&lp_id='.$row->getId().'&id_session='.$session_id;
$sql2 = "SELECT visibility FROM $tbl_tool /*$sql2 = "SELECT visibility FROM $tbl_tool
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
name = '$name' AND name = '$name' AND
image = 'scormbuilder.gif' AND image = 'scormbuilder.gif' AND
( (
link LIKE '$link%' OR link LIKE '$link%' OR
link LIKE '$oldLink%' link LIKE '$oldLink%'
) )
"; ";
$res2 = Database::query($sql2); $res2 = Database::query($sql2);*/
$pub = 'i'; $pub = 'i';
if (Database::num_rows($res2) > 0) { /*if (Database::num_rows($res2) > 0) {
$row2 = Database::fetch_array($res2); $row2 = Database::fetch_array($res2);
$pub = $row2['visibility']; $pub = $row2['visibility'];
} }*/
// Check if visible. // Check if visible.
$visibility = api_get_item_visibility( $visibility = api_get_item_visibility(

@ -55,7 +55,7 @@ $htmlHeadXtra[] = '
/* /*
Script to manipulate Learning Path items with Drag and drop Script to manipulate Learning Path items with Drag and drop
*/ */
var newOrderData = ""; var newOrderData = "";
function buildLPtree(in_elem, in_parent_id) { function buildLPtree(in_elem, in_parent_id) {
var item_tag = in_elem.get(0).tagName; var item_tag = in_elem.get(0).tagName;
var item_id = in_elem.attr("id"); var item_id = in_elem.attr("id");
@ -80,7 +80,7 @@ $htmlHeadXtra[] = '
return in_parent_integer_id; return in_parent_integer_id;
} }
$(function() { $(function() {
$(".lp_resource").sortable({ $(".lp_resource").sortable({
items: ".lp_resource_element ", items: ".lp_resource_element ",
handle: ".moved", //only the class "moved" handle: ".moved", //only the class "moved"
@ -95,15 +95,15 @@ $htmlHeadXtra[] = '
$(ui.item).css("width", "100%"); $(ui.item).css("width", "100%");
} }
}); });
$(".li_container .order_items").click(function(e) { $(".li_container .order_items").click(function(e) {
var dir = $(this).data("dir"); var dir = $(this).data("dir");
var itemId = $(this).data("id"); var itemId = $(this).data("id");
var jItems = $("#lp_item_list li.li_container"); var jItems = $("#lp_item_list li.li_container");
var jItem = $("#"+ itemId); var jItem = $("#"+ itemId);
var index = jItems.index(jItem); var index = jItems.index(jItem);
var total = jItems.length; var total = jItems.length;
switch (dir) { switch (dir) {
case "up": case "up":
if (index != 0 && jItems[index - 1]) { if (index != 0 && jItems[index - 1]) {
@ -111,58 +111,58 @@ $htmlHeadXtra[] = '
if (subItems.length >= 0) { if (subItems.length >= 0) {
index = index - 1; index = index - 1;
}*/ }*/
var subItems = $(jItems[index - 1]).find("li.sub_item"); var subItems = $(jItems[index - 1]).find("li.sub_item");
var parentClass = $(jItems[index - 1]).parent().parent().attr("class"); var parentClass = $(jItems[index - 1]).parent().parent().attr("class");
var parentId = $(jItems[index]).parent().parent().attr("id"); var parentId = $(jItems[index]).parent().parent().attr("id");
var myParentId = $(jItems[index - 1]).parent().parent().attr("id"); var myParentId = $(jItems[index - 1]).parent().parent().attr("id");
//console.log(parentId + " - " + myParentId); //console.log(parentId + " - " + myParentId);
// We are brothers! // We are brothers!
if (parentId == myParentId) { if (parentId == myParentId) {
console.log("Brothers"); console.log("Brothers");
console.log(subItems.length); console.log(subItems.length);
if (subItems.length > 0) { if (subItems.length > 0) {
var lastItem = $(jItems[index - 1]).find("li.sub_item"); var lastItem = $(jItems[index - 1]).find("li.sub_item");
parentIndex = jItems.index(lastItem); parentIndex = jItems.index(lastItem);
console.log(parentIndex); console.log(parentIndex);
jItem.detach().insertAfter(lastItem); jItem.detach().insertAfter(lastItem);
//console.log("not classic"); //console.log("not classic");
} else { } else {
//console.log("classic"); //console.log("classic");
jItem.detach().insertBefore(jItems[index - 1]); jItem.detach().insertBefore(jItems[index - 1]);
} }
break; break;
} }
//console.log(parentClass); //console.log(parentClass);
if (parentClass == "record li_container") { if (parentClass == "record li_container") {
// previous is a chapter // previous is a chapter
var lastItem = $(jItems[index - 1]).parent().parent().find("li.li_container").last(); var lastItem = $(jItems[index - 1]).parent().parent().find("li.li_container").last();
parentIndex = jItems.index(lastItem); parentIndex = jItems.index(lastItem);
//console.log(parentIndex); //console.log(parentIndex);
jItem.detach().insertAfter(jItems[parentIndex]); jItem.detach().insertAfter(jItems[parentIndex]);
} else { } else {
jItem.detach().insertBefore(jItems[index - 1]); jItem.detach().insertBefore(jItems[index - 1]);
} }
} }
break; break;
case "down": case "down":
if (index != total - 1) { if (index != total - 1) {
const originIndex = index; const originIndex = index;
// The element is a chapter with items // The element is a chapter with items
var subItems = jItem.find("li.li_container"); var subItems = jItem.find("li.li_container");
if (subItems.length > 0) { if (subItems.length > 0) {
index = subItems.length + index; index = subItems.length + index;
//console.log("element is a chapter with items"); //console.log("element is a chapter with items");
//console.log("new index = " + index); //console.log("new index = " + index);
} }
var subItems = $(jItems[index + 1]).find("li.sub_item"); var subItems = $(jItems[index + 1]).find("li.sub_item");
//console.log("next subItems.length: "+subItems.length); //console.log("next subItems.length: "+subItems.length);
// This is an element entering in a chapter // This is an element entering in a chapter
if (subItems.length > 0) { if (subItems.length > 0) {
// Check if im a child // Check if im a child
var parentClass = jItem.parent().parent().attr("class"); var parentClass = jItem.parent().parent().attr("class");
//console.log(parentClass); //console.log(parentClass);
if (parentClass == "record li_container") { if (parentClass == "record li_container") {
// Parent position // Parent position
@ -171,29 +171,29 @@ $htmlHeadXtra[] = '
//console.log(parentIndex); //console.log(parentIndex);
jItem.detach().insertAfter(jItems[parentIndex]); jItem.detach().insertAfter(jItems[parentIndex]);
} else { } else {
jItem.detach().insertAfter(subItems); jItem.detach().insertAfter(subItems);
} }
break; break;
} }
var currentSubItems = $(jItems[index]).parent().find("li.sub_item"); var currentSubItems = $(jItems[index]).parent().find("li.sub_item");
//console.log("currentSubItems"+currentSubItems.length); //console.log("currentSubItems"+currentSubItems.length);
var parentId = $(jItems[originIndex]).parent().parent().attr("id"); var parentId = $(jItems[originIndex]).parent().parent().attr("id");
var myParentId = $(jItems[index + 1]).parent().parent().attr("id"); var myParentId = $(jItems[index + 1]).parent().parent().attr("id");
//console.log("parent ids: "+ parentId + " - " + myParentId); //console.log("parent ids: "+ parentId + " - " + myParentId);
// We are brothers! // We are brothers!
if (parentId == myParentId) { if (parentId == myParentId) {
if ((index + 1) < total) { if ((index + 1) < total) {
//console.log(index + 1); //console.log(index + 1);
//console.log("We are brothers"); //console.log("We are brothers");
jItem.detach().insertAfter(jItems[index + 1]); jItem.detach().insertAfter(jItems[index + 1]);
} }
break; break;
} }
if (currentSubItems.length > 0) { if (currentSubItems.length > 0) {
var parentIndex = jItems.index(jItem.parent().parent()); var parentIndex = jItems.index(jItem.parent().parent());
//console.log("has currentSubItems"); //console.log("has currentSubItems");
//console.log("id " + jItem.parent().parent().attr("id")); //console.log("id " + jItem.parent().parent().attr("id"));
@ -202,14 +202,14 @@ $htmlHeadXtra[] = '
jItem.detach().insertAfter(jItems[parentIndex]); jItem.detach().insertAfter(jItems[parentIndex]);
break; break;
} }
//jItem.detach().insertAfter($(jItems[index]).parent().parent()); //jItem.detach().insertAfter($(jItems[index]).parent().parent());
} }
//var lastItem = $(jItems[index + 1]).parent().parent().find("li.li_container").last(); //var lastItem = $(jItems[index + 1]).parent().parent().find("li.li_container").last();
if (subItems.length > 0) { if (subItems.length > 0) {
index = originIndex; index = originIndex;
} }
if ((index + 1) < total) { if ((index + 1) < total) {
//console.log(index + 1); //console.log(index + 1);
//console.log("changed"); //console.log("changed");
@ -217,11 +217,11 @@ $htmlHeadXtra[] = '
} }
} }
break; break;
} }
//console.log("rebuild"); //console.log("rebuild");
buildLPtree($("#lp_item_list"), 0); buildLPtree($("#lp_item_list"), 0);
var order = "new_order="+ newOrderData + "&a=update_lp_item_order"; var order = "new_order="+ newOrderData + "&a=update_lp_item_order";
$.post( $.post(
"'.$ajax_url.'", "'.$ajax_url.'",
@ -231,7 +231,7 @@ $htmlHeadXtra[] = '
order = ""; order = "";
newOrderData = ""; newOrderData = "";
} }
); );
}); });
$("#lp_item_list").sortable({ $("#lp_item_list").sortable({
@ -272,7 +272,7 @@ $htmlHeadXtra[] = '
"type": type, "type": type,
"title" : title "title" : title
}; };
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "'.$ajax_url.'", url: "'.$ajax_url.'",
@ -281,7 +281,7 @@ $htmlHeadXtra[] = '
success: function(data) { success: function(data) {
$("#lp_item_list").html(data); $("#lp_item_list").html(data);
} }
}); });
} }
} }
} // End receive } // End receive
@ -516,7 +516,7 @@ switch ($action) {
if (!empty($sessionId)) { if (!empty($sessionId)) {
$sessionInfo = api_get_session_info($sessionId); $sessionInfo = api_get_session_info($sessionId);
$courseName = $sessionInfo['name']; $courseName = $sessionInfo['name'];
$courseUrl .= '?id_session='.$sessionId; $courseUrl .= '?sid='.$sessionId;
} }
$url = Display::url($courseName, $courseUrl, ['title' => get_lang('Go to the course')]); $url = Display::url($courseName, $courseUrl, ['title' => get_lang('Go to the course')]);
@ -1447,7 +1447,7 @@ switch ($action) {
error_log('save_current()'); error_log('save_current()');
error_log('save_last()'); error_log('save_last()');
} }
$url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id(); $url = $_course['course_public_url'].'?sid='.api_get_session_id();
$redirectTo = isset($_GET['redirectTo']) ? $_GET['redirectTo'] : ''; $redirectTo = isset($_GET['redirectTo']) ? $_GET['redirectTo'] : '';
switch ($redirectTo) { switch ($redirectTo) {
case 'lp_list': case 'lp_list':

@ -16,7 +16,7 @@ if (!isset($origin)) {
$origin = 'learnpath'; $origin = 'learnpath';
} }
$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : api_get_session_id(); $sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : api_get_session_id();
$courseCode = isset($_GET['course']) ? $_GET['course'] : api_get_course_id(); $courseCode = isset($_GET['course']) ? $_GET['course'] : api_get_course_id();
$userId = isset($_GET['student_id']) ? (int) $_GET['student_id'] : api_get_user_id(); $userId = isset($_GET['student_id']) ? (int) $_GET['student_id'] : api_get_user_id();
$lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : null; $lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : null;

@ -214,7 +214,7 @@ olms.userfname = '<?php echo addslashes(trim($user['firstname'])); ?>';
olms.userlname = '<?php echo addslashes(trim($user['lastname'])); ?>'; olms.userlname = '<?php echo addslashes(trim($user['lastname'])); ?>';
olms.execute_stats = false; olms.execute_stats = false;
var courseUrl = '?cidReq='+olms.lms_course_code+'&id_session='+olms.lms_session_id; var courseUrl = '?cid='+olms.lms_course_id+'&sid='+olms.lms_session_id;
/** /**
* Add the "addListeners" function to the "onload" event of the window and * Add the "addListeners" function to the "onload" event of the window and
@ -1662,7 +1662,7 @@ function switch_item(current_item, next_item)
} }
var mysrc = '<?php echo api_get_path(WEB_CODE_PATH); ?>lp/lp_controller.php?action=content&lp_id=' + olms.lms_lp_id + var mysrc = '<?php echo api_get_path(WEB_CODE_PATH); ?>lp/lp_controller.php?action=content&lp_id=' + olms.lms_lp_id +
'&item_id=' + next_item + '&cidReq=' + olms.lms_course_code + '&id_session=' + olms.lms_session_id; '&item_id=' + next_item + '&cid=' + olms.lms_course_id + '&sid=' + olms.lms_session_id;
var cont_f = $("#content_id"); var cont_f = $("#content_id");
<?php if ($oLP->mode == 'fullscreen') { <?php if ($oLP->mode == 'fullscreen') {

Loading…
Cancel
Save