function _setCourseCompleted() { if ($this->environment != 'course_lo') { return; } if ($this->status == 'completed' || $this->status == 'passed') { //update complete dates in DB $query = "SELECT first_complete, last_complete FROM %lms_commontrack WHERE idTrack=" . (int) $this->idTrack; $res = sql_query($query); if ($res && sql_num_rows($res) > 0) { $now = date("Y-m-d H:i:s"); list($first_complete, $last_complete) = sql_fetch_row($res); $query = "UPDATE %lms_commontrack SET last_complete='" . $now . "'"; if (!$first_complete || $first_complete > $now) { $query .= ", first_complete='" . $now . "'"; } $query .= " WHERE idTrack=" . (int) $this->idTrack; $res = sql_query($query); } //--- /* if(isset($_SESSION['idCourse'])) { $idCourse = $_SESSION['idCourse']; } else { */ // the only way is a direct query :(, or else if more than one course is open only the last one will complete $query = "SELECT idCourse " . "FROM %lms_organization " . "WHERE idOrg = '" . (int) $this->idReference . "' "; list($idCourse) = sql_fetch_row(sql_query($query)); //} $useridst = $this->idUser; require_once Docebo::inc(_lms_ . '/modules/organization/orglib.php'); $repoDb = new OrgDirDb($idCourse); $item = $repoDb->getFolderById($this->idReference); $values = $item->otherValues; $isTerminator = isset($values[ORGFIELDISTERMINATOR]) && $values[ORGFIELDISTERMINATOR]; if ($isTerminator) { require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.stats.php'; saveTrackStatusChange((int) $useridst, (int) $idCourse, _CUS_END); } } }