Adding error logs

skala
Julio Montoya 12 years ago
parent 3f2a7daf64
commit 7c8f107e9d
  1. 52
      main/newscorm/learnpath.class.php
  2. 16
      main/newscorm/lp_ajax_save_item.php
  3. 2
      main/newscorm/scorm_api.php

@ -727,23 +727,19 @@ class learnpath {
* @param integer Optional ID of the item from which to look for parents
*/
public function autocomplete_parents($item) {
$debug = $this->debug;
$debug = 10;
if ($debug) {
error_log('New LP - In learnpath::autocomplete_parents()', 0);
error_log('Learnpath::autocomplete_parents()', 0);
}
if (empty($item)) {
$item = $this->current;
}
$parent_id = $this->items[$item]->get_parent();
if ($debug) {
error_log('New LP - autocompleting parent of item ' . $item . ' (item ' . $parent_id . ')', 0);
}
if (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 ($debug) {
error_log('New LP - ' . $item . ' is an item, proceed', 0);
error_log('Autocompleting parent of item ' . $item . ' (item ' . $parent_id . ')', 0);
}
$current_item = & $this->items[$item];
$parent = & $this->items[$parent_id]; // Get the parent.
@ -753,14 +749,14 @@ class learnpath {
// If the current item is completed or passes or succeeded.
$completed = true;
if ($debug) {
error_log('New LP - Status of current item is alright', 0);
error_log('Status of current item is alright', 0);
}
foreach ($parent->get_children() as $child) {
// Check all his brothers (parent's children) for completion status.
if ($child != $item) {
if ($debug) {
error_log('New LP - Looking at brother with ID ' . $child . ', status is ' . $this->items[$child]->get_status(), 0);
error_log('Looking at brother with ID ' . $child . ', status is ' . $this->items[$child]->get_status(), 0);
}
//if($this->items[$child]->status_is(array('completed','passed','succeeded')))
// Trying completing parents of failed and browsed items as well.
@ -774,7 +770,7 @@ class learnpath {
// Keep completion status to true.
} else {
if ($this->debug > 2) {
error_log('New LP - Found one incomplete child of ' . $parent_id . ': ' . $child . ' is ' . $this->items[$child]->get_status(), 0);
error_log('Found one incomplete child of ' . $parent_id . ': ' . $child . ' is ' . $this->items[$child]->get_status(), 0);
}
$completed = false;
}
@ -786,13 +782,17 @@ class learnpath {
$parent->save(false, $this->prerequisites_match($parent->get_id()));
$this->update_queue[$parent->get_id()] = $parent->get_status();
if ($debug) {
error_log('New LP - Added parent to update queue ' . print_r($this->update_queue, true), 0);
error_log('Added parent to update queue ' . print_r($this->update_queue, true), 0);
}
$this->autocomplete_parents($parent->get_id()); // Recursive call.
}
} else {
//error_log('New LP - status of current item is not enough to get bothered with it', 0);
}
} else {
if ($debug) {
error_log("#$item is an item doesn't have parents");
}
}
}
@ -3727,7 +3727,7 @@ class learnpath {
*/
public function save_current() {
if ($this->debug > 0) {
error_log('New LP - In learnpath::save_current()', 0);
error_log('learnpath::save_current()', 0);
}
// TODO: Do a better check on the index pointing to the right item (it is supposed to be working
// on $ordered_items[] but not sure it's always safe to use with $items[]).
@ -3756,9 +3756,9 @@ class learnpath {
* @return boolean
*/
public function save_item($item_id = null, $from_outside = true) {
$debug = $this->debug;
$debug = 10;
if ($debug) {
error_log('New LP - In learnpath::save_item(' . $item_id . ',' . $from_outside . ')', 0);
error_log('In learnpath::save_item(' . $item_id . ',' . intval($from_outside). ')', 0);
}
// TODO: Do a better check on the index pointing to the right item (it is supposed to be working
// on $ordered_items[] but not sure it's always safe to use with $items[]).
@ -3768,16 +3768,22 @@ class learnpath {
if (empty($item_id)) {
$item_id = $this->get_current_item_id();
}
if ($debug) {
error_log('New LP - save_current() saving item ' . $item_id, 0);
}
if (is_object($this->items[$item_id])) {
if ($debug) { error_log('object exists'); }
if (isset($this->items[$item_id]) && is_object($this->items[$item_id])) {
if ($debug) { error_log('Object exists'); }
$res = $this->items[$item_id]->save($from_outside, $this->prerequisites_match($item_id));
$this->autocomplete_parents($item_id);
$status = $this->items[$item_id]->get_status();
$this->append_message('new_item_status: ' . $status);
if ($debug) {
error_log('update_queue before:');
error_log(print_r($this->update_queue,1));
}
$status = $this->items[$item_id]->get_status();
$this->update_queue[$item_id] = $status;
if ($debug) {
error_log('get_status(): ' . $status);
error_log('update_queue after:' . $status);
error_log(print_r($this->update_queue,1));
}
return $res;
}
return false;

@ -43,7 +43,7 @@ require_once 'aiccItem.class.php';
*/
function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $min = -1, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none') {
$return = null;
$debug = 0;
$debug = 10;
if ($debug > 0) {
error_log('lp_ajax_save_item.php : save_item() params: ');
@ -70,7 +70,8 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
$prereq_check = $mylp->prerequisites_match($item_id);
$mylpi = $mylp->items[$item_id];
$mylpi = $mylp->items[$item_id];
//This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069
$mylpi->set_lp_view($view_id);
@ -179,8 +180,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
if ($core_exit != 'undefined') {
$mylpi->set_core_exit($core_exit);
}
}
$mylp->save_item($item_id, false);
} else {
return $return;
@ -222,13 +222,11 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
if ($my_upd_id != $item_id) { // Only update the status from other items (i.e. parents and brothers), do not update current as we just did it already.
$return .= "update_toc('".$my_upd_status."','".$my_upd_id."');";
}
}
}
$return .= "update_progress_bar('$mycomplete', '$mytotal', '$myprogress_mode');";
if ($debug > 0) {
$return .= "logit_lms('Saved data for item ".$item_id.", user ".$user_id." (status=".$mystatus.")',2);";
if ($debug > 1) { error_log('End of save_item()', 0); }
$return .= "logit_lms('Saved data for item ".$item_id.", user ".$user_id." (status=".$mystatus.")',2);";
}
if (!isset($_SESSION['login_as'])) {
@ -256,7 +254,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
//To be sure progress is updated
$mylp->save_last();
if ($debug > 0) { error_log('lp_ajax_save_item.php : save_item end ----- '); }
if ($debug > 0) { error_log('---------------- lp_ajax_save_item.php : save_item end ----- '); }
return $return;
}

@ -1558,7 +1558,7 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id)
my_scorm_values = process_scorm_values();
for (k=0;k<my_scorm_values.length;k++) {
for (k=0; k<my_scorm_values.length; k++) {
if (my_scorm_values[k]=='cmi.core.session_time') {
params += '&t='+olms.session_time;
} else if (my_scorm_values[k]=='cmi.core.lesson_status' && olms.lesson_status!='') {

Loading…
Cancel
Save