From ba1fe4bb812b774c4a2836661972d5aab0fe2bb7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 30 Nov 2020 15:05:08 +0100 Subject: [PATCH] Minor - format code, add logs --- main/lp/learnpath.class.php | 8 ++++++-- main/lp/learnpathItem.class.php | 16 +++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index ac31df9c28..2e0b340430 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -4313,6 +4313,9 @@ class learnpath } $currentItem = $this->getItem($itemId); + if ($debug > 0) { + error_log("Checking item id $itemId"); + } if ($currentItem) { if ($this->type == 2) { @@ -4350,12 +4353,13 @@ class learnpath } else { $result = true; if ($debug > 1) { - error_log('$this->items['.$itemId.'] was not an object', 0); + error_log('$this->items['.$itemId.'] was not an object'); } } if ($debug > 1) { - error_log('End of prerequisites_match(). Error message is now '.$this->error, 0); + error_log('Result: '.$result); + error_log('End of prerequisites_match(). Error message is now '.$this->error); } return $result; diff --git a/main/lp/learnpathItem.class.php b/main/lp/learnpathItem.class.php index 9adc671975..1dd54d47aa 100755 --- a/main/lp/learnpathItem.class.php +++ b/main/lp/learnpathItem.class.php @@ -12,7 +12,7 @@ */ class learnpathItem { - const DEBUG = 0; // Logging parameter. + public const DEBUG = 0; // Logging parameter. public $iId; public $attempt_id; // Also called "objectives" SCORM-wise. public $audio; // The path to an audio file (stored in document/audio/). @@ -250,17 +250,17 @@ class learnpathItem /** * Closes/stops the item viewing. Finalises runtime values. * If required, save to DB. + * @param bool $prerequisitesCheck Needed to check if asset can be set as completed or not * * @return bool True on success, false otherwise */ public function close() { - if (self::DEBUG) { - error_log('Start - learnpathItem:close'); - } + $debug = self::DEBUG; $this->current_stop_time = time(); $type = $this->get_type(); - if (self::DEBUG) { + if ($debug) { + error_log('Start - learnpathItem:close'); error_log("Type: ".$type); error_log("get_id: ".$this->get_id()); } @@ -271,8 +271,6 @@ class learnpathItem true ); } else { - /*if ($this->prerequisites_match()) { - }*/ $this->status = $this->possible_status[2]; if (self::DEBUG) { @@ -281,13 +279,13 @@ class learnpathItem } } if ($this->save_on_close) { - if (self::DEBUG) { + if ($debug) { error_log("save_on_close: "); } $this->save(); } - if (self::DEBUG) { + if ($debug) { error_log('End - learnpathItem:close'); }