if (self::debug > 0) { error_log('New LP - In learnpathItem::drop_child()', 0); }
if (self::debug > 0) { error_log('learnpathItem::drop_child()', 0); }
if (!empty($item)) {
foreach ($this->children as $index => $child) {
if ($child == $item) {
@ -271,7 +271,7 @@ class learnpathItem {
* @return integer The attempt_id for this item view by this user, or 1 if none defined
*/
public function get_attempt_id() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_attempt_id() on item '.$this->db_id, 0); }
if (self::debug > 0) { error_log('learnpathItem::get_attempt_id() on item '.$this->db_id, 0); }
$res = 1;
if (!empty($this->attempt_id)) {
$res = $this->attempt_id;
@ -285,7 +285,7 @@ class learnpathItem {
* @return array Array of children items IDs
*/
public function get_children() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_children()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_children()', 0); }
$list = array();
foreach ($this->children as $child) {
if (!empty($child)) {
@ -309,7 +309,7 @@ class learnpathItem {
* @return string 'credit' or 'no-credit'. Defaults to 'credit' because if we don't know enough about this item, it's probably because it was never used before.
*/
public function get_credit() {
if (self::debug > 1) {error_log('New LP - In learnpathItem::get_credit()', 0); }
if (self::debug > 1) {error_log('learnpathItem::get_credit()', 0); }
$credit = 'credit';
// Now check the value of prevent_reinit (if it's 0, return credit as the default was).
if ($this->get_prevent_reinit() != 0) { // If prevent_reinit == 1 (or more).
@ -317,11 +317,13 @@ class learnpathItem {
// Check the status in the database rather than in the object, as checking in the object
// would always return "no-credit" when we want to set it to completed.
$status = $this->get_status(true);
if (self::debug > 2) { error_log('New LP - In learnpathItem::get_credit() - get_prevent_reinit!=0 and status is '.$status, 0); }
if (self::debug > 2) { error_log('learnpathItem::get_credit() - get_prevent_reinit!=0 and status is '.$status, 0); }
//0=not attempted - 1 = incomplete
if ($status != $this->possible_status[0] && $status != $this->possible_status[1]) {
$credit = 'no-credit';
}
}
if (self::debug > 1) {error_log("learnpathItem::get_credit() returns: $credit"); }
return $credit;
}
@ -330,7 +332,7 @@ class learnpathItem {
* @return integer Current start time, or current time if none
*/
public function get_current_start_time() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_current_start_time()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_current_start_time()', 0); }
if (empty($this->current_start_time)) {
return time();
} else {
@ -343,7 +345,7 @@ class learnpathItem {
* @return string Description
*/
public function get_description() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_description()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_description()', 0); }
if (empty($this->description)) { return ''; }
return $this->description;
}
@ -354,7 +356,7 @@ class learnpathItem {
*/
public function get_file_path($path_to_scorm_dir = '') {
$course_id = api_get_course_int_id();
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_file_path()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_file_path()', 0); }
$path = $this->get_path();
$type = $this->get_type();
if (empty($path)) {
@ -398,7 +400,7 @@ class learnpathItem {
* @return integer Database ID for the current item
*/
public function get_id() {
if (self::debug > 1) {error_log('New LP - In learnpathItem::get_id()', 0); }
if (self::debug > 1) {error_log('learnpathItem::get_id()', 0); }
if (!empty($this->db_id)) {
return $this->db_id;
}
@ -440,7 +442,7 @@ class learnpathItem {
* @return int The current number of interactions recorder
*/
public function get_interactions_count($checkdb = false) {
if (self::debug > 1) { error_log('New LP - In learnpathItem::get_interactions_count()', 0); }
if (self::debug > 1) { error_log('learnpathItem::get_interactions_count()', 0); }
$return = 0;
$course_id = api_get_course_int_id();
@ -495,7 +497,7 @@ class learnpathItem {
* @return int The current number of objectives recorder
*/
public function get_objectives_count() {
if (self::debug > 1) { error_log('New LP - In learnpathItem::get_objectives_count()', 0);}
if (self::debug > 1) { error_log('learnpathItem::get_objectives_count()', 0);}
$res = 0;
if (!empty($this->objectives_count)) {
$res = $this->objectives_count;
@ -508,7 +510,7 @@ class learnpathItem {
* @return string Launch data as found in imsmanifest and stored in Chamilo (read only). Defaults to ''.
*/
public function get_launch_data() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_launch_data()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_launch_data()', 0); }
if (!empty($this->launch_data)) {
return $this->launch_data;
}
@ -520,7 +522,7 @@ class learnpathItem {
* @return string lesson location as recorded by the SCORM and AICC elements. Defaults to ''
*/
public function get_lesson_location() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_lesson_location()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_lesson_location()', 0); }
if (self::debug > 2) { error_log('New LP - In learnpathItem::get_scorm_time(): given time empty, current_start_time = '.$this->current_start_time, 0); }
if (self::debug > 2) { error_log('learnpathItem::get_scorm_time(): given time empty, current_start_time = '.$this->current_start_time, 0); }
if (self::debug > 2) { error_log('New LP - In learnpathItem::get_scorm_time('.$scorm_time.')', 0); }
if (self::debug > 2) { error_log('learnpathItem::get_scorm_time('.$scorm_time.')', 0); }
return $scorm_time;
}
@ -1105,7 +1107,7 @@ class learnpathItem {
* @return string Title
*/
public function get_title() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_title()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_title()', 0); }
if (empty($this->title)) { return ''; }
return $this->title;
}
@ -1115,7 +1117,7 @@ class learnpathItem {
* @return integer Total time
*/
public function get_total_time() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_total_time()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_total_time()', 0); }
if ($this->current_start_time == 0) { // Shouldn't be necessary thanks to the open() method.
$this->current_start_time = time();
}
@ -1129,7 +1131,7 @@ class learnpathItem {
if ($time <0){
return 0;
} else {
if (self::debug > 2) { error_log('New LP - In learnpathItem::get_total_time() - Current stop time = '.$this->current_stop_time.', current start time = '.$this->current_start_time.' Returning '.$time, 0); }
if (self::debug > 2) { error_log('learnpathItem::get_total_time() - Current stop time = '.$this->current_stop_time.', current start time = '.$this->current_start_time.' Returning '.$time, 0); }
return $time;
}
}
@ -1143,7 +1145,7 @@ class learnpathItem {
if (!empty($this->type)) {
$res = $this->type;
}
if (self::debug > 2) { error_log('New LP - In learnpathItem::get_type() - Returning '.$res.' for item '.$this->db_id, 0); }
if (self::debug > 2) { error_log('learnpathItem::get_type() - Returning '.$res.' for item '.$this->db_id, 0); }
return $res;
}
@ -1152,7 +1154,7 @@ class learnpathItem {
* @return int Number of attempts or 0
*/
public function get_view_count() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::get_view_count()', 0); }
if (self::debug > 0) { error_log('learnpathItem::get_view_count()', 0); }
if (!empty($this->attempt_id)) {
return $this->attempt_id;
} else {
@ -1166,10 +1168,10 @@ class learnpathItem {
*/
function is_done(){
if ($this->status_is(array('completed', 'passed', 'succeeded', 'failed'))) {
if (self::debug > 2) { error_log('New LP - In learnpath::is_done() - Item '.$this->get_id().' is complete', 0); }
if (self::debug > 2) { error_log('learnpath::is_done() - Item '.$this->get_id().' is complete', 0); }
return true;
}else{
if (self::debug > 2) { error_log('New LP - In learnpath::is_done() - Item '.$this->get_id().' is not complete', 0); }
if (self::debug > 2) { error_log('learnpath::is_done() - Item '.$this->get_id().' is not complete', 0); }
return false;
}
}
@ -1181,7 +1183,7 @@ class learnpathItem {
* 1 if it is allowed. Defaults to 1
*/
public function is_restart_allowed() {
if (self::debug > 2) { error_log('New LP - In learnpathItem::is_restart_allowed()', 0); }
if (self::debug > 2) { error_log('learnpathItem::is_restart_allowed()', 0); }
$restart = 1;
$mystatus = $this->get_status(true);
if ($this->get_prevent_reinit() > 0){ // If prevent_reinit == 1 (or more)
@ -1205,7 +1207,7 @@ class learnpathItem {
* @return boolean True on success, false on failure.
*/
public function open($allow_new_attempt = false) {
if (self::debug > 0) { error_log('New LP - In learnpathItem::open()', 0); }
if (self::debug > 0) { error_log('learnpathItem::open()', 0); }
if ($this->prevent_reinit == 0) {
$this->current_score = 0;
$this->current_start_time = time();
@ -1240,7 +1242,7 @@ class learnpathItem {
* @return string HTML file (displayable in an <iframe>) or empty string if no path defined
*/
function output() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::output()', 0); }
if (self::debug > 0) { error_log('learnpathItem::output()', 0); }
if (!empty($this->path) and is_file($this->path)) {
$output = '';
$output .= file_get_contents($this->path);
@ -1258,7 +1260,7 @@ class learnpathItem {
* @return boolean True if the list of prerequisites given is entirely satisfied, false otherwise
*/
public function parse_prereq($prereqs_string, $items, $refs_list, $user_id) {
if (self::debug > 0) { error_log('New LP - In learnpathItem::parse_prereq() for learnpath '.$this->lp_id.' with string '.$prereqs_string, 0); }
if (self::debug > 0) { error_log('learnpathItem::parse_prereq() for learnpath '.$this->lp_id.' with string '.$prereqs_string, 0); }
$course_id = api_get_course_int_id();
// Deal with &, |, ~, =, <>, {}, ,, X*, () in reverse order.
@ -1645,7 +1647,7 @@ class learnpathItem {
* @return boolean True on success, false otherwise
*/
public function restart() {
if (self::debug > 0) { error_log('New LP - In learnpathItem::restart()', 0); }
if (self::debug > 0) { error_log('learnpathItem::restart()', 0); }
if ($this->type == 'sco') { //If this is a sco, chamilo can't update the time without explicit scorm call
$this->current_start_time = 0;
$this->current_stop_time = 0; //Those 0 value have this effect
@ -1700,8 +1702,7 @@ 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('New LP - In learnpathItem::save()', 0); }