Minor - removing old comments + adding error_logs

skala
Julio Montoya 12 years ago
parent bc8f0852f9
commit 5493bd31a3
  1. 22
      main/newscorm/learnpath.class.php
  2. 34
      main/newscorm/learnpathItem.class.php
  3. 19
      main/newscorm/lp_ajax_initialize.php

@ -97,8 +97,7 @@ class learnpath {
* @return boolean True on success, false on error
*/
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.
// Check params.
$this->encoding = api_get_system_encoding(); // Chamilo 1.8.8: We intend always to use the system encoding.
// Check course code.
$course_id = api_get_course_int_id();
@ -153,7 +152,6 @@ class learnpath {
$this->hide_toc_frame = $row['hide_toc_frame'];
$this->lp_session_id = $row['session_id'];
$this->use_max_score = $row['use_max_score'];
$this->created_on = $row['created_on'];
$this->modified_on = $row['modified_on'];
$this->ref = $row['ref'];
@ -200,10 +198,9 @@ class learnpath {
// 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";
if ($this->debug > 2) { error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - querying lp_view: ' . $sql, 0); }
$res = Database::query($sql);
$view_id = 0; // Used later to query lp_item_view.
if ($this->debug > 2) { error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - querying lp_view: ' . $sql, 0); }
if (Database :: num_rows($res) > 0) {
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Found previous view', 0);
@ -342,6 +339,7 @@ class learnpath {
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() - Selecting item_views: ' . $sql, 0);
}
$status_list = array();
$res = Database::query($sql);
while ($row = Database :: fetch_array($res) ) {
@ -349,11 +347,11 @@ class learnpath {
}
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];
if (is_object($this->items[$item_id])) {
$this->items[$item_id]->set_status($status);
if (empty ($status)) {
if (empty($status)) {
$this->items[$item_id]->set_status($this->default_status);
}
}
@ -363,14 +361,14 @@ class learnpath {
}
// Add that row to the lp_item_view table so that we have something to show in the stats page.
$sql_ins = "INSERT INTO $lp_item_view_table (c_id, lp_item_id, lp_view_id, view_count, status)
VALUES ($course_id, ".$item_id . "," . $this->lp_view_id . ",1,'not attempted')";
VALUES ($course_id, ".$item_id . "," . $this->lp_view_id . ", 1, 'not attempted')";
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Inserting blank item_view : ' . $sql_ins, 0);
}
$res_ins = Database::query($sql_ins);
}
}
}
}
}
$this->ordered_items = self::get_flat_ordered_items_list($this->get_id(), 0, $course_id);
$this->max_ordered_items = 0;
@ -384,8 +382,6 @@ class learnpath {
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - End of learnpath constructor for learnpath ' . $this->get_id(), 0);
}
}
/**

@ -33,7 +33,7 @@ class learnpathItem {
public $launch_data = '';
public $lesson_location = '';
public $level = 0;
public $core_exit = '';
public $core_exit = '';
//var $location; // Only set this for SCORM?
public $lp_id;
public $max_score;
@ -90,8 +90,7 @@ class learnpathItem {
//error_log('New LP - Creating item object from DB: '.$sql, 0);
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
$this->error = 'Could not find given learnpath item in learnpath_item table';
//error_log('New LP - '.$this->error, 0);
$this->error = 'Could not find given learnpath item in learnpath_item table';
return false;
}
$row = Database::fetch_array($res);
@ -227,17 +226,18 @@ class learnpathItem {
$course_id = api_get_course_int_id();
$sql_del_view = "DELETE FROM $lp_item_view WHERE c_id = $course_id AND lp_item_id = ".$this->db_id;
//error_log('New LP - Deleting from lp_item_view: '.$sql_del_view, 0);
$res_del_view = Database::query($sql_del_view);
if (self::debug > 0) { error_log('Deleting from lp_item_view: '.$sql_del_view, 0); }
Database::query($sql_del_view);
$sql_sel = "SELECT * FROM $lp_item WHERE c_id = $course_id AND id = ".$this->db_id;
$res_sel = Database::query($sql_sel);
if (Database::num_rows($res_sel) < 1) { return false; }
$row = Database::fetch_array($res_sel);
$sql_del_item = "DELETE FROM $lp_item WHERE c_id = $course_id AND id = ".$this->db_id;
//error_log('New LP - Deleting from lp_item: '.$sql_del_view, 0);
$res_del_item = Database::query($sql_del_item);
if (Database::num_rows($res_sel) < 1) {
return false;
}
$sql_del_item = "DELETE FROM $lp_item WHERE c_id = $course_id AND id = ".$this->db_id;
Database::query($sql_del_item);
if (self::debug > 0) { error_log('Deleting from lp_item: '.$sql_del_view); }
if (api_get_setting('search_enabled') == 'true') {
if (!is_null($this->search_did)) {
@ -246,7 +246,6 @@ class learnpathItem {
$di->remove_document($this->search_did);
}
}
return true;
}
@ -1702,14 +1701,13 @@ class learnpathItem {
* @return boolean True on success, false on failure
*/
public function save($from_outside = true, $prereqs_complete = false) {
if (self::debug > 0) { error_log('learnpathItem::save()', 0); }
$item_id = $this->get_id();
if (self::debug > 0) { error_log('learnpathItem::save()', 0); }
// First check if parameters passed via GET can be saved here
// in case it's a SCORM, we should get:
if ($this->type == 'sco' || $this->type== 'au') {
$s = $this->get_status(true);
$status = $this->get_status(true);
if ($this->prevent_reinit == 1 AND
$s != $this->possible_status[0] AND $s != $this->possible_status[1]) {
$status != $this->possible_status[0] AND $status != $this->possible_status[1]) {
if (self::debug > 1) { error_log('learnpathItem::save() - save reinit blocked by setting', 0); }
// Do nothing because the status has already been set. Don't allow it to change.
// TODO: Check there isn't a special circumstance where this should be saved.
@ -1734,9 +1732,9 @@ class learnpathItem {
if (self::debug > 2) { error_log('learnpathItem::save() - setting min_score to '.$value, 0); }
break;
case 'lesson_status':
if(!empty($value)){
if (!empty($value)) {
$this->set_status($value);
if (self::debug > 2) { error_log('learnpathItem::save() - setting status to '.$value, 0); }
if (self::debug > 2) { error_log('learnpathItem::save() - setting status to '.$value, 0); }
}
break;
case 'time':

@ -31,7 +31,6 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$debug = 0;
$return = '';
if ($debug > 0) { error_log('In initialize_item('.$lp_id.','.$user_id.','.$view_id.','.$next_item.')', 0); }
//$objResponse = new xajaxResponse();
/*$item_id may be one of:
* -'next'
* -'previous'
@ -47,16 +46,16 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
require_once 'aiccItem.class.php';
$mylp = '';
if (isset($_SESSION['lpobject'])) {
if ($debug > 1) { error_log('////$_SESSION[lpobject] is set', 0); }
if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
$oLP = unserialize($_SESSION['lpobject']);
if (!is_object($oLP)) {
if ($debug > 1) { error_log(print_r($oLP,true), 0); }
if ($debug > 2) { error_log('////Building new lp', 0); }
if ($debug > 2) { error_log('Building new LP', 0); }
unset($oLP);
$code = api_get_course_id();
$mylp = new learnpath($code,$lp_id,$user_id);
} else {
if ($debug > 1) { error_log('////Reusing session lp', 0); }
if ($debug > 1) { error_log('Reusing session LP', 0); }
$mylp = $oLP;
}
}
@ -68,10 +67,10 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$mylp->save_current();
}
*/
//$objResponse->addAlert(api_get_path(REL_CODE_PATH).'newscorm/learnpathItem.class.php');
if (is_object($mylp->items[$next_item])) {
if ($debug > 1) { error_log('In initialize_item - recovering existing item object '.$next_item, 0); }
$mylpi = & $mylp->items[$next_item];
$mylpi = $mylp->items[$next_item];
} else {
if ($debug > 1) { error_log('In initialize_item - generating new item object '.$next_item, 0); }
$mylpi = new learnpathItem($next_item, $user_id);
@ -90,8 +89,8 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$mymax = $mylpi->get_max();
if ($mymax === '') { $mymax = "''"; }
$mymin = $mylpi->get_min();
$mylesson_status = $mylpi->get_status();
$mylesson_location = $mylpi->get_lesson_location();
$mylesson_status = $mylpi->get_status();
$mytotal_time = $mylpi->get_scorm_time('js', null, true);
$mymastery_score = $mylpi->get_mastery_score();
$mymax_time_allowed = $mylpi->get_max_time_allowed();
@ -189,9 +188,7 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$mylp->set_error_msg('');
$mylp->prerequisites_match(); // Check the prerequisites are all complete.
if ($debug > 1) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); }
//$_SESSION['scorm_item_id'] = $new_item_id; // Save the new item ID for the exercise tool to use/
//$_SESSION['lpobject'] = serialize($mylp);
if ($debug > 1) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); }
return $return;
}
echo initialize_item($_POST['lid'], $_POST['uid'], $_POST['vid'], $_POST['iid']);
Loading…
Cancel
Save