diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php index 370fff18ca..d1936bb827 100755 --- a/main/inc/lib/skill.lib.php +++ b/main/inc/lib/skill.lib.php @@ -3,6 +3,7 @@ use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\Repository\UserRepository; +use Fhaculty\Graph\Vertex; /** * Class SkillProfile @@ -97,7 +98,7 @@ class SkillProfile extends Model Database::delete( $this->table_rel_profile, array( - 'profile_id' => $id + 'profile_id' => $id, ) ); @@ -222,15 +223,15 @@ class SkillRelSkill extends Model } /** - * @param int $skill_id + * @param int $skillId * @return array */ - public function getDirectParents($skill_id) + public function getDirectParents($skillId) { - $skill_id = intval($skill_id); + $skillId = (int) $skillId; $sql = 'SELECT parent_id as skill_id FROM '.$this->table.' - WHERE skill_id = '.$skill_id.' '; + WHERE skill_id = '.$skillId.' '; $result = Database::query($sql); $skill = Database::store_result($result, 'ASSOC'); $skill = isset($skill[0]) ? $skill[0] : null; @@ -324,9 +325,9 @@ class SkillRelSkill extends Model 'where' => array( 'skill_id = ? AND parent_id = ?' => array( $skill_id, - $parent_id - ) - ) + $parent_id, + ), + ), ) ); @@ -365,9 +366,9 @@ class SkillRelGradebook extends Model 'where' => array( 'gradebook_id = ? AND skill_id = ?' => array( $gradebookId, - $skillId - ) - ) + $skillId, + ), + ), ) ); if (!empty($result)) { @@ -391,9 +392,9 @@ class SkillRelGradebook extends Model 'where' => array( 'skill_id = ? AND gradebook_id = ? ' => array( $skill_id, - $gradebookId - ) - ) + $gradebookId, + ), + ), ), 'first' ); @@ -443,7 +444,7 @@ class SkillRelGradebook extends Model foreach ($gradebooks_to_add as $gradebook_id) { $attributes = array( 'skill_id' => $skill_id, - 'gradebook_id' => $gradebook_id + 'gradebook_id' => $gradebook_id, ); $this->save($attributes); } @@ -532,7 +533,7 @@ class SkillRelUser extends Model $courseId = intval($courseId); $sessionId = $sessionId ? intval($sessionId) : null; $whereConditions = array( - 'user_id = ? ' => intval($userId) + 'user_id = ? ' => intval($userId), ); if ($courseId > 0) { @@ -544,7 +545,7 @@ class SkillRelUser extends Model 'skill_id', $this->table, array( - 'where' => $whereConditions + 'where' => $whereConditions, ), 'all' ); @@ -566,12 +567,12 @@ class SkillRelUser extends Model intval($userId), intval($skillId), intval($courseId), - $sessionId ? intval($sessionId) : null - ) + $sessionId ? intval($sessionId) : null, + ), ); return Database::select('*', $this->table, array( - 'where' => $where + 'where' => $where, ), 'first'); } @@ -589,7 +590,7 @@ class Skill extends Model 'access_url_id', 'short_code', 'icon', - 'criteria' + 'criteria', ); public $required = array('name'); @@ -628,6 +629,10 @@ class Skill extends Model public function get($id) { $result = parent::get($id); + if (empty($result)) { + return []; + } + $path = api_get_path(WEB_UPLOAD_PATH).'badges/'; if (!empty($result['icon'])) { @@ -653,7 +658,6 @@ class Skill extends Model $result['icon_big'] = $iconSmall; $result['icon_small'] = $iconBig; $result['icon_mini'] = $iconMini; - $result['img_mini'] = Display::img($iconBig, $result['name'], ['width' => ICON_SIZE_MEDIUM]); $result['img_big'] = Display::img($iconBig, $result['name']); $result['img_small'] = Display::img($iconSmall, $result['name']); @@ -687,6 +691,9 @@ class Skill extends Model } $html .= '