Skill: Fixing wheel

pull/3924/head
Angel Fernando Quiroz Campos 4 years ago
parent e157d2d74b
commit 87e35a41b3
  1. 10
      public/main/inc/ajax/skill.ajax.php
  2. 32
      public/main/inc/lib/SkillModel.php
  3. 2
      public/main/inc/lib/model.lib.php

@ -104,13 +104,13 @@ switch ($action) {
} }
break; break;
case 'get_skills_by_profile': case 'get_skills_by_profile':
$skillRelProfile = new SkillRelProfile(); $skillRelProfile = new SkillRelProfileModel();
$profile_id = isset($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : null; $profile_id = isset($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : null;
$skills = $skillRelProfile->getSkillsByProfile($profile_id); $skills = $skillRelProfile->getSkillsByProfile($profile_id);
echo json_encode($skills); echo json_encode($skills);
break; break;
case 'get_saved_profiles': case 'get_saved_profiles':
$skillProfile = new SkillProfile(); $skillProfile = new SkillProfileModel();
$profiles = $skillProfile->get_all(); $profiles = $skillProfile->get_all();
Display::display_no_header(); Display::display_no_header();
Display::$global_template->assign('profiles', $profiles); Display::$global_template->assign('profiles', $profiles);
@ -304,14 +304,14 @@ switch ($action) {
} }
break; break;
case 'get_profile': case 'get_profile':
$skillRelProfile = new SkillRelProfile(); $skillRelProfile = new SkillRelProfileModel();
$profileId = isset($_REQUEST['profile_id']) ? intval($_REQUEST['profile_id']) : null; $profileId = isset($_REQUEST['profile_id']) ? intval($_REQUEST['profile_id']) : null;
$profile = $skillRelProfile->getProfileInfo($profileId); $profile = $skillRelProfile->getProfileInfo($profileId);
echo json_encode($profile); echo json_encode($profile);
break; break;
case 'save_profile': case 'save_profile':
if (api_is_platform_admin() || api_is_drh()) { if (api_is_platform_admin() || api_is_drh()) {
$skill_profile = new SkillProfile(); $skill_profile = new SkillProfileModel();
$params = $_REQUEST; $params = $_REQUEST;
$params['skills'] = isset($params['skill_id']) ? $params['skill_id'] : null; $params['skills'] = isset($params['skill_id']) ? $params['skill_id'] : null;
$profileId = isset($_REQUEST['profile']) ? intval($_REQUEST['profile']) : null; $profileId = isset($_REQUEST['profile']) ? intval($_REQUEST['profile']) : null;
@ -335,7 +335,7 @@ switch ($action) {
case 'delete_profile': case 'delete_profile':
if (api_is_platform_admin() || api_is_drh()) { if (api_is_platform_admin() || api_is_drh()) {
$profileId = $_REQUEST['profile']; $profileId = $_REQUEST['profile'];
$skillProfile = new SkillProfile(); $skillProfile = new SkillProfileModel();
$isDeleted = $skillProfile->delete($profileId); $isDeleted = $skillProfile->delete($profileId);
echo json_encode([ echo json_encode([

@ -780,6 +780,8 @@ class SkillModel extends Model
$courseInfo = api_get_course_info_by_id($courseId); $courseInfo = api_get_course_info_by_id($courseId);
$courseTempList[$courseId] = $courseInfo; $courseTempList[$courseId] = $courseInfo;
} }
} else {
$courseInfo = [];
} }
$tableRow = [ $tableRow = [
'skill_badge' => $resultData['img_small'], 'skill_badge' => $resultData['img_small'],
@ -807,9 +809,8 @@ class SkillModel extends Model
} }
if ($addTitle) { if ($addTitle) {
$tableResult .= '<h3 class="section-title">'.get_lang('Achieved skills').'</h3> $tableResult .= Display::page_subheader(get_lang('Achieved skills'));
<div class="skills-badges"> $tableResult .= '<div class="skills-badges">';
';
} }
if (!empty($skillParents)) { if (!empty($skillParents)) {
@ -951,8 +952,8 @@ class SkillModel extends Model
// Default root node // Default root node
$skills[1] = [ $skills[1] = [
'id' => '1', 'id' => '1',
'name' => get_lang('root'), 'name' => get_lang('Root'),
'parent_id' => '0', 'parent_id' => 0,
'status' => 1, 'status' => 1,
]; ];
$skillInfo = $this->getSkillInfo($skill_id); $skillInfo = $this->getSkillInfo($skill_id);
@ -975,7 +976,7 @@ class SkillModel extends Model
if (!empty($skills)) { if (!empty($skills)) {
foreach ($skills as &$skill) { foreach ($skills as &$skill) {
if (0 == $skill['parent_id']) { if (0 == $skill['parent_id']) {
$skill['parent_id'] = 'root'; $skill['parent_id'] = 1;
} }
// because except main keys (id, name, children) others keys // because except main keys (id, name, children) others keys
@ -1044,9 +1045,9 @@ class SkillModel extends Model
} }
if (empty($original_skill)) { if (empty($original_skill)) {
$refs['root']['children'][0] = $skills[1]; $refs[1]['children'][0] = $skills[1];
$skills[$skill_id]['data']['family_id'] = 1; $skills[$skill_id]['data']['family_id'] = 1;
$refs['root']['children'][0]['children'][0] = $skills[$skill_id]; $refs[1]['children'][0]['children'][0] = $skills[$skill_id];
$flat_array[$skill_id] = $skills[$skill_id]; $flat_array[$skill_id] = $skills[$skill_id];
} else { } else {
// Moving node to the children index of their parents // Moving node to the children index of their parents
@ -1061,8 +1062,8 @@ class SkillModel extends Model
$skills_tree = [ $skills_tree = [
'name' => get_lang('Absolute skill'), 'name' => get_lang('Absolute skill'),
'id' => 'root', 'id' => 1,
'children' => $refs['root']['children'], 'children' => $refs[1]['children'],
'data' => [], 'data' => [],
]; ];
} }
@ -1111,7 +1112,7 @@ class SkillModel extends Model
} }
} }
return json_encode($simple_tree[0]['children']); return json_encode($simple_tree);
} }
/** /**
@ -1365,7 +1366,7 @@ class SkillModel extends Model
'first' 'first'
); );
if (false === $result) { if (empty($result)) {
return false; return false;
} }
@ -2236,6 +2237,8 @@ class SkillModel extends Model
* @param int $courseId * @param int $courseId
* @param int $sessionId * @param int $sessionId
* *
* @throws \Doctrine\ORM\OptimisticLockException
*
* @return bool * @return bool
*/ */
public static function saveSkillsToCourse($skills, $courseId, $sessionId) public static function saveSkillsToCourse($skills, $courseId, $sessionId)
@ -2330,7 +2333,10 @@ class SkillModel extends Model
* @param string $argumentation * @param string $argumentation
* @param int $authorId * @param int $authorId
* *
* @return \Chamilo\CoreBundle\Entity\SkillRelUser|bool * @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*
* @return SkillRelUser|false
*/ */
public function addSkillToUserBadge($user, $skill, $levelId, $argumentation, $authorId) public function addSkillToUserBadge($user, $skill, $levelId, $argumentation, $authorId)
{ {

@ -11,7 +11,7 @@ class Model
{ {
public $table; public $table;
public $columns; public $columns;
public $required; public array $required;
public $is_course_model = false; public $is_course_model = false;
public function __construct() public function __construct()

Loading…
Cancel
Save