Fixing formatting

skala
Julio Montoya 12 years ago
parent c7f4d241a5
commit 5a629e4ad7
  1. 310
      main/newscorm/learnpath.class.php

@ -72,13 +72,13 @@ class learnpath {
public $modified_on = ''; public $modified_on = '';
public $publicated_on = ''; public $publicated_on = '';
public $expired_on = ''; public $expired_on = '';
public $ref = null; public $ref = null;
public $course_int_id; public $course_int_id;
public function get_course_int_id() { public function get_course_int_id() {
return isset($this->course_int_id) ? $this->course_int_id : api_get_course_int_id(); return isset($this->course_int_id) ? $this->course_int_id : api_get_course_int_id();
} }
public function set_course_int_id($course_id) { public function set_course_int_id($course_id) {
return $this->course_int_id = intval($course_id); return $this->course_int_id = intval($course_id);
} }
@ -92,7 +92,7 @@ class learnpath {
* @return boolean True on success, false on error * @return boolean True on success, false on error
*/ */
public function __construct($course, $lp_id, $user_id) { public function __construct($course, $lp_id, $user_id) {
$this->encoding = api_get_system_encoding(); // Chamilo 1.8.8: We intend always to use the system encoding. $this->encoding = api_get_system_encoding(); // Chamilo 1.8.8: We intend always to use the system encoding.
// Check course code. // Check course code.
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -148,7 +148,7 @@ class learnpath {
$this->lp_session_id = $row['session_id']; $this->lp_session_id = $row['session_id'];
$this->use_max_score = $row['use_max_score']; $this->use_max_score = $row['use_max_score'];
$this->created_on = $row['created_on']; $this->created_on = $row['created_on'];
$this->modified_on = $row['modified_on']; $this->modified_on = $row['modified_on'];
$this->ref = $row['ref']; $this->ref = $row['ref'];
if ($row['publicated_on'] != '0000-00-00 00:00:00') { if ($row['publicated_on'] != '0000-00-00 00:00:00') {
@ -174,7 +174,7 @@ class learnpath {
if (empty($user_id)) { if (empty($user_id)) {
$this->error = 'User ID is empty'; $this->error = 'User ID is empty';
return false; return false;
} else { } else {
$user_info = api_get_user_info($user_id); $user_info = api_get_user_info($user_id);
if (!empty($user_info)) { if (!empty($user_info)) {
$this->user_id = $user_info['user_id']; $this->user_id = $user_info['user_id'];
@ -190,12 +190,12 @@ class learnpath {
$session = api_get_session_condition($session_id); $session = api_get_session_condition($session_id);
// Now get the latest attempt from this user on this LP, if available, otherwise create a new one. // Now get the latest attempt from this user on this LP, if available, otherwise create a new one.
$lp_table = Database::get_course_table(TABLE_LP_VIEW); $lp_table = Database::get_course_table(TABLE_LP_VIEW);
// 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 WHERE c_id = $course_id AND lp_id = '$lp_id' AND user_id = '$user_id' $session ORDER BY view_count DESC"; $sql = "SELECT * FROM $lp_table WHERE c_id = $course_id AND lp_id = '$lp_id' AND user_id = '$user_id' $session ORDER BY view_count DESC";
$res = Database::query($sql); $res = Database::query($sql);
if ($this->debug > 2) { error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - querying lp_view: ' . $sql, 0); } if ($this->debug > 2) { error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - querying lp_view: ' . $sql, 0); }
if (Database :: num_rows($res) > 0) { if (Database :: num_rows($res) > 0) {
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Found previous view', 0); error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Found previous view', 0);
@ -211,7 +211,7 @@ class learnpath {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0); error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0);
} }
$this->attempt = 1; $this->attempt = 1;
$sql_ins = "INSERT INTO $lp_table (c_id, lp_id, user_id, view_count, session_id) VALUES ($course_id, $lp_id, $user_id, 1, $session_id)"; $sql_ins = "INSERT INTO $lp_table (c_id, lp_id, user_id, view_count, session_id) VALUES ($course_id, $lp_id, $user_id, 1, $session_id)";
$res_ins = Database::query($sql_ins); $res_ins = Database::query($sql_ins);
$this->lp_view_id = Database :: insert_id(); $this->lp_view_id = Database :: insert_id();
if ($this->debug > 2) { if ($this->debug > 2) {
@ -221,14 +221,14 @@ class learnpath {
// Initialise items. // Initialise items.
$lp_item_table = Database::get_course_table(TABLE_LP_ITEM); $lp_item_table = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT * FROM $lp_item_table WHERE c_id = $course_id AND lp_id = '".$this->lp_id."' ORDER BY parent_item_id, display_order"; $sql = "SELECT * FROM $lp_item_table WHERE c_id = $course_id AND lp_id = '".$this->lp_id."' ORDER BY parent_item_id, display_order";
$res = Database::query($sql); $res = Database::query($sql);
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - query lp items: ' . $sql, 0); error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - query lp items: ' . $sql, 0);
error_log('-- Start while--', 0); error_log('-- Start while--', 0);
} }
$lp_item_id_list = array(); $lp_item_id_list = array();
while ($row = Database::fetch_array($res)) { while ($row = Database::fetch_array($res)) {
$oItem = ''; $oItem = '';
@ -271,7 +271,7 @@ class learnpath {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - calling learnpathItem', 0); error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - calling learnpathItem', 0);
} }
$oItem = new learnpathItem($row['id'], $user_id, $course_id, $row); $oItem = new learnpathItem($row['id'], $user_id, $course_id, $row);
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - end calling learnpathItem', 0); error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - end calling learnpathItem', 0);
} }
@ -306,43 +306,43 @@ class learnpath {
} }
} }
} }
// Setting the view in the item object. // Setting the view in the item object.
if (is_object($this->items[$row['id']])) { if (is_object($this->items[$row['id']])) {
$this->items[$row['id']]->set_lp_view($this->lp_view_id, $course_id); $this->items[$row['id']]->set_lp_view($this->lp_view_id, $course_id);
if ($this->items[$row['id']]->get_type() == TOOL_HOTPOTATOES) { if ($this->items[$row['id']]->get_type() == TOOL_HOTPOTATOES) {
$this->items[$row['id']]->current_start_time = 0; $this->items[$row['id']]->current_start_time = 0;
$this->items[$row['id']]->current_stop_time = 0; $this->items[$row['id']]->current_stop_time = 0;
} }
} }
} }
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' ----- end while ----', 0); error_log('New LP - learnpath::__construct() ' . __LINE__ . ' ----- end while ----', 0);
} }
if (!empty($lp_item_id_list)) { if (!empty($lp_item_id_list)) {
$lp_item_id_list_to_string = implode("','", $lp_item_id_list); $lp_item_id_list_to_string = implode("','", $lp_item_id_list);
// Get last viewing vars. // Get last viewing vars.
$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW); $lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
// This query should only return one or zero result. // This query should only return one or zero result.
$sql = "SELECT lp_item_id, status FROM $lp_item_view_table $sql = "SELECT lp_item_id, status FROM $lp_item_view_table
WHERE c_id = $course_id AND lp_view_id = ".$this->lp_view_id." AND lp_item_id IN ('".$lp_item_id_list_to_string."') WHERE c_id = $course_id AND lp_view_id = ".$this->lp_view_id." AND lp_item_id IN ('".$lp_item_id_list_to_string."')
ORDER BY view_count DESC "; ORDER BY view_count DESC ";
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() - Selecting item_views: ' . $sql, 0); error_log('New LP - learnpath::__construct() - Selecting item_views: ' . $sql, 0);
} }
$status_list = array(); $status_list = array();
$res = Database::query($sql); $res = Database::query($sql);
while ($row = Database :: fetch_array($res) ) { while ($row = Database :: fetch_array($res) ) {
$status_list[$row['lp_item_id']] = $row['status']; $status_list[$row['lp_item_id']] = $row['status'];
} }
foreach ($lp_item_id_list as $item_id) { foreach ($lp_item_id_list as $item_id) {
if (isset($status_list[$item_id])) { if (isset($status_list[$item_id])) {
$status = $status_list[$item_id]; $status = $status_list[$item_id];
if (is_object($this->items[$item_id])) { if (is_object($this->items[$item_id])) {
$this->items[$item_id]->set_status($status); $this->items[$item_id]->set_status($status);
@ -364,7 +364,7 @@ class learnpath {
} }
} }
} }
$this->ordered_items = self::get_flat_ordered_items_list($this->get_id(), 0, $course_id); $this->ordered_items = self::get_flat_ordered_items_list($this->get_id(), 0, $course_id);
$this->max_ordered_items = 0; $this->max_ordered_items = 0;
foreach ($this->ordered_items as $index => $dummy) { foreach ($this->ordered_items as $index => $dummy) {
@ -679,7 +679,7 @@ class learnpath {
case 'aicc': case 'aicc':
break; break;
} }
switch ($origin) { switch ($origin) {
case 'zip': case 'zip':
// Check zipname string. If empty, we are currently creating a new Chamilo learnpath. // Check zipname string. If empty, we are currently creating a new Chamilo learnpath.
@ -704,7 +704,7 @@ class learnpath {
$course_info = api_get_course_info(); $course_info = api_get_course_info();
// Insert into item_property. // Insert into item_property.
api_item_property_update($course_info, TOOL_LEARNPATH, $id, 'LearnpathAdded', api_get_user_id()); api_item_property_update($course_info, TOOL_LEARNPATH, $id, 'LearnpathAdded', api_get_user_id());
api_set_default_visibility($id, TOOL_LEARNPATH); api_set_default_visibility($id, TOOL_LEARNPATH);
return $id; return $id;
} }
break; break;
@ -727,7 +727,7 @@ class learnpath {
* @param integer Optional ID of the item from which to look for parents * @param integer Optional ID of the item from which to look for parents
*/ */
public function autocomplete_parents($item) { public function autocomplete_parents($item) {
$debug = $this->debug; $debug = $this->debug;
if ($debug) { if ($debug) {
error_log('Learnpath::autocomplete_parents()', 0); error_log('Learnpath::autocomplete_parents()', 0);
} }
@ -735,7 +735,7 @@ class learnpath {
$item = $this->current; $item = $this->current;
} }
$parent_id = $this->items[$item]->get_parent(); $parent_id = $this->items[$item]->get_parent();
if (isset($this->items[$item]) && is_object($this->items[$item]) and !empty($parent_id)) { if (isset($this->items[$item]) && is_object($this->items[$item]) and !empty($parent_id)) {
// if $item points to an object and there is a parent. // if $item points to an object and there is a parent.
if ($debug) { if ($debug) {
@ -751,7 +751,7 @@ class learnpath {
if ($debug) { if ($debug) {
error_log('Status of current item is alright', 0); error_log('Status of current item is alright', 0);
} }
foreach ($parent->get_children() as $child) { foreach ($parent->get_children() as $child) {
// Check all his brothers (parent's children) for completion status. // Check all his brothers (parent's children) for completion status.
if ($child != $item) { if ($child != $item) {
@ -776,7 +776,7 @@ class learnpath {
} }
} }
} }
if ($completed) { // If all the children were completed: if ($completed) { // If all the children were completed:
$parent->set_status('completed'); $parent->set_status('completed');
$parent->save(false, $this->prerequisites_match($parent->get_id())); $parent->save(false, $this->prerequisites_match($parent->get_id()));
@ -1084,7 +1084,7 @@ class learnpath {
if (empty ($id) || ($id != strval(intval($id))) || empty ($title)) { if (empty ($id) || ($id != strval(intval($id))) || empty ($title)) {
return false; return false;
} }
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$sql_select = "SELECT * FROM " . $tbl_lp_item . " WHERE c_id = ".$course_id." AND id = " . $id; $sql_select = "SELECT * FROM " . $tbl_lp_item . " WHERE c_id = ".$course_id." AND id = " . $id;
$res_select = Database::query($sql_select); $res_select = Database::query($sql_select);
@ -1353,7 +1353,7 @@ class learnpath {
* @param string Zip file name * @param string Zip file name
* @return string Zip file path (or false on error) * @return string Zip file path (or false on error)
*/ */
public function export_lp($type, $course, $id, $zipname) { public function export_lp($type, $course, $id, $zipname) {
//if ($this->debug > 0) { error_log('New LP - In learnpath::export_lp()', 0); } //if ($this->debug > 0) { error_log('New LP - In learnpath::export_lp()', 0); }
if (empty($type) || empty($course) || empty($id) || empty($zipname)) { if (empty($type) || empty($course) || empty($id) || empty($zipname)) {
return false; return false;
@ -1541,34 +1541,34 @@ class learnpath {
* Gets the first element URL. * Gets the first element URL.
* @return string URL to load into the viewer * @return string URL to load into the viewer
*/ */
public function first() { public function first() {
if ($this->debug > 0) { if ($this->debug > 0) {
error_log('New LP - In learnpath::first()', 0); error_log('New LP - In learnpath::first()', 0);
error_log('$this->last_item_seen '.$this->last_item_seen); error_log('$this->last_item_seen '.$this->last_item_seen);
//error_log('$this->items '.print_r($this->items, 1)); //error_log('$this->items '.print_r($this->items, 1));
//error_log('$this->ordered_items '.print_r($this->ordered_items, 1)); //error_log('$this->ordered_items '.print_r($this->ordered_items, 1));
} }
// Test if the last_item_seen exists and is not a dir. // Test if the last_item_seen exists and is not a dir.
if (count($this->ordered_items) == 0) { if (count($this->ordered_items) == 0) {
$this->index = 0; $this->index = 0;
} }
if ($this->debug > 0) { if ($this->debug > 0) {
if (isset($this->items[$this->last_item_seen])) { if (isset($this->items[$this->last_item_seen])) {
$status = $this->items[$this->last_item_seen]->get_status(); $status = $this->items[$this->last_item_seen]->get_status();
} }
error_log('status '.$status); error_log('status '.$status);
} }
if (!empty($this->last_item_seen) && if (!empty($this->last_item_seen) &&
!empty($this->items[$this->last_item_seen]) && !empty($this->items[$this->last_item_seen]) &&
$this->items[$this->last_item_seen]->get_type() != 'dir' && $this->items[$this->last_item_seen]->get_type() != 'dir' &&
$this->items[$this->last_item_seen]->get_type() != 'dokeos_chapter' $this->items[$this->last_item_seen]->get_type() != 'dokeos_chapter'
//with this change (below) the LP will NOT go to the next item, it will take lp item we left //with this change (below) the LP will NOT go to the next item, it will take lp item we left
//&& !$this->items[$this->last_item_seen]->is_done() //&& !$this->items[$this->last_item_seen]->is_done()
) { ) {
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - In learnpath::first() - Last item seen is ' . $this->last_item_seen.' of type '.$this->items[$this->last_item_seen]->get_type(), 0); error_log('New LP - In learnpath::first() - Last item seen is ' . $this->last_item_seen.' of type '.$this->items[$this->last_item_seen]->get_type(), 0);
} }
@ -1597,11 +1597,11 @@ class learnpath {
$index = 0; $index = 0;
// Loop through all ordered items and stop at the first item that is // Loop through all ordered items and stop at the first item that is
// not a directory *and* that has not been completed yet. // not a directory *and* that has not been completed yet.
while ( !empty($this->ordered_items[$index]) AND while ( !empty($this->ordered_items[$index]) AND
is_a($this->items[$this->ordered_items[$index]], 'learnpathItem') AND is_a($this->items[$this->ordered_items[$index]], 'learnpathItem') AND
( (
$this->items[$this->ordered_items[$index]]->get_type() == 'dir' OR $this->items[$this->ordered_items[$index]]->get_type() == 'dir' OR
$this->items[$this->ordered_items[$index]]->get_type() == 'dokeos_chapter' OR $this->items[$this->ordered_items[$index]]->get_type() == 'dokeos_chapter' OR
$this->items[$this->ordered_items[$index]]->is_done() === true $this->items[$this->ordered_items[$index]]->is_done() === true
) AND $index < $this->max_ordered_items) { ) AND $index < $this->max_ordered_items) {
$index++; $index++;
@ -1619,7 +1619,7 @@ class learnpath {
} }
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - In learnpath::first() - First item is ' . $this->get_current_item_id()); error_log('New LP - In learnpath::first() - First item is ' . $this->get_current_item_id());
} }
} }
/** /**
@ -1722,7 +1722,7 @@ class learnpath {
$navbar = null; $navbar = null;
$lp_id = $this->lp_id; $lp_id = $this->lp_id;
$mycurrentitemid = $this->get_current_item_id(); $mycurrentitemid = $this->get_current_item_id();
if ($this->mode == 'fullscreen') { if ($this->mode == 'fullscreen') {
$navbar = ' $navbar = '
<div class="buttons"> <div class="buttons">
@ -2555,7 +2555,7 @@ class learnpath {
* @todo Translate labels * @todo Translate labels
*/ */
public function get_iv_objectives_array($lp_iv_id = 0) { public function get_iv_objectives_array($lp_iv_id = 0) {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE); $table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE);
$sql = "SELECT * FROM $table WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id ORDER BY order_id ASC"; $sql = "SELECT * FROM $table WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id ORDER BY order_id ASC";
$res = Database::query($sql); $res = Database::query($sql);
@ -2629,7 +2629,7 @@ class learnpath {
} }
$toc = $varname.' = new Array();'; $toc = $varname.' = new Array();';
//echo "<pre>".print_r($this->items,true)."</pre>"; //echo "<pre>".print_r($this->items,true)."</pre>";
foreach ($this->ordered_items as $item_id) { foreach ($this->ordered_items as $item_id) {
$toc.= $varname."['i$item_id'] = '".$this->items[$item_id]->get_type()."';"; $toc.= $varname."['i$item_id'] = '".$this->items[$item_id]->get_type()."';";
} }
if ($this->debug > 2) { if ($this->debug > 2) {
@ -2715,29 +2715,29 @@ class learnpath {
* Uses the table generated by get_toc() and returns an HTML-formatted string ready to display * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
* @return string HTML TOC ready to display * @return string HTML TOC ready to display
*/ */
public function get_html_toc($toc_list = null) { public function get_html_toc($toc_list = null) {
global $_configuration; global $_configuration;
$is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false); $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
if ($this->debug > 0) { if ($this->debug > 0) {
error_log('New LP - In learnpath::get_html_toc()', 0); error_log('New LP - In learnpath::get_html_toc()', 0);
} }
if (empty($toc_list)) { if (empty($toc_list)) {
$toc_list = $this->get_toc(); $toc_list = $this->get_toc();
} }
$html = '<div id="scorm_title" class="scorm_title">' . Security::remove_XSS($this->get_name()) . '</div>'; $html = '<div id="scorm_title" class="scorm_title">' . Security::remove_XSS($this->get_name()) . '</div>';
$hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true; $hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true;
if ($is_allowed_to_edit && $hide_teacher_icons_lp == false) { if ($is_allowed_to_edit && $hide_teacher_icons_lp == false) {
$gradebook = Security :: remove_XSS($_GET['gradebook']); $gradebook = Security :: remove_XSS($_GET['gradebook']);
if ($this->get_lp_session_id() == api_get_session_id()) { if ($this->get_lp_session_id() == api_get_session_id()) {
$html .= '<div id="actions_lp" class="actions_lp">'; $html .= '<div id="actions_lp" class="actions_lp">';
$html .= '<div class="btn-group">'; $html .= '<div class="btn-group">';
$html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=build&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Overview') . "</a>"; $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=build&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Overview') . "</a>";
$html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;action=add_item&amp;type=step&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Edit') . "</a>"; $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;action=add_item&amp;type=step&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Edit') . "</a>";
$html .= '<a class="btn" href="lp_controller.php?'.api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=edit&amp;lp_id=" . $this->lp_id.'">'.get_lang('Settings').'</a>'; $html .= '<a class="btn" href="lp_controller.php?'.api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=edit&amp;lp_id=" . $this->lp_id.'">'.get_lang('Settings').'</a>';
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';
} }
} }
@ -2748,7 +2748,7 @@ class learnpath {
$mycurrentitemid = $this->get_current_item_id(); $mycurrentitemid = $this->get_current_item_id();
$color_counter = 0; $color_counter = 0;
$i = 0; $i = 0;
foreach ($toc_list as $item) { foreach ($toc_list as $item) {
if ($this->debug > 2) { if ($this->debug > 2) {
//error_log('New LP - learnpath::get_html_toc(): using item ' . $item['id'], 0); //error_log('New LP - learnpath::get_html_toc(): using item ' . $item['id'], 0);
@ -2900,7 +2900,7 @@ class learnpath {
*/ */
public function get_link($type = 'http', $item_id = null, $provided_toc = false) { public function get_link($type = 'http', $item_id = null, $provided_toc = false) {
$course_id = $this->get_course_int_id(); $course_id = $this->get_course_int_id();
if ($this->debug > 0) { if ($this->debug > 0) {
error_log('New LP - In learnpath::get_link(' . $type . ',' . $item_id . ')', 0); error_log('New LP - In learnpath::get_link(' . $type . ',' . $item_id . ')', 0);
} }
@ -2928,8 +2928,8 @@ class learnpath {
$item_id = Database::escape_string($item_id); $item_id = Database::escape_string($item_id);
$sql = "SELECT l.lp_type as ltype, l.path as lpath, li.item_type as litype, li.path as lipath, li.parameters as liparams $sql = "SELECT l.lp_type as ltype, l.path as lpath, li.item_type as litype, li.path as lipath, li.parameters as liparams
FROM $lp_table l FROM $lp_table l
INNER JOIN $lp_item_table li INNER JOIN $lp_item_table li
ON (li.lp_id = l.id AND l.c_id = $course_id AND li.c_id = $course_id ) ON (li.lp_id = l.id AND l.c_id = $course_id AND li.c_id = $course_id )
WHERE li.id = $item_id "; WHERE li.id = $item_id ";
if ($this->debug > 2) { if ($this->debug > 2) {
@ -2945,7 +2945,7 @@ class learnpath {
$lp_item_params = $row['liparams']; $lp_item_params = $row['liparams'];
if (empty ($lp_item_params) && strpos($lp_item_path, '?') !== false) { if (empty ($lp_item_params) && strpos($lp_item_path, '?') !== false) {
list ($lp_item_path, $lp_item_params) = explode('?', $lp_item_path); list ($lp_item_path, $lp_item_params) = explode('?', $lp_item_path);
} }
$sys_course_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path(); $sys_course_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path();
if ($type == 'http') { if ($type == 'http') {
$course_path = api_get_path(WEB_COURSE_PATH) . api_get_course_path(); //web path $course_path = api_get_path(WEB_COURSE_PATH) . api_get_course_path(); //web path
@ -2957,23 +2957,23 @@ class learnpath {
if (in_array($lp_item_type, array('quiz', 'document', 'link', 'forum', 'thread', 'student_publication'))) { if (in_array($lp_item_type, array('quiz', 'document', 'link', 'forum', 'thread', 'student_publication'))) {
$lp_type = 1; $lp_type = 1;
} }
if ($this->debug > 2) { if ($this->debug > 2) {
error_log('New LP - In learnpath::get_link() - $lp_type ' . $lp_type, 0); error_log('New LP - In learnpath::get_link() - $lp_type ' . $lp_type, 0);
error_log('New LP - In learnpath::get_link() - $lp_item_type ' . $lp_item_type, 0); error_log('New LP - In learnpath::get_link() - $lp_item_type ' . $lp_item_type, 0);
} }
// Now go through the specific cases to get the end of the path // Now go through the specific cases to get the end of the path
// @todo Use constants instead of int values. // @todo Use constants instead of int values.
switch ($lp_type) { switch ($lp_type) {
case 1 : case 1 :
if ($lp_item_type == 'dokeos_chapter') { if ($lp_item_type == 'dokeos_chapter') {
$file = 'lp_content.php?type=dir'; $file = 'lp_content.php?type=dir';
} else { } else {
require_once 'resourcelinker.inc.php'; require_once 'resourcelinker.inc.php';
$file = rl_get_resource_link_for_learnpath($course_id, $this->get_id(), $item_id); $file = rl_get_resource_link_for_learnpath($course_id, $this->get_id(), $item_id);
if ($this->debug > 0) { if ($this->debug > 0) {
error_log('rl_get_resource_link_for_learnpath - file: ' . $file, 0); error_log('rl_get_resource_link_for_learnpath - file: ' . $file, 0);
} }
@ -2988,13 +2988,13 @@ class learnpath {
// check how much attempts of a exercise exits in lp // check how much attempts of a exercise exits in lp
$lp_item_id = $this->get_current_item_id(); $lp_item_id = $this->get_current_item_id();
$lp_view_id = $this->get_view_id(); $lp_view_id = $this->get_view_id();
$prevent_reinit = null; $prevent_reinit = null;
if (isset($this->items[$this->current])) { if (isset($this->items[$this->current])) {
$prevent_reinit = $this->items[$this->current]->get_prevent_reinit(); $prevent_reinit = $this->items[$this->current]->get_prevent_reinit();
} }
if (empty($provided_toc)) { if (empty($provided_toc)) {
if ($this->debug > 0) { if ($this->debug > 0) {
error_log('In learnpath::get_link() Loading get_toc ', 0); error_log('In learnpath::get_link() Loading get_toc ', 0);
} }
@ -3005,7 +3005,7 @@ class learnpath {
} }
$list = $provided_toc; $list = $provided_toc;
} }
$type_quiz = false; $type_quiz = false;
foreach ($list as $toc) { foreach ($list as $toc) {
@ -3100,7 +3100,7 @@ class learnpath {
//prerequisites did not match //prerequisites did not match
//$file = 'blank.php'; //$file = 'blank.php';
//} //}
// We want to use parameters if they were defined in the imsmanifest // We want to use parameters if they were defined in the imsmanifest
if (strpos($file, 'blank.php') === false) { if (strpos($file, 'blank.php') === false) {
$file .= (strstr($file, '?') === false ? '?' : '') . $lp_item_params; $file .= (strstr($file, '?') === false ? '?' : '') . $lp_item_params;
} }
@ -3520,7 +3520,7 @@ class learnpath {
error_log('New LP - In learnpath::next()', 0); error_log('New LP - In learnpath::next()', 0);
} }
$this->last = $this->get_current_item_id(); $this->last = $this->get_current_item_id();
$this->items[$this->last]->save(false, $this->prerequisites_match($this->last)); $this->items[$this->last]->save(false, $this->prerequisites_match($this->last));
$this->autocomplete_parents($this->last); $this->autocomplete_parents($this->last);
$new_index = $this->get_next_index(); $new_index = $this->get_next_index();
if ($this->debug > 2) { if ($this->debug > 2) {
@ -3658,7 +3658,7 @@ class learnpath {
$v = 1; $v = 1;
} }
} else { } else {
return false; return false;
} }
$session_id = api_get_session_id(); $session_id = api_get_session_id();
@ -3683,7 +3683,7 @@ class learnpath {
return false; return false;
} }
$result = Database::query($sql); $result = Database::query($sql);
//if ($this->debug > 2) { error_log('New LP - Leaving learnpath::toggle_visibility: '.$sql, 0); } //if ($this->debug > 2) { error_log('New LP - Leaving learnpath::toggle_visibility: '.$sql, 0); }
} }
/** /**
@ -3743,7 +3743,7 @@ class learnpath {
} }
if (is_object($this->items[$this->current])) { if (is_object($this->items[$this->current])) {
//$res = $this->items[$this->current]->save(false); //$res = $this->items[$this->current]->save(false);
$res = $this->items[$this->current]->save(false, $this->prerequisites_match($this->current)); $res = $this->items[$this->current]->save(false, $this->prerequisites_match($this->current));
$this->autocomplete_parents($this->current); $this->autocomplete_parents($this->current);
$status = $this->items[$this->current]->get_status(); $status = $this->items[$this->current]->get_status();
$this->append_message('new_item_status: ' . $status); $this->append_message('new_item_status: ' . $status);
@ -3759,7 +3759,7 @@ class learnpath {
* @param boolean Save from url params (true) or from current attributes (false). Optional. Defaults to true * @param boolean Save from url params (true) or from current attributes (false). Optional. Defaults to true
* @return boolean * @return boolean
*/ */
public function save_item($item_id = null, $from_outside = true) { public function save_item($item_id = null, $from_outside = true) {
$debug = $this->debug; $debug = $this->debug;
if ($debug) { if ($debug) {
error_log('In learnpath::save_item(' . $item_id . ',' . intval($from_outside). ')', 0); error_log('In learnpath::save_item(' . $item_id . ',' . intval($from_outside). ')', 0);
@ -3774,15 +3774,15 @@ class learnpath {
} }
if (isset($this->items[$item_id]) && is_object($this->items[$item_id])) { if (isset($this->items[$item_id]) && is_object($this->items[$item_id])) {
if ($debug) { error_log('Object exists'); } if ($debug) { error_log('Object exists'); }
$res = $this->items[$item_id]->save($from_outside, $this->prerequisites_match($item_id)); $res = $this->items[$item_id]->save($from_outside, $this->prerequisites_match($item_id));
$this->autocomplete_parents($item_id); $this->autocomplete_parents($item_id);
if ($debug) { if ($debug) {
error_log('update_queue before:'); error_log('update_queue before:');
error_log(print_r($this->update_queue,1)); error_log(print_r($this->update_queue,1));
} }
$status = $this->items[$item_id]->get_status(); $status = $this->items[$item_id]->get_status();
$this->update_queue[$item_id] = $status; $this->update_queue[$item_id] = $status;
if ($debug) { if ($debug) {
error_log('get_status(): ' . $status); error_log('get_status(): ' . $status);
error_log('update_queue after:'); error_log('update_queue after:');
@ -3808,8 +3808,8 @@ class learnpath {
error_log('New LP - Saving current item (' . $this->current . ') for later review', 0); error_log('New LP - Saving current item (' . $this->current . ') for later review', 0);
} }
$sql = "UPDATE $table SET last_item = " . Database::escape_string($this->get_current_item_id()). " $sql = "UPDATE $table SET last_item = " . Database::escape_string($this->get_current_item_id()). "
WHERE c_id = $course_id AND WHERE c_id = $course_id AND
lp_id = " . $this->get_id() . " AND lp_id = " . $this->get_id() . " AND
user_id = " . $this->get_user_id()." ".$session_condition; user_id = " . $this->get_user_id()." ".$session_condition;
if ($this->debug > 2) { if ($this->debug > 2) {
@ -3822,9 +3822,9 @@ class learnpath {
list($progress, $text) = $this->get_progress_bar_text('%'); list($progress, $text) = $this->get_progress_bar_text('%');
if ($progress >= 0 && $progress <= 100) { if ($progress >= 0 && $progress <= 100) {
$progress = (int) $progress; $progress = (int) $progress;
$sql = "UPDATE $table SET progress = $progress $sql = "UPDATE $table SET progress = $progress
WHERE c_id = ".$course_id." AND WHERE c_id = ".$course_id." AND
lp_id = " . $this->get_id() . " AND lp_id = " . $this->get_id() . " AND
user_id = " . $this->get_user_id()." ".$session_condition; user_id = " . $this->get_user_id()." ".$session_condition;
$res = Database::query($sql); // Ignore errors as some tables might not have the progress field just yet. $res = Database::query($sql); // Ignore errors as some tables might not have the progress field just yet.
$this->progress_db = $progress; $this->progress_db = $progress;
@ -3995,7 +3995,7 @@ class learnpath {
if (Database::affected_rows()) { if (Database::affected_rows()) {
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$session_condition = api_get_session_condition($session_id); $session_condition = api_get_session_condition($session_id);
$tbl_tool = Database :: get_course_table(TABLE_TOOL_LIST); $tbl_tool = Database :: get_course_table(TABLE_TOOL_LIST);
$link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id.'&id_session='.$session_id; $link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id.'&id_session='.$session_id;
$sql = "UPDATE $tbl_tool SET name = '$this->name' $sql = "UPDATE $tbl_tool SET name = '$this->name'
WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)"; WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
@ -4004,7 +4004,7 @@ class learnpath {
} else { } else {
return false; return false;
} }
} }
/** /**
@ -4695,7 +4695,7 @@ class learnpath {
} }
return -1; return -1;
} }
/** /**
* Updates the "scorm_debug" value that shows or hide the debug window * Updates the "scorm_debug" value that shows or hide the debug window
* @return boolean True if scorm_debug has been set to 'on', false otherwise (or 1 or 0 in this case) * @return boolean True if scorm_debug has been set to 'on', false otherwise (or 1 or 0 in this case)
@ -5037,15 +5037,15 @@ class learnpath {
$elements = array(); $elements = array();
for ($i = 0; $i < count($arrLP); $i++) { for ($i = 0; $i < count($arrLP); $i++) {
$title = $arrLP[$i]['title']; $title = $arrLP[$i]['title'];
$title_cut = cut($arrLP[$i]['title'], 25); $title_cut = cut($arrLP[$i]['title'], 25);
//Link for the documents //Link for the documents
if ($arrLP[$i]['item_type'] == 'document') { if ($arrLP[$i]['item_type'] == 'document') {
$url = api_get_self() . '?'.api_get_cidreq().'&amp;action=view_item&amp;mode=preview_document&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id; $url = api_get_self() . '?'.api_get_cidreq().'&amp;action=view_item&amp;mode=preview_document&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id;
$title_cut = Display::url($title_cut, $url, array('class' => 'ajax')); $title_cut = Display::url($title_cut, $url, array('class' => 'ajax'));
} }
if (($i % 2) == 0) { if (($i % 2) == 0) {
$oddclass = 'row_odd'; $oddclass = 'row_odd';
} else { } else {
@ -5070,7 +5070,7 @@ class learnpath {
$return_audio .= '<td align="center">'; $return_audio .= '<td align="center">';
$audio = ''; $audio = '';
if (!$update_audio OR $update_audio <> 'true') { if (!$update_audio OR $update_audio <> 'true') {
if (!empty($arrLP[$i]['audio'])) { if (!empty($arrLP[$i]['audio'])) {
/*$audio .= '<span id="container'.$i.'"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</span>'; /*$audio .= '<span id="container'.$i.'"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</span>';
@ -5126,10 +5126,10 @@ class learnpath {
$delete_icon .= '</a>'; $delete_icon .= '</a>';
$url = api_get_self() . '?cidReq='.Security::remove_XSS($_GET['cidReq']).'&view=build&id='.$arrLP[$i]['id'] .'&lp_id='.$this->lp_id; $url = api_get_self() . '?cidReq='.Security::remove_XSS($_GET['cidReq']).'&view=build&id='.$arrLP[$i]['id'] .'&lp_id='.$this->lp_id;
if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module', 'dir'))) { if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module', 'dir'))) {
$prerequisities_icon = Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_TINY), $url.'&action=edit_item_prereq'); $prerequisities_icon = Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_TINY), $url.'&action=edit_item_prereq');
$move_item_icon = Display::url(Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_TINY), $url.'&action=move_item'); $move_item_icon = Display::url(Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_TINY), $url.'&action=move_item');
$audio_icon = Display::url(Display::return_icon('audio.png', get_lang('UplUpload'), array(), ICON_SIZE_TINY), $url.'&action=add_audio'); $audio_icon = Display::url(Display::return_icon('audio.png', get_lang('UplUpload'), array(), ICON_SIZE_TINY), $url.'&action=add_audio');
} }
} }
@ -5261,9 +5261,9 @@ class learnpath {
//$return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;gradebook=' . $gradebook . '&amp;action=add_item&amp;type=step&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="' . get_lang('NewStep') . '">' . Display :: return_icon('new_learnigpath_object.png', get_lang('NewStep'),'',ICON_SIZE_MEDIUM).'</a>'; //$return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;gradebook=' . $gradebook . '&amp;action=add_item&amp;type=step&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="' . get_lang('NewStep') . '">' . Display :: return_icon('new_learnigpath_object.png', get_lang('NewStep'),'',ICON_SIZE_MEDIUM).'</a>';
// echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;gradebook=' . $gradebook . '&amp;action=add_item&amp;type=chapter&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="' . get_lang('NewChapter') . '">' . Display :: return_icon('add_learnpath_section.png', get_lang('NewChapter'),'',ICON_SIZE_MEDIUM).'</a>'; // echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;gradebook=' . $gradebook . '&amp;action=add_item&amp;type=chapter&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="' . get_lang('NewChapter') . '">' . Display :: return_icon('add_learnpath_section.png', get_lang('NewChapter'),'',ICON_SIZE_MEDIUM).'</a>';
$return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '&amp;updateaudio=true">' . Display :: return_icon('upload_audio.png', get_lang('UpdateAllAudioFragments'),'',ICON_SIZE_MEDIUM).'</a>'; $return .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '&amp;updateaudio=true">' . Display :: return_icon('upload_audio.png', get_lang('UpdateAllAudioFragments'),'',ICON_SIZE_MEDIUM).'</a>';
$return .= '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=edit&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display :: return_icon('settings.png', get_lang('CourseSettings'),'',ICON_SIZE_MEDIUM).'</a>'; $return .= '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=edit&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display :: return_icon('settings.png', get_lang('CourseSettings'),'',ICON_SIZE_MEDIUM).'</a>';
$return .= '</div>'; $return .= '</div>';
echo $return; echo $return;
@ -5365,12 +5365,12 @@ class learnpath {
public function generate_lp_folder($course, $lp_name = null) { public function generate_lp_folder($course, $lp_name = null) {
$filepath = ''; $filepath = '';
$dir = '/learning_path/'; $dir = '/learning_path/';
if (empty($lp_name)) { if (empty($lp_name)) {
$lp_name = $this->name; $lp_name = $this->name;
} }
$folder = self::generate_learning_path_folder($course); $folder = self::generate_learning_path_folder($course);
//Creating LP folder //Creating LP folder
if ($folder) { if ($folder) {
//Limits title size //Limits title size
@ -5564,7 +5564,7 @@ class learnpath {
if ($row['item_type'] != 'dokeos_chapter' || $row['item_type'] != 'dokeos_module') { if ($row['item_type'] != 'dokeos_chapter' || $row['item_type'] != 'dokeos_module') {
$_SESSION['parent_item_id'] = $row['parent_item_id']; $_SESSION['parent_item_id'] = $row['parent_item_id'];
} }
if ($show_actions) { if ($show_actions) {
$return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_manipulate($item_id, $row['item_type']);
} }
@ -5619,7 +5619,7 @@ class learnpath {
public function display_edit_item($item_id) { public function display_edit_item($item_id) {
global $_course; // It will disappear. global $_course; // It will disappear.
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$return = ''; $return = '';
if (is_numeric($item_id)) { if (is_numeric($item_id)) {
$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 WHERE c_id = ".$course_id." AND id = " . Database::escape_string($item_id); $sql = "SELECT * FROM $tbl_lp_item WHERE c_id = ".$course_id." AND id = " . Database::escape_string($item_id);
@ -5632,7 +5632,7 @@ class learnpath {
case 'asset' : case 'asset' :
case 'sco' : case 'sco' :
if (isset ($_GET['view']) && $_GET['view'] == 'build') { if (isset ($_GET['view']) && $_GET['view'] == 'build') {
$return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_item_form($row['item_type'], get_lang('EditCurrentChapter') . ' :', 'edit', $item_id, $row); $return .= $this->display_item_form($row['item_type'], get_lang('EditCurrentChapter') . ' :', 'edit', $item_id, $row);
} else { } else {
$return .= $this->display_item_small_form($row['item_type'], get_lang('EditCurrentChapter') . ' :', $row); $return .= $this->display_item_small_form($row['item_type'], get_lang('EditCurrentChapter') . ' :', $row);
@ -5678,7 +5678,7 @@ class learnpath {
$return .= $this->display_quiz_form('edit', $item_id, $row); $return .= $this->display_quiz_form('edit', $item_id, $row);
break; break;
case TOOL_HOTPOTATOES : case TOOL_HOTPOTATOES :
$return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_hotpotatoes_form('edit', $item_id, $row); $return .= $this->display_hotpotatoes_form('edit', $item_id, $row);
break; break;
case TOOL_STUDENTPUBLICATION : case TOOL_STUDENTPUBLICATION :
@ -5730,7 +5730,7 @@ class learnpath {
Display::return_icon('add_learnpath_section.png', get_lang('NewChapter'), array(), 64) Display::return_icon('add_learnpath_section.png', get_lang('NewChapter'), array(), 64)
); );
echo Display::display_normal_message(get_lang('ClickOnTheLearnerViewToSeeYourLearningPath')); echo Display::display_normal_message(get_lang('ClickOnTheLearnerViewToSeeYourLearningPath'));
$chapter = $_SESSION['oLP']->display_item_form('chapter', get_lang('EnterDataNewChapter'), 'add_item'); $chapter = $_SESSION['oLP']->display_item_form('chapter', get_lang('EnterDataNewChapter'), 'add_item');
echo Display::tabs($headers, array($documents, $exercises, $links, $works, $forums, $chapter), 'resource_tab'); echo Display::tabs($headers, array($documents, $exercises, $links, $works, $forums, $chapter), 'resource_tab');
return true; return true;
} }
@ -6576,7 +6576,7 @@ class learnpath {
if ($id != 0 && is_array($extra_info)) { if ($id != 0 && is_array($extra_info)) {
$item_title = $extra_info['title']; $item_title = $extra_info['title'];
$item_description = $extra_info['description']; $item_description = $extra_info['description'];
$item_path = api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/scorm/' . $this->path . '/' . stripslashes($extra_info['path']); $item_path = api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/scorm/' . $this->path . '/' . stripslashes($extra_info['path']);
$item_path_fck = '/scorm/' . $this->path . '/' . stripslashes($extra_info['path']); $item_path_fck = '/scorm/' . $this->path . '/' . stripslashes($extra_info['path']);
} else { } else {
@ -6585,7 +6585,7 @@ class learnpath {
$item_path_fck = ''; $item_path_fck = '';
} }
if ($id != 0 && is_array($extra_info)) if ($id != 0 && is_array($extra_info))
$parent = $extra_info['parent_item_id']; $parent = $extra_info['parent_item_id'];
@ -6625,7 +6625,7 @@ class learnpath {
unset ($this->arrMenu); unset ($this->arrMenu);
$gradebook = isset($_GET['gradebook']) ? Security :: remove_XSS($_GET['gradebook']) : null; $gradebook = isset($_GET['gradebook']) ? Security :: remove_XSS($_GET['gradebook']) : null;
$url = api_get_self() . '?' .api_get_cidreq().'&gradeboook='.$gradebook.'&action='.$action.'&type='.$item_type.'&lp_id='.$this->lp_id; $url = api_get_self() . '?' .api_get_cidreq().'&gradeboook='.$gradebook.'&action='.$action.'&type='.$item_type.'&lp_id='.$this->lp_id;
$form = new FormValidator('form', 'POST', $url); $form = new FormValidator('form', 'POST', $url);
@ -6691,7 +6691,7 @@ class learnpath {
//this is the same! //this is the same!
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']; $s_selected_position = $arrLP[$i]['id'];
} elseif ($action == 'add') { } elseif ($action == 'add') {
$s_selected_position = $arrLP[$i]['id']; $s_selected_position = $arrLP[$i]['id'];
} }
@ -6730,13 +6730,13 @@ class learnpath {
$extension = null; $extension = null;
if (!empty($item_path)) { if (!empty($item_path)) {
$extension = pathinfo($item_path, PATHINFO_EXTENSION); $extension = pathinfo($item_path, PATHINFO_EXTENSION);
} }
//assets can't be modified //assets can't be modified
//$item_type == 'asset' || //$item_type == 'asset' ||
if (( $item_type == 'sco') && ($extension == 'html' || $extension == 'htm')) { if (( $item_type == 'sco') && ($extension == 'html' || $extension == 'htm')) {
if ($item_type == 'sco') { if ($item_type == 'sco') {
$form->addElement('html', '<script type="text/javascript">alert("' . get_lang('WarningWhenEditingScorm') . '")</script>'); $form->addElement('html', '<script type="text/javascript">alert("' . get_lang('WarningWhenEditingScorm') . '")</script>');
} }
@ -6777,7 +6777,7 @@ class learnpath {
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
$no_display_edit_textarea = false; $no_display_edit_textarea = false;
//If action==edit document //If action==edit document
@ -7494,7 +7494,7 @@ class learnpath {
public function display_manipulate($item_id, $item_type = TOOL_DOCUMENT) { public function display_manipulate($item_id, $item_type = TOOL_DOCUMENT) {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$course_code = api_get_course_id(); $course_code = api_get_course_id();
global $charset, $_course; global $charset, $_course;
$return = '<div class="actions">'; $return = '<div class="actions">';
@ -7539,7 +7539,7 @@ class learnpath {
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_assoc($result); $row = Database::fetch_assoc($result);
$audio_player = null; $audio_player = null;
// We display an audio player if needed. // We display an audio player if needed.
if (!empty($row['audio'])) { if (!empty($row['audio'])) {
@ -7562,23 +7562,23 @@ class learnpath {
$return .= Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_SMALL), $url.'&action=edit_item_prereq'); $return .= Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_SMALL), $url.'&action=edit_item_prereq');
} }
$return .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), $url.'&action=delete_item'); $return .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), $url.'&action=delete_item');
if ($item_type == TOOL_HOTPOTATOES ) { if ($item_type == TOOL_HOTPOTATOES ) {
$document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code); $document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code);
$return .= get_lang('File').': '.$document_data['absolute_path_from_document']; $return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
} }
if ($item_type == TOOL_DOCUMENT ) { if ($item_type == TOOL_DOCUMENT ) {
$document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code); $document_data = DocumentManager::get_document_data_by_id($row['path'], $course_code);
$return .= get_lang('File').': '.$document_data['absolute_path_from_document']; $return .= get_lang('File').': '.$document_data['absolute_path_from_document'];
} }
$return .= '</div>'; $return .= '</div>';
if (!empty($audio_player)) { if (!empty($audio_player)) {
$return .= '<br />'.$audio_player; $return .= '<br />'.$audio_player;
} }
return $return; return $return;
} }
@ -7704,7 +7704,7 @@ class learnpath {
* @param array $data * @param array $data
* @return string * @return string
*/ */
public function display_item_small_form($item_type, $title = '', $data = array()) { public function display_item_small_form($item_type, $title = '', $data = array()) {
$url = api_get_self() . '?' .api_get_cidreq().'&action=edit_item&lp_id='.$this->lp_id; $url = api_get_self() . '?' .api_get_cidreq().'&action=edit_item&lp_id='.$this->lp_id;
$form = new FormValidator('small_form', 'post', $url); $form = new FormValidator('small_form', 'post', $url);
$form->addElement('header', $title); $form->addElement('header', $title);
@ -7712,7 +7712,7 @@ class learnpath {
$form->addElement('button', 'submit_button', get_lang('Save')); $form->addElement('button', 'submit_button', get_lang('Save'));
$form->addElement('hidden', 'id', $data['id']); $form->addElement('hidden', 'id', $data['id']);
$form->addElement('hidden', 'parent', $data['parent_item_id']); $form->addElement('hidden', 'parent', $data['parent_item_id']);
$form->addElement('hidden', 'previous', $data['previous_item_id']); $form->addElement('hidden', 'previous', $data['previous_item_id']);
$form->setDefaults(array('title' => $data['title'])); $form->setDefaults(array('title' => $data['title']));
return $form->toHtml(); return $form->toHtml();
} }
@ -7736,11 +7736,11 @@ class learnpath {
//$preq_max = $row['max_score']; //$preq_max = $row['max_score'];
$return = $this->display_manipulate($item_id, TOOL_DOCUMENT); $return = $this->display_manipulate($item_id, TOOL_DOCUMENT);
$return = '<legend>'; $return = '<legend>';
$return .= get_lang('AddEditPrerequisites'); $return .= get_lang('AddEditPrerequisites');
$return .= '</legend>'; $return .= '</legend>';
$return .= '<div class="sectioncomment">'; $return .= '<div class="sectioncomment">';
$return .= '<form method="POST">'; $return .= '<form method="POST">';
@ -7911,11 +7911,11 @@ class learnpath {
// Display hotpotatoes // Display hotpotatoes
while ($row_hot = Database :: fetch_array($res_hot)) { while ($row_hot = Database :: fetch_array($res_hot)) {
$return .= '<li class="lp_resource_element" data_id="'.$row_hot['id'].'" data_type="hotpotatoes" title="'.$row_hot['title'].'" >'; $return .= '<li class="lp_resource_element" data_id="'.$row_hot['id'].'" data_type="hotpotatoes" title="'.$row_hot['title'].'" >';
$return .= '<a class="moved" href="#">'; $return .= '<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$return .= '</a> '; $return .= '</a> ';
$return .= '<img src="../img/hotpotatoes_s.png" style="margin-right:5px;" title="" width="16px" />'; $return .= '<img src="../img/hotpotatoes_s.png" style="margin-right:5px;" title="" width="16px" />';
$return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']).'&amp;action=add_item&amp;type=' . TOOL_HOTPOTATOES . '&amp;file=' . $row_hot['id'] . '&amp;lp_id=' . $this->lp_id . '">'. $return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']).'&amp;action=add_item&amp;type=' . TOOL_HOTPOTATOES . '&amp;file=' . $row_hot['id'] . '&amp;lp_id=' . $this->lp_id . '">'.
((!empty ($row_hot['comment'])) ? $row_hot['comment'] : Security :: remove_XSS($row_hot['title'])) . '</a>'; ((!empty ($row_hot['comment'])) ? $row_hot['comment'] : Security :: remove_XSS($row_hot['title'])) . '</a>';
@ -7924,11 +7924,11 @@ class learnpath {
while ($row_quiz = Database :: fetch_array($res_quiz)) { while ($row_quiz = Database :: fetch_array($res_quiz)) {
$return .= '<li class="lp_resource_element" data_id="'.$row_quiz['id'].'" data_type="quiz" title="'.$row_quiz['title'].'" >'; $return .= '<li class="lp_resource_element" data_id="'.$row_quiz['id'].'" data_type="quiz" title="'.$row_quiz['title'].'" >';
$return .= '<a class="moved" href="#">'; $return .= '<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$return .= '</a> '; $return .= '</a> ';
$return .= '<img alt="" src="../img/quizz_small.gif" style="margin-right:5px;" title="" />'; $return .= '<img alt="" src="../img/quizz_small.gif" style="margin-right:5px;" title="" />';
$return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=' . TOOL_QUIZ . '&amp;file=' . $row_quiz['id'] . '&amp;lp_id=' . $this->lp_id . '">' . $return .= '<a href="' . api_get_self() . '?cidReq=' . Security :: remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=' . TOOL_QUIZ . '&amp;file=' . $row_quiz['id'] . '&amp;lp_id=' . $this->lp_id . '">' .
Security :: remove_XSS(cut($row_quiz['title'], 80)). Security :: remove_XSS(cut($row_quiz['title'], 80)).
@ -7986,7 +7986,7 @@ class learnpath {
* Creates a list with all the student publications in it * Creates a list with all the student publications in it
* @return unknown * @return unknown
*/ */
public function get_student_publications() { public function get_student_publications() {
$return = '<div class="lp_resource" >'; $return = '<div class="lp_resource" >';
$return .= '<div class="lp_resource_element">'; $return .= '<div class="lp_resource_element">';
$return .= '<img align="left" alt="" src="../img/works_small.gif" style="margin-right:5px;" title="" />'; $return .= '<img align="left" alt="" src="../img/works_small.gif" style="margin-right:5px;" title="" />';
@ -8179,12 +8179,12 @@ class learnpath {
// Removes the learning_path/scorm_folder path when exporting see #4841 // Removes the learning_path/scorm_folder path when exporting see #4841
$path_to_remove = null; $path_to_remove = null;
$result = $this->generate_lp_folder($_course); $result = $this->generate_lp_folder($_course);
if (isset($result['dir']) && strpos($result['dir'], 'learning_path')) { if (isset($result['dir']) && strpos($result['dir'], 'learning_path')) {
$path_to_remove = 'document'.$result['dir']; $path_to_remove = 'document'.$result['dir'];
$path_to_replace = $folder_name.'/'; $path_to_replace = $folder_name.'/';
} }
//Fixes chamilo scorm exports //Fixes chamilo scorm exports
if ($this->ref == 'chamilo_scorm_export') { if ($this->ref == 'chamilo_scorm_export') {
$path_to_remove = 'scorm/'.$this->path.'/document/'; $path_to_remove = 'scorm/'.$this->path.'/document/';
@ -8242,14 +8242,14 @@ class learnpath {
$my_file_path = $item->get_file_path('scorm/'.$this->path.'/'); $my_file_path = $item->get_file_path('scorm/'.$this->path.'/');
if (!empty($path_to_remove)) { if (!empty($path_to_remove)) {
//From docs //From docs
$my_xml_file_path = str_replace($path_to_remove, $path_to_replace, $my_file_path); $my_xml_file_path = str_replace($path_to_remove, $path_to_replace, $my_file_path);
//From quiz //From quiz
if ($this->ref == 'chamilo_scorm_export') { if ($this->ref == 'chamilo_scorm_export') {
$path_to_remove = 'scorm/'.$this->path.'/'; $path_to_remove = 'scorm/'.$this->path.'/';
$my_xml_file_path = str_replace($path_to_remove, '', $my_file_path); $my_xml_file_path = str_replace($path_to_remove, '', $my_file_path);
} }
} else { } else {
$my_xml_file_path = $my_file_path; $my_xml_file_path = $my_file_path;
} }
@ -8388,7 +8388,7 @@ class learnpath {
$link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $relative_path); $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $relative_path);
$my_dep_file->setAttribute('href', $file_path); $my_dep_file->setAttribute('href', $file_path);
$my_dep->setAttribute('xml:base', ''); $my_dep->setAttribute('xml:base', '');
} elseif (strstr($file_path, $main_path) !== false) { } elseif (strstr($file_path, $main_path) !== false) {
// The calculated real path is really inside Chamilo's root path. // The calculated real path is really inside Chamilo's root path.
// Reduce file path to what's under the DocumentRoot. // Reduce file path to what's under the DocumentRoot.
$file_path = substr($file_path, strlen($root_path)); $file_path = substr($file_path, strlen($root_path));
@ -8421,7 +8421,7 @@ class learnpath {
$current_dir = str_replace('\\', '/', $current_dir); $current_dir = str_replace('\\', '/', $current_dir);
$file_path = realpath($current_dir.$doc_info[0]); $file_path = realpath($current_dir.$doc_info[0]);
$file_path = str_replace('\\', '/', $file_path); $file_path = str_replace('\\', '/', $file_path);
//error_log($file_path.' <-> '.$main_path,0); //error_log($file_path.' <-> '.$main_path,0);
if (strstr($file_path, $main_path) !== false) { if (strstr($file_path, $main_path) !== false) {
// The calculated real path is really inside Chamilo's root path. // The calculated real path is really inside Chamilo's root path.
@ -8527,7 +8527,7 @@ class learnpath {
$resources->appendChild($my_resource); $resources->appendChild($my_resource);
} }
break; break;
case TOOL_QUIZ: case TOOL_QUIZ:
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.class.php'; require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.class.php';
$exe_id = $item->path; // Should be using ref when everything will be cleaned up in this regard. $exe_id = $item->path; // Should be using ref when everything will be cleaned up in this regard.
$exe = new Exercise(); $exe = new Exercise();
@ -8765,7 +8765,7 @@ class learnpath {
} }
} }
} }
$organizations->appendChild($organization); $organizations->appendChild($organization);
$root->appendChild($organizations); $root->appendChild($organizations);
@ -8804,14 +8804,14 @@ class learnpath {
//Fix to avoid problems with default_course_document //Fix to avoid problems with default_course_document
if (strpos("main/default_course_document", $old_new['dest'] === false)) { if (strpos("main/default_course_document", $old_new['dest'] === false)) {
$new_dest = str_replace('document/', $mult.'document/', $old_new['dest']); $new_dest = str_replace('document/', $mult.'document/', $old_new['dest']);
} else { } else {
//$new_dest = str_replace('main/default_course_document', $mult.'document/main/default_course_document', $old_new['dest']); //$new_dest = str_replace('main/default_course_document', $mult.'document/main/default_course_document', $old_new['dest']);
$new_dest = $old_new['dest']; $new_dest = $old_new['dest'];
} }
//$string = str_replace($old_new['orig'], $old_new['dest'], $string); //$string = str_replace($old_new['orig'], $old_new['dest'], $string);
$string = str_replace($old_new['orig'], $new_dest, $string); $string = str_replace($old_new['orig'], $new_dest, $string);
//Add files inside the HTMLs //Add files inside the HTMLs
$new_path = str_replace('/courses/', '', $old_new['orig']); $new_path = str_replace('/courses/', '', $old_new['orig']);
//var_dump($sys_course_path.$new_path); var_dump($archive_path.$temp_dir_short.'/'.$old_new['dest']); echo '---'; //var_dump($sys_course_path.$new_path); var_dump($archive_path.$temp_dir_short.'/'.$old_new['dest']); echo '---';
@ -8852,7 +8852,7 @@ class learnpath {
file_put_contents($dest_file, $string); file_put_contents($dest_file, $string);
} }
} }
if (is_array($links_to_create)) { if (is_array($links_to_create)) {
foreach ($links_to_create as $file => $link) { foreach ($links_to_create as $file => $link) {
@ -8953,12 +8953,12 @@ EOD;
$list = self::get_flat_ordered_items_list($lp_id); $list = self::get_flat_ordered_items_list($lp_id);
if (!empty($list)) { if (!empty($list)) {
foreach ($list as $item_id) { foreach ($list as $item_id) {
$item = $this->items[$item_id]; $item = $this->items[$item_id];
switch ($item->type) { switch ($item->type) {
case 'document': case 'document':
//Getting documents from a LP with chamilo documents //Getting documents from a LP with chamilo documents
$file_data = DocumentManager::get_document_data_by_id($item->path, $this->cc); $file_data = DocumentManager::get_document_data_by_id($item->path, $this->cc);
$file_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document'.$file_data['path']; $file_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document'.$file_data['path'];
if (file_exists($file_path)) { if (file_exists($file_path)) {
$files_to_export[] = array('title'=>$item->get_title(),'path'=>$file_path); $files_to_export[] = array('title'=>$item->get_title(),'path'=>$file_path);
} }
@ -9153,7 +9153,7 @@ EOD;
$course_restorer->set_tool_copy_settings(array('learnpaths' => array('reset_dates' => true))); $course_restorer->set_tool_copy_settings(array('learnpaths' => array('reset_dates' => true)));
$course_restorer->restore(api_get_course_id(), api_get_session_id(), false, false); $course_restorer->restore(api_get_course_id(), api_get_session_id(), false, false);
} }
function verify_document_size($s) { function verify_document_size($s) {
$post_max = ini_get('post_max_size'); $post_max = ini_get('post_max_size');
$upl_max = ini_get('upload_max_filesize'); $upl_max = ini_get('upload_max_filesize');

Loading…
Cancel
Save