Task #1765 - LP tool, cleaning files (5).

skala
Ivan Tcholakov 14 years ago
parent c40926d29a
commit 4ddb34fef2
  1. 16
      main/newscorm/learnpath.class.php
  2. 844
      main/newscorm/learnpathItem.class.php
  3. 28
      main/newscorm/learnpathList.class.php

@ -57,7 +57,7 @@ class learnpath {
public $proximity; // Wether the content is distant or local or unknown.
public $refs_list = array (); //list of items by ref => db_id. Used only for prerequisites match.
// !!!This array (refs_list) is built differently depending on the nature of the LP.
// If SCORM, uses ref, if Dokeos, uses id to keep a unique value.
// If SCORM, uses ref, if Chamilo, uses id to keep a unique value.
public $type; //type of learnpath. Could be 'dokeos', 'scorm', 'scorm2004', 'aicc', ...
// TODO: Check if this type variable is useful here (instead of just in the controller script).
public $user_id; //ID of the user that is viewing/using the course
@ -174,7 +174,7 @@ class learnpath {
$sql = "SELECT * FROM $lp_table WHERE lp_id = '$lp_id' AND user_id = '$user_id' $session ORDER BY view_count DESC";
if ($this->debug > 2) { error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - querying lp_view: ' . $sql, 0); }
$res = Database::query($sql);
$view_id = 0; // Uused later to query lp_item_view.
$view_id = 0; // Used later to query lp_item_view.
if (Database :: num_rows($res) > 0) {
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Found previous view', 0);
@ -2664,7 +2664,7 @@ class learnpath {
}
// The anchor will let us center the TOC on the currently viewed item &^D
if ($item['type'] != 'dokeos_module' AND $item['type'] != 'dokeos_chapter') {
if ($item['type'] != 'dokeos_module' && $item['type'] != 'dokeos_chapter') {
$html .= '<a name="atoc_' . $item['id'] . '" />';
$html .= '<div class="' . $style_item . '" style="padding-left: ' . ($item['level'] * 1.5) . 'em; padding-right:' . ($item['level'] / 2) . 'em" title="' . $item['description'] . '" >';
} else {
@ -7693,7 +7693,7 @@ class learnpath {
$my_dep_file->setAttribute('href', $file_path);
$my_dep->setAttribute('xml:base', '');
if (strstr($file_path,$main_path) !== false) {
// The calculated real path is really inside the dokeos root path.
// The calculated real path is really inside Chamilo's root path.
// Reduce file path to what's under the DocumentRoot.
$file_path = substr($file_path, strlen($root_path) - 1);
//echo $file_path;echo '<br /><br />';
@ -7777,7 +7777,7 @@ class learnpath {
$my_dep->setAttribute('xml:base', '');
}
elseif(strstr($file_path,$main_path) !== false) {
// The calculated real path is really inside the dokeos root path.
// The calculated real path is really inside Chamilo's root path.
// Reduce file path to what's under the DocumentRoot.
$file_path = substr($file_path,strlen($root_path));
//echo $file_path;echo '<br /><br />';
@ -7810,7 +7810,7 @@ class learnpath {
$file_path = realpath($current_dir.$doc_info[0]);
//error_log($file_path.' <-> '.$main_path,0);
if (strstr($file_path,$main_path) !== false) {
// The calculated real path is really inside the dokeos root path.
// The calculated real path is really inside Chamilo's root path.
// Reduce file path to what's under the DocumentRoot.
$file_path = substr($file_path, strlen($root_path));
//error_log('Reduced path: '.$file_path, 0);
@ -8073,13 +8073,13 @@ class learnpath {
$file_path = realpath($current_dir.$doc_info[0]);
//error_log($file_path.' <-> '.$main_path, 0);
if (strstr($file_path, $main_path) !== false) {
// The calculated real path is really inside the dokeos root path.
// The calculated real path is really inside Chamilo's root path.
// Reduce file path to what's under the DocumentRoot.
$file_path = substr($file_path, strlen($root_path));
$file_path_dest = $file_path;
// File path is courses/DOKEOS/document/....
// File path is courses/CHAMILO/document/....
$info_file_path = explode('/', $file_path);
if ($info_file_path[0] == 'courses') { // Add character "/" in file path.
$file_path_dest = 'document/'.$file_path;

File diff suppressed because it is too large Load Diff

@ -1,10 +1,12 @@
<?php
/* For licensing terms, see /license.txt */
/**
* File containing the declaration of the learnpathList class.
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
/**
* This class is only a learning path list container with several practical methods for sorting the list and
* provide links to specific paths
@ -12,9 +14,9 @@
* @uses learnpath.class.php to generate learnpath objects to get in the list
*/
class learnpathList {
public $list = array(); //holds a flat list of learnpaths data from the database
public $ref_list = array(); //holds a list of references to the learnpaths objects (only filled by get_refs())
public $alpha_list = array(); //holds a flat list of learnpaths sorted by alphabetical name order
public $list = array(); // Holds a flat list of learnpaths data from the database.
public $ref_list = array(); // Holds a list of references to the learnpaths objects (only filled by get_refs()).
public $alpha_list = array(); // Holds a flat list of learnpaths sorted by alphabetical name order.
public $course_code;
public $user_id;
public $refs_active = false;
@ -40,7 +42,7 @@ class learnpathList {
$this->course_code = $course_code;
$this->user_id = $user_id;
//condition for the session
// Condition for the session.
if (isset($session_id)) {
$session_id = intval($session_id);
} else {
@ -51,12 +53,11 @@ class learnpathList {
$sql = "SELECT * FROM $lp_table $condition_session ORDER BY display_order ASC, name ASC";
$res = Database::query($sql);
$names = array();
while ($row = Database::fetch_array($res))
{
//check if published
while ($row = Database::fetch_array($res)) {
// Check if published.
$pub = '';
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
//use domesticate here instead of Database::escape_string because
// Use domesticate here instead of Database::escape_string because
// it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility())
// is done using domesticate()
$myname = domesticate($row['name']);
@ -70,7 +71,7 @@ class learnpathList {
} else {
$pub = 'i';
}
//check if visible
// Check if visible.
$vis = api_get_item_visibility(api_get_course_info($course_code), 'learnpath', $row['id'], $session_id);
$this->list[$row['id']] = array(
@ -95,26 +96,25 @@ class learnpathList {
}
$this->alpha_list = asort($names);
}
/**
* Gets references to learnpaths for all learnpaths IDs kept in the local list.
* This applies a transformation internally on list and ref_list and returns a copy of the refs list
* @return array List of references to learnpath objects
*/
function get_refs() {
foreach($this->list as $id => $dummy)
{
foreach ($this->list as $id => $dummy) {
$this->ref_list[$id] = new learnpath($this->course_code, $id, $this->user_id);
}
$this->refs_active = true;
return $this->ref_list;
}
/**
* Gets a table of the different learnpaths we have at the moment
* @return array Learnpath info as [lp_id] => ([lp_type]=> ..., [lp_name]=>...,[lp_desc]=>...,[lp_path]=>...)
*/
function get_flat_list()
{
function get_flat_list() {
return $this->list;
}
}
?>

Loading…
Cancel
Save