Refactor Skills code #2243

Move classes in independent files.
Fix legacy skill classes from Skill to SkillModel to avoid
conflicts with the entities.
pull/3904/head
Julio Montoya 4 years ago
parent d7468b6df7
commit 07f4947ca6
  1. 2
      public/main/admin/index.php
  2. 2
      public/main/admin/skill_badge.php
  3. 4
      public/main/admin/skill_badge_create.php
  4. 6
      public/main/admin/skill_badge_list.php
  5. 4
      public/main/admin/skill_create.php
  6. 4
      public/main/admin/skill_edit.php
  7. 9
      public/main/admin/skill_list.php
  8. 2
      public/main/admin/skill_rel_course.php
  9. 4
      public/main/admin/skills.php
  10. 2
      public/main/admin/skills_gradebook.php
  11. 4
      public/main/admin/skills_import.php
  12. 10
      public/main/admin/skills_profile.php
  13. 2
      public/main/admin/skills_wheel.php
  14. 2
      public/main/admin/user_information.php
  15. 4
      public/main/attendance/index.php
  16. 2
      public/main/badge/assertion.php
  17. 5
      public/main/badge/assign.php
  18. 2
      public/main/badge/class.php
  19. 2
      public/main/badge/criteria.php
  20. 14
      public/main/badge/issued.php
  21. 12
      public/main/badge/issued_all.php
  22. 6
      public/main/exercise/exercise.class.php
  23. 2
      public/main/exercise/exercise_show.php
  24. 4
      public/main/forum/editthread.php
  25. 10
      public/main/forum/forumfunction.inc.php
  26. 6
      public/main/gradebook/get_badges.php
  27. 2
      public/main/gradebook/lib/be/abstractlink.class.php
  28. 6
      public/main/gradebook/lib/be/category.class.php
  29. 2
      public/main/gradebook/lib/fe/catform.class.php
  30. 6
      public/main/gradebook/skill_rel_user.php
  31. 2
      public/main/inc/ajax/model.ajax.php
  32. 10
      public/main/inc/ajax/skill.ajax.php
  33. 782
      public/main/inc/lib/SkillModel.php
  34. 106
      public/main/inc/lib/SkillProfileModel.php
  35. 138
      public/main/inc/lib/SkillRelGradebookModel.php
  36. 56
      public/main/inc/lib/SkillRelProfileModel.php
  37. 192
      public/main/inc/lib/SkillRelSkillModel.php
  38. 152
      public/main/inc/lib/SkillRelUserModel.php
  39. 4
      public/main/inc/lib/attendance.lib.php
  40. 4
      public/main/inc/lib/certificate.lib.php
  41. 2
      public/main/inc/lib/course.lib.php
  42. 4
      public/main/inc/lib/gradebook.lib.php
  43. 4
      public/main/inc/lib/link.lib.php
  44. 4
      public/main/inc/lib/social.lib.php
  45. 4
      public/main/inc/lib/tracking.lib.php
  46. 4
      public/main/inc/lib/userportal.lib.php
  47. 4
      public/main/link/link.php
  48. 4
      public/main/lp/lp_add.php
  49. 2
      public/main/lp/lp_controller.php
  50. 4
      public/main/lp/lp_edit.php
  51. 2
      public/main/lp/lp_final_item.php
  52. 4
      public/main/mySpace/myStudents.php
  53. 8
      public/main/social/my_skills_report.php
  54. 2
      public/main/social/skills_ranking.php
  55. 4
      public/main/social/skills_tree.php
  56. 4
      public/main/social/skills_wheel.php
  57. 4
      public/main/survey/create_new_survey.php
  58. 2
      public/main/survey/survey.lib.php
  59. 4
      public/main/webservices/gradebook.php
  60. 2
      public/main/work/edit_work.php
  61. 6
      public/main/work/work.lib.php
  62. 2
      public/main/work/work.php

@ -253,7 +253,7 @@ if (api_is_platform_admin()) {
$blocks['sessions']['extra'] = null;
// Skills
if (Skill::isToolAvailable()) {
if (SkillModel::isToolAvailable()) {
$blocks['skills']['icon'] = Display::return_icon(
'skill-badges.png',
get_lang('Skills'),

@ -12,7 +12,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
$backpack = 'https://backpack.openbadges.org/';

@ -11,12 +11,12 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
$this_section = SECTION_PLATFORM_ADMIN;
$skillId = intval($_GET['id']);
$objSkill = new Skill();
$objSkill = new SkillModel();
$skill = $objSkill->get($skillId);
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_JS_PATH).'badge-studio/media/css/core.css" rel="stylesheet">';

@ -13,12 +13,12 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
$this_section = SECTION_PLATFORM_ADMIN;
$objSkill = new Skill();
$skills = $objSkill->get_all();
$objSkill = new SkillModel();
$skills = $objSkill->getAllSkills();
$interbreadcrumb = [
[

@ -13,7 +13,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
$interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('Administration')];
$interbreadcrumb[] = ['url' => 'skill_list.php', 'name' => get_lang('Manage skills')];
@ -22,7 +22,7 @@ $interbreadcrumb[] = ['url' => 'skill_list.php', 'name' => get_lang('Manage skil
$skillParentId = isset($_GET['parent']) ? intval($_GET['parent']) : 0;
$formDefaultValues = [];
$objSkill = new Skill();
$objSkill = new SkillModel();
if ($skillParentId > 0) {
$skillParentInfo = $objSkill->getSkillInfo($skillParentId);

@ -13,7 +13,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
$interbreadcrumb[] = ['url' => 'skill_list.php', 'name' => get_lang('Manage skills')];
@ -21,7 +21,7 @@ $interbreadcrumb[] = ['url' => 'skill_list.php', 'name' => get_lang('Manage skil
/* Process data */
$skillId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$objSkill = new Skill();
$objSkill = new SkillModel();
$objGradebook = new Gradebook();
$skillInfo = $objSkill->getSkillInfo($skillId);

@ -3,7 +3,6 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Skill;
use Skill as SkillManager;
/**
* Skill list for management.
@ -18,7 +17,7 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
SkillManager::isAllowed();
SkillModel::isAllowed();
$action = isset($_GET['action']) ? $_GET['action'] : 'list';
$skillId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
@ -81,7 +80,7 @@ switch ($action) {
$entityManager->persist($skill);
$skillObj = new SkillManager();
$skillObj = new SkillModel();
$children = $skillObj->getChildren($skill->getId());
foreach ($children as $child) {
@ -160,8 +159,8 @@ switch ($action) {
}
/* View */
$skill = new SkillManager();
$skillList = $skill->get_all();
$skill = new SkillModel();
$skillList = $skill->getAllSkills();
$extraFieldSearchTagId = isset($_REQUEST['tag_id']) ? $_REQUEST['tag_id'] : 0;
if ($extraFieldSearchTagId) {

@ -62,7 +62,7 @@ $form->addButtonSave(get_lang('Save'));
$form->setDefaults(['skills' => array_keys($skillList)]);
if ($form->validate()) {
$result = Skill::saveSkillsToCourseFromForm($form);
$result = SkillModel::saveSkillsToCourseFromForm($form);
if ($result) {
Display::addFlash(Display::return_message(get_lang('Update successful')));
}

@ -8,14 +8,14 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');
$htmlHeadXtra[] = api_get_js('jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
$htmlHeadXtra[] = api_get_js('skills.js');
$skill = new Skill();
$skill = new SkillModel();
$type = 'edit'; //edit
$tree = $skill->getSkillsTree(null, null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);

@ -7,7 +7,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();

@ -78,7 +78,7 @@ function save_data($skills)
$skill['short_code'] = '';
$skill['icon'] = '';
$skill['updated_at'] = api_get_utc_datetime();
$oskill = new Skill();
$oskill = new SkillModel();
$skill_id = $oskill->add($skill);
$parents[$saved_id] = $skill_id;
}
@ -188,7 +188,7 @@ if (!empty($see_message_import)) {
echo Display::return_message($see_message_import, 'normal');
}
$objSkill = new Skill();
$objSkill = new SkillModel();
echo $objSkill->getToolBar();
$form = new FormValidator('user_import', 'post', 'skills_import.php');

@ -8,16 +8,16 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllowed();
SkillModel::isAllowed();
$interbreadcrumb[] = [
'url' => 'index.php',
"name" => get_lang('Administration'),
];
$skill = new Skill();
$skill_profile = new SkillProfile();
$skill_rel_user = new SkillRelUser();
$skill = new SkillModel();
$skill_profile = new SkillProfileModel();
$skill_rel_user = new SkillRelUserModel();
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php';
$tpl = new Template(get_lang('Skills'));
@ -118,7 +118,7 @@ switch ($action) {
Session::write('skills', $skills);
break;
case 'load_profile':
$skill_profile = new SkillRelProfile();
$skill_profile = new SkillRelProfileModel();
$skills = $skill_profile->getSkillsByProfile($id);
$total_skills_to_search = $skill->getSkillsInfo($skills);
break;

@ -8,7 +8,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(false, true);
Skill::isAllowed();
SkillModel::isAllowed();
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_js('d3/d3.v3.5.4.min.js');

@ -103,7 +103,7 @@ if (api_is_platform_admin()) {
api_get_path(WEB_CODE_PATH).'admin/add_drh_to_user.php?u='.$userId
);
if (Skill::isAllowed($userId, false)) {
if (SkillModel::isAllowed($userId, false)) {
$actions[] = Display::url(
Display::return_icon(
'skill-badges.png',

@ -290,7 +290,7 @@ switch ($action) {
$attendanceId = $attendance->attendance_add($link_to_gradebook);
if ($attendanceId) {
Skill::saveSkills($form, ITEM_TYPE_ATTENDANCE, $attendanceId);
SkillModel::saveSkills($form, ITEM_TYPE_ATTENDANCE, $attendanceId);
header('Location: '.$currentUrl.'&action=calendar_add&attendance_id='.$attendanceId);
exit;
}
@ -334,7 +334,7 @@ switch ($action) {
}
$attendance->attendance_edit($attendanceEntity, $link_to_gradebook);
Skill::saveSkills($form, ITEM_TYPE_ATTENDANCE, $attendanceId);
SkillModel::saveSkills($form, ITEM_TYPE_ATTENDANCE, $attendanceId);
Display::addFlash(Display::return_message(get_lang('Update successful')));
Security::clear_token();

@ -17,7 +17,7 @@ if (0 === $userId || 0 === $skillId) {
exit;
}
$objSkill = new Skill();
$objSkill = new SkillModel();
if (!$objSkill->userHasSkill($userId, $skillId, $courseId, $sessionId)) {
exit;
}

@ -3,7 +3,6 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Skill;
use Skill as SkillManager;
/**
* Page for assign skills to a user.
@ -18,7 +17,7 @@ if (empty($userId)) {
api_not_allowed(true);
}
SkillManager::isAllowed($userId);
SkillModel::isAllowed($userId);
$user = api_get_user_entity($userId);
@ -27,7 +26,7 @@ if (!$user) {
}
$entityManager = Database::getManager();
$skillManager = new SkillManager();
$skillManager = new SkillModel();
$skillRepo = $entityManager->getRepository(Skill::class);
$skillRelSkill = $entityManager->getRepository(\Chamilo\CoreBundle\Entity\SkillRelSkill::class);
$skillLevelRepo = $entityManager->getRepository(\Chamilo\CoreBundle\Entity\Level::class);

@ -9,7 +9,7 @@
require_once __DIR__.'/../inc/global.inc.php';
$skillId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$objSkill = new Skill();
$objSkill = new SkillModel();
$skill = $objSkill->get($skillId);
$json = [];

@ -25,7 +25,7 @@ if ($skill) {
'short_code' => $skill->getShortCode(),
'description' => $skill->getDescription(),
'criteria' => $skill->getCriteria(),
'badge_image' => Skill::getWebIconPath($skill),
'badge_image' => SkillModel::getWebIconPath($skill),
];
$template = new Template();

@ -49,7 +49,7 @@ if (!$user || !$skill) {
exit;
}
if (!Skill::isToolAvailable()) {
if (!SkillModel::isToolAvailable()) {
api_not_allowed(true);
}
@ -61,7 +61,7 @@ $skillInfo = [
'short_code' => $skill->getShortCode(),
'description' => $skill->getDescription(),
'criteria' => $skill->getCriteria(),
'badge_image' => Skill::getWebIconPath($skill),
'badge_image' => SkillModel::getWebIconPath($skill),
'courses' => [],
];
@ -80,7 +80,7 @@ $currentUserId = api_get_user_id();
$currentUser = api_get_user_entity($currentUserId);
$allowExport = $currentUser ? $currentUser->getId() === $user->getId() : false;
$allowComment = $currentUser ? Skill::userCanAddFeedbackToUser($currentUser, $user) : false;
$allowComment = $currentUser ? SkillModel::userCanAddFeedbackToUser($currentUser, $user) : false;
$skillIssueDate = api_get_local_time($skillIssue->getAcquiredSkillAt());
$currentSkillLevel = get_lang('No level acquired yet');
if ($skillIssue->getAcquiredLevel()) {
@ -100,12 +100,12 @@ $skillIssueInfo = [
'user_id' => $skillIssue->getUser()->getId(),
'user_complete_name' => UserManager::formatUserFullName($skillIssue->getUser()),
'skill_id' => $skillIssue->getSkill()->getId(),
'skill_badge_image' => Skill::getWebIconPath($skillIssue->getSkill()),
'skill_badge_image' => SkillModel::getWebIconPath($skillIssue->getSkill()),
'skill_name' => $skillIssue->getSkill()->getName(),
'skill_short_code' => $skillIssue->getSkill()->getShortCode(),
'skill_description' => $skillIssue->getSkill()->getDescription(),
'skill_criteria' => $skillIssue->getSkill()->getCriteria(),
'badge_assertion' => SkillRelUserManager::getAssertionUrl($skillIssue),
'badge_assertion' => SkillRelUserModel::getAssertionUrl($skillIssue),
'comments' => [],
'feedback_average' => $skillIssue->getAverage(),
];
@ -170,7 +170,7 @@ if ($profile) {
}
}
$allowToEdit = Skill::isAllowed($user->getId(), false);
$allowToEdit = SkillModel::isAllowed($user->getId(), false);
if ($showLevels && $allowToEdit) {
$formAcquiredLevel = new FormValidator('acquired_level');
@ -242,7 +242,7 @@ if ($allowExport) {
}
$htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';
$objSkill = new Skill();
$objSkill = new SkillModel();
$assertionUrl = $skillIssueInfo['badge_assertion'];
$skills = $objSkill->get($skillId);
$unbakedBadge = api_get_path(SYS_UPLOAD_PATH).'badges/'.$skills['icon'];

@ -19,7 +19,7 @@ if (!$userId || !$skillId) {
api_not_allowed(true);
}
Skill::isAllowed($userId);
SkillModel::isAllowed($userId);
$em = Database::getManager();
$user = api_get_user_entity($userId);
@ -55,7 +55,7 @@ $skillInfo = [
'short_code' => $skill->getShortCode(),
'description' => $skill->getDescription(),
'criteria' => $skill->getCriteria(),
'badge_image' => Skill::getWebIconPath($skill),
'badge_image' => SkillModel::getWebIconPath($skill),
'courses' => [],
];
@ -64,7 +64,7 @@ $allUserBadges = [];
foreach ($userSkills as $index => $skillIssue) {
$currentUser = api_get_user_entity($currentUserId);
$allowDownloadExport = $currentUser ? $currentUser->getId() === $user->getId() : false;
$allowComment = $currentUser ? Skill::userCanAddFeedbackToUser($currentUser, $user) : false;
$allowComment = $currentUser ? SkillModel::userCanAddFeedbackToUser($currentUser, $user) : false;
$skillIssueDate = api_get_local_time($skillIssue->getAcquiredSkillAt());
$currentSkillLevel = get_lang('No level acquired yet');
if ($skillIssue->getAcquiredLevel()) {
@ -86,12 +86,12 @@ foreach ($userSkills as $index => $skillIssue) {
'user_id' => $skillIssue->getUser()->getId(),
'user_complete_name' => UserManager::formatUserFullName($skillIssue->getUser()),
'skill_id' => $skillIssue->getSkill()->getId(),
'skill_badge_image' => Skill::getWebIconPath($skillIssue->getSkill()),
'skill_badge_image' => SkillModel::getWebIconPath($skillIssue->getSkill()),
'skill_name' => $skillIssue->getSkill()->getName(),
'skill_short_code' => $skillIssue->getSkill()->getShortCode(),
'skill_description' => $skillIssue->getSkill()->getDescription(),
'skill_criteria' => $skillIssue->getSkill()->getCriteria(),
'badge_assertion' => SkillRelUserManager::getAssertionUrl($skillIssue),
'badge_assertion' => SkillRelUserModel::getAssertionUrl($skillIssue),
'comments' => [],
'feedback_average' => $skillIssue->getAverage(),
];
@ -231,7 +231,7 @@ foreach ($userSkills as $index => $skillIssue) {
}
$htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';
$objSkill = new Skill();
$objSkill = new SkillModel();
$assertionUrl = $skillIssueInfo['badge_assertion'];
$skills = $objSkill->get($skillId);
$unbakedBadge = api_get_path(SYS_UPLOAD_PATH)."badges/".$skills['icon'];

@ -1801,7 +1801,7 @@ class Exercise
$repo->softDelete($exercise);
Skill::deleteSkillsFromItem($exerciseId, ITEM_TYPE_EXERCISE);
SkillModel::deleteSkillsFromItem($exerciseId, ITEM_TYPE_EXERCISE);
if ('true' === api_get_setting('search_enabled') &&
extension_loaded('xapian')
@ -2332,7 +2332,7 @@ class Exercise
}
}
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_EXERCISE, $this->iId);
$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_EXERCISE, $this->iId);
$extraField = new ExtraField('exercise');
$extraField->addElements(
@ -2680,7 +2680,7 @@ class Exercise
$extraFieldValue = new ExtraFieldValue('exercise');
$extraFieldValue->saveFieldValues($values);
Skill::saveSkills($form, ITEM_TYPE_EXERCISE, $iId);
SkillModel::saveSkills($form, ITEM_TYPE_EXERCISE, $iId);
}
}

@ -1044,7 +1044,7 @@ if ($isFeedbackAllowed && 'learnpath' !== $origin && 'student_progress' !== $ori
.'&id_session='.api_get_session_id();
}
Skill::addSkillsToUserForm(
SkillModel::addSkillsToUserForm(
$emailForm,
ITEM_TYPE_EXERCISE,
$exercise_id,

@ -284,7 +284,7 @@ if (api_is_allowed_to_edit(null, true)) {
$form->addElement('html', '</div>');
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_FORUM_THREAD, $threadId);
$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_FORUM_THREAD, $threadId);
$defaults = [];
$defaults['thread_qualify_gradebook'] = 0;
@ -314,7 +314,7 @@ if ($form->validate()) {
$values = $form->exportValues();
Security::clear_token();
updateThread($values);
Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $threadId);
SkillModel::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $threadId);
header('Location: '.$redirectUrl);
exit;
}

@ -178,7 +178,7 @@ function handleForum($url)
$locked = api_resource_is_locked_by_gradebook($id, LINK_FORUM_THREAD);
if ($resource && false === $locked) {
$repo->delete($resource);
Skill::deleteSkillsFromItem($id, ITEM_TYPE_FORUM_THREAD);
SkillModel::deleteSkillsFromItem($id, ITEM_TYPE_FORUM_THREAD);
$link_info = GradebookUtils::isResourceInCourseGradebook(
api_get_course_id(),
5,
@ -440,7 +440,7 @@ function forumForm(CForum $forum = null, $lp_id)
);*/
//$forumId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
//$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_FORUM, $forumId);
//$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_FORUM, $forumId);
$form->addElement('html', '</div>');
@ -497,7 +497,7 @@ function forumForm(CForum $forum = null, $lp_id)
$values = $form->getSubmitValues();
$forumId = store_forum($values, '', true);
if ($forumId) {
// Skill::saveSkills($form, ITEM_TYPE_FORUM, $forumId);
// SkillModel::saveSkills($form, ITEM_TYPE_FORUM, $forumId);
if (isset($values['forum_id'])) {
Display::addFlash(Display::return_message(get_lang('The forum has been modified'), 'confirmation'));
} else {
@ -2927,7 +2927,7 @@ function newThread(CForum $forum, $form_values = '', $showPreview = true)
$form->addElement('html', '</div>');
}
Skill::addSkillsToForm($form, ITEM_TYPE_FORUM_THREAD, 0);
SkillModel::addSkillsToForm($form, ITEM_TYPE_FORUM_THREAD, 0);
$form->addElement('checkbox', 'thread_sticky', '', get_lang('This is a sticky message (appears always on top and has a special sticky icon)'));
$form->addFile('user_upload', get_lang('Attachment'));
@ -2996,7 +2996,7 @@ function newThread(CForum $forum, $form_values = '', $showPreview = true)
$newThread = saveThread($forum, $values);
if ($newThread) {
Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $newThread->getIid());
SkillModel::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $newThread->getIid());
$postId = $newThread->getThreadLastPost();
if ($postId) {

@ -14,12 +14,12 @@ if (empty($userId)) {
api_not_allowed(true);
}
Skill::isAllowed($userId);
SkillModel::isAllowed($userId);
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$objSkillRelUser = new SkillRelUser();
$objSkillRelUser = new SkillRelUserModel();
$userSkills = $objSkillRelUser->getUserSkills($userId, $courseId, $sessionId);
if (empty($userSkills)) {
@ -58,7 +58,7 @@ $tpl->assign(
'content',
"<script>
$(function() {
OpenBadges.issue_no_modal(".json_encode($assertions).");
OpenBadges.issue_no_modal(".json_encode($assertions).");
});
</script>"
);

@ -703,7 +703,7 @@ abstract class AbstractLink implements GradebookItem
break;
}
$skillToString = Skill::getSkillRelItemsToString($toolType, $this->get_ref_id());
$skillToString = SkillModel::getSkillRelItemsToString($toolType, $this->get_ref_id());
return $skillToString;
}

@ -2053,12 +2053,12 @@ class Category implements GradebookItem
return false;
}
$skillToolEnabled = Skill::hasAccessToUserSkill(api_get_user_id(), $user_id);
$skillToolEnabled = SkillModel::hasAccessToUserSkill(api_get_user_id(), $user_id);
$userHasSkills = false;
if ($skillToolEnabled) {
$skill = new Skill();
$skill = new SkillModel();
$skill->addSkillToUser($user_id, $category, $courseId, $sessionId);
$objSkillRelUser = new SkillRelUser();
$objSkillRelUser = new SkillRelUserModel();
$userSkills = $objSkillRelUser->getUserSkills($user_id, $courseId, $sessionId);
$userHasSkills = !empty($userSkills);
}

@ -252,7 +252,7 @@ class CatForm extends FormValidator
}
if ($allowSkillEdit) {
if (Skill::isToolAvailable()) {
if (SkillModel::isToolAvailable()) {
$skillSelect = $this->addSelectAjax(
'skills',
[

@ -24,11 +24,11 @@ if (empty($userInfo)) {
api_not_allowed(true);
}
$skills = Skill::getSkillRelItemsPerCourse($courseId, $sessionId);
$skills = SkillModel::getSkillRelItemsPerCourse($courseId, $sessionId);
$uniqueSkills = [];
$itemsPerSkill = [];
$uniqueSkillsConclusion = [];
$skillRelUser = new SkillRelUser();
$skillRelUser = new SkillRelUserModel();
$userSkills = $skillRelUser->getUserSkills($userId, api_get_course_int_id(), api_get_session_id());
$userSkillsList = [];
if (!empty($userSkills)) {
@ -43,7 +43,7 @@ $codePath = api_get_path(WEB_CODE_PATH);
foreach ($skills as $skill) {
$skillId = $skill->getSkill()->getId();
$uniqueSkills[$skillId] = $skill->getSkill();
$itemInfo = Skill::getItemInfo($skill->getItemId(), $skill->getItemType());
$itemInfo = SkillModel::getItemInfo($skill->getItemId(), $skill->getItemType());
$criteria = [
'user' => $userId,

@ -542,7 +542,7 @@ switch ($action) {
$count = Question::get_count_course_medias($course_id);
break;
case 'get_user_skill_ranking':
$skill = new Skill();
$skill = new SkillModel();
$count = $skill->getUserListSkillRankingCount();
break;
case 'get_course_announcements':

@ -15,11 +15,11 @@ $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
api_block_anonymous_users();
Skill::isAllowed(api_get_user_id());
SkillModel::isAllowed(api_get_user_id());
$skill = new Skill();
$skill = new SkillModel();
$gradebook = new Gradebook();
$skillGradeBook = new SkillRelGradebook();
$skillGradeBook = new SkillRelGradebookModel();
$userId = api_get_user_id();
switch ($action) {
@ -120,7 +120,7 @@ switch ($action) {
case 'get_skills':
$loadUserData = isset($_REQUEST['load_user_data']) ? $_REQUEST['load_user_data'] : null;
$id = intval($_REQUEST['id']);
$skills = $skill->get_all($loadUserData, false, $id);
$skills = $skill->getAllSkills($loadUserData, false, $id);
echo json_encode($skills);
break;
case 'get_skill_info':
@ -454,7 +454,7 @@ switch ($action) {
$em->flush();
}
}
echo Skill::getUserSkillStatusLabel($skillRelItem, $skillRelItemRelUser, false);
echo SkillModel::getUserSkillStatusLabel($skillRelItem, $skillRelItemRelUser, false);
}
break;
case 'assign_user_to_skill':

@ -0,0 +1,106 @@
<?php
/* For licensing terms, see /license.txt */
class SkillProfileModel extends Model
{
public $columns = ['id', 'name', 'description'];
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_PROFILE);
$this->table_rel_profile = Database::get_main_table(TABLE_MAIN_SKILL_REL_PROFILE);
}
/**
* @return array
*/
public function getProfiles()
{
$sql = "SELECT * FROM $this->table p
INNER JOIN $this->table_rel_profile sp
ON (p.id = sp.profile_id) ";
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
/**
* This function is for editing profile info from profile_id.
*
* @param int $profileId
* @param string $name
* @param string $description
*
* @return bool
*/
public function updateProfileInfo($profileId, $name, $description)
{
$profileId = (int) $profileId;
if (empty($profileId)) {
return false;
}
$name = Database::escape_string($name);
$description = Database::escape_string($description);
$sql = "UPDATE $this->table SET
name = '$name',
description = '$description'
WHERE id = $profileId ";
Database::query($sql);
return true;
}
/**
* Call the save method of the parent class and the SkillRelProfile object.
*
* @param array $params
* @param bool $showQuery Whether to show the query in parent save() method
*
* @return mixed Profile ID or false if incomplete params
*/
public function save($params, $showQuery = false)
{
if (!empty($params)) {
$profile_id = parent::save($params, $showQuery);
if ($profile_id) {
$skill_rel_profile = new SkillRelProfileModel();
if (isset($params['skills'])) {
foreach ($params['skills'] as $skill_id) {
$attributes = [
'skill_id' => $skill_id,
'profile_id' => $profile_id,
];
$skill_rel_profile->save($attributes);
}
}
return $profile_id;
}
}
return false;
}
/**
* Delete a skill profile.
*
* @param int $id The skill profile id
*
* @return bool Whether delete a skill profile
*/
public function delete($id)
{
Database::delete(
$this->table_rel_profile,
[
'profile_id' => $id,
]
);
return parent::delete($id);
}
}

@ -0,0 +1,138 @@
<?php
/* For licensing terms, see /license.txt */
class SkillRelGradebookModel extends Model
{
public $columns = ['id', 'gradebook_id', 'skill_id'];
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK);
}
/**
* @param int $gradebookId
* @param int $skillId
*
* @return bool
*/
public function existsGradeBookSkill($gradebookId, $skillId)
{
$result = $this->find(
'all',
[
'where' => [
'gradebook_id = ? AND skill_id = ?' => [
$gradebookId,
$skillId,
],
],
]
);
if (!empty($result)) {
return true;
}
return false;
}
/**
* Gets an element.
*/
public function getSkillInfo($skill_id, $gradebookId)
{
if (empty($skill_id)) {
return [];
}
$result = Database::select(
'*',
$this->table,
[
'where' => [
'skill_id = ? AND gradebook_id = ? ' => [
$skill_id,
$gradebookId,
],
],
],
'first'
);
return $result;
}
/**
* @param int $skill_id
* @param array $gradebook_list
*/
public function updateGradeBookListBySkill($skill_id, $gradebook_list)
{
$original_gradebook_list = $this->find(
'all',
['where' => ['skill_id = ?' => [$skill_id]]]
);
$gradebooks_to_remove = [];
$gradebooks_to_add = [];
$original_gradebook_list_ids = [];
if (!empty($original_gradebook_list)) {
foreach ($original_gradebook_list as $gradebook) {
if (!in_array($gradebook['gradebook_id'], $gradebook_list)) {
$gradebooks_to_remove[] = $gradebook['id'];
}
}
foreach ($original_gradebook_list as $gradebook_item) {
$original_gradebook_list_ids[] = $gradebook_item['gradebook_id'];
}
}
if (!empty($gradebook_list)) {
foreach ($gradebook_list as $gradebook_id) {
if (!in_array($gradebook_id, $original_gradebook_list_ids)) {
$gradebooks_to_add[] = $gradebook_id;
}
}
}
if (!empty($gradebooks_to_remove)) {
foreach ($gradebooks_to_remove as $id) {
$this->delete($id);
}
}
if (!empty($gradebooks_to_add)) {
foreach ($gradebooks_to_add as $gradebook_id) {
$attributes = [
'skill_id' => $skill_id,
'gradebook_id' => $gradebook_id,
];
$this->save($attributes);
}
}
}
/**
* @param array $params
*
* @return bool|void
*/
public function updateBySkill($params)
{
$skillInfo = $this->existsGradeBookSkill(
$params['gradebook_id'],
$params['skill_id']
);
if ($skillInfo) {
return;
} else {
$result = $this->save($params);
}
if ($result) {
return true;
}
return false;
}
}

@ -0,0 +1,56 @@
<?php
/* For licensing terms, see /license.txt */
class SkillRelProfileModel extends Model
{
public $columns = ['id', 'skill_id', 'profile_id'];
/**
* Constructor.
*/
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_REL_PROFILE);
$this->tableProfile = Database::get_main_table(TABLE_MAIN_SKILL_PROFILE);
}
/**
* @param int $profileId
*
* @return array
*/
public function getSkillsByProfile($profileId)
{
$profileId = (int) $profileId;
$skills = $this->get_all(['where' => ['profile_id = ? ' => $profileId]]);
$return = [];
if (!empty($skills)) {
foreach ($skills as $skill_data) {
$return[] = $skill_data['skill_id'];
}
}
return $return;
}
/**
* This function is for getting profile info from profile_id.
*
* @param int $profileId
*
* @return array
*/
public function getProfileInfo($profileId)
{
$profileId = (int) $profileId;
$sql = "SELECT * FROM $this->table p
INNER JOIN $this->tableProfile pr
ON (pr.id = p.profile_id)
WHERE p.profile_id = ".$profileId;
$result = Database::query($sql);
$profileData = Database::fetch_array($result, 'ASSOC');
return $profileData;
}
}

@ -0,0 +1,192 @@
<?php
/* For licensing terms, see /license.txt */
class SkillRelSkillModel extends Model
{
public $columns = ['skill_id', 'parent_id', 'relation_type', 'level'];
/**
* Constructor.
*/
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_REL_SKILL);
$this->tableSkill = Database::get_main_table(TABLE_MAIN_SKILL);
}
/**
* Gets an element.
*
* @param int $id
*
* @return array
*/
public function getSkillInfo($id)
{
$id = (int) $id;
if (empty($id)) {
return [];
}
$result = Database::select(
'*',
$this->table,
['where' => ['skill_id = ?' => $id]],
'first'
);
return $result;
}
/**
* @param int $skillId
* @param bool $add_child_info
*
* @return array
*/
public function getSkillParents($skillId, $add_child_info = true)
{
$skillId = (int) $skillId;
$sql = 'SELECT child.* FROM '.$this->table.' child
LEFT JOIN '.$this->table.' parent
ON child.parent_id = parent.skill_id
WHERE child.skill_id = '.$skillId.' ';
$result = Database::query($sql);
$skill = Database::store_result($result, 'ASSOC');
$skill = isset($skill[0]) ? $skill[0] : null;
$parents = [];
if (!empty($skill)) {
if (null != $skill['parent_id']) {
$parents = self::getSkillParents($skill['parent_id']);
}
if ($add_child_info) {
$parents[] = $skill;
}
}
return $parents;
}
/**
* @param int $skillId
*
* @return array
*/
public function getDirectParents($skillId)
{
$skillId = (int) $skillId;
$sql = 'SELECT parent_id as skill_id
FROM '.$this->table.'
WHERE skill_id = '.$skillId;
$result = Database::query($sql);
$skill = Database::store_result($result, 'ASSOC');
$skill = isset($skill[0]) ? $skill[0] : null;
$parents = [];
if (!empty($skill)) {
$parents[] = $skill;
}
return $parents;
}
/**
* @param int $skill_id
* @param bool $load_user_data
* @param bool $user_id
*
* @return array
*/
public function getChildren(
$skill_id,
$load_user_data = false,
$user_id = false,
$order = ''
) {
$skill_id = (int) $skill_id;
$sql = 'SELECT parent.* FROM '.$this->tableSkill.' skill
INNER JOIN '.$this->table.' parent
ON parent.id = skill.id
WHERE parent_id = '.$skill_id.'
ORDER BY skill.name ASC';
$result = Database::query($sql);
$skills = Database::store_result($result, 'ASSOC');
$skill_obj = new SkillModel();
$skill_rel_user = new SkillRelUserModel();
if ($load_user_data) {
$passed_skills = $skill_rel_user->getUserSkills($user_id);
$done_skills = [];
foreach ($passed_skills as $done_skill) {
$done_skills[] = $done_skill['skill_id'];
}
}
if (!empty($skills)) {
foreach ($skills as &$skill) {
$skill['data'] = $skill_obj->get($skill['skill_id']);
if (isset($skill['data']) && !empty($skill['data'])) {
if (!empty($done_skills)) {
$skill['data']['passed'] = 0;
if (in_array($skill['skill_id'], $done_skills)) {
$skill['data']['passed'] = 1;
}
}
} else {
$skill = null;
}
}
}
return $skills;
}
/**
* @param array $params
*
* @return bool
*/
public function updateBySkill($params)
{
$result = Database::update(
$this->table,
$params,
['skill_id = ? ' => $params['skill_id']]
);
if ($result) {
return true;
}
return false;
}
/**
* @param int $skill_id
* @param int $parent_id
*
* @return bool
*/
public function relationExists($skill_id, $parent_id)
{
$result = $this->find(
'all',
[
'where' => [
'skill_id = ? AND parent_id = ?' => [
$skill_id,
$parent_id,
],
],
]
);
if (!empty($result)) {
return true;
}
return false;
}
}

@ -0,0 +1,152 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\SkillRelUser;
class SkillRelUserModel extends Model
{
public $columns = [
'id',
'user_id',
'skill_id',
'acquired_skill_at',
'assigned_by',
'course_id',
'session_id',
];
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
}
/**
* @param array $skill_list
*
* @return array
*/
public function getUserBySkills($skill_list)
{
$users = [];
if (!empty($skill_list)) {
$skill_list = array_map('intval', $skill_list);
$skill_list = implode("', '", $skill_list);
$sql = "SELECT user_id FROM {$this->table}
WHERE skill_id IN ('$skill_list') ";
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');
}
return $users;
}
/**
* Get the achieved skills for the user.
*
* @param int $userId
* @param int $courseId Optional. The course id
* @param int $sessionId Optional. The session id
*
* @return array The skill list. Otherwise return false
*/
public function getUserSkills($userId, $courseId = 0, $sessionId = 0)
{
if (empty($userId)) {
return [];
}
$courseId = (int) $courseId;
$sessionId = $sessionId ? (int) $sessionId : null;
$whereConditions = [
'user_id = ? ' => (int) $userId,
];
if ($courseId > 0) {
$whereConditions['AND course_id = ? '] = $courseId;
$whereConditions['AND session_id = ?'] = $sessionId;
}
$result = Database::select(
'skill_id',
$this->table,
[
'where' => $whereConditions,
],
'all'
);
return $result;
}
/**
* Get the relation data between user and skill.
*
* @param int $userId The user id
* @param int $skillId The skill id
* @param int $courseId Optional. The course id
* @param int $sessionId Optional. The session id
*
* @return array The relation data. Otherwise return false
*/
public function getByUserAndSkill($userId, $skillId, $courseId = 0, $sessionId = 0)
{
$sql = "SELECT * FROM {$this->table} WHERE user_id = %d AND skill_id = %d ";
if ($courseId > 0) {
$sql .= "AND course_id = %d ".api_get_session_condition($sessionId, true);
}
$sql = sprintf(
$sql,
$userId,
$skillId,
$courseId
);
$result = Database::query($sql);
return Database::fetch_assoc($result);
}
/**
* Get the URL for the issue.
*
* @return string
*/
public static function getIssueUrl(SkillRelUser $skillIssue)
{
return api_get_path(WEB_PATH)."badge/{$skillIssue->getId()}";
}
/**
* Get the URL for the All issues page.
*
* @return string
*/
public static function getIssueUrlAll(SkillRelUser $skillIssue)
{
return api_get_path(WEB_PATH)."skill/{$skillIssue->getSkill()->getId()}/user/{$skillIssue->getUser()->getId()}";
}
/**
* Get the URL for the assertion.
*
* @return string
*/
public static function getAssertionUrl(SkillRelUser $skillIssue)
{
$url = api_get_path(WEB_CODE_PATH).'badge/assertion.php?';
$url .= http_build_query([
'user' => $skillIssue->getUser()->getId(),
'skill' => $skillIssue->getSkill()->getId(),
'course' => $skillIssue->getCourse() ? $skillIssue->getCourse()->getId() : 0,
'session' => $skillIssue->getSession() ? $skillIssue->getSession()->getId() : 0,
]);
return $url;
}
}

@ -539,7 +539,7 @@ class Attendance
$attendance->setActive(2);
$repo->update($attendance);
Skill::deleteSkillsFromItem($attendance->getIid(), ITEM_TYPE_ATTENDANCE);
SkillModel::deleteSkillsFromItem($attendance->getIid(), ITEM_TYPE_ATTENDANCE);
return true;
@ -2397,7 +2397,7 @@ class Attendance
$form->applyFilter('attendance_weight', 'html_filter');
$form->addElement('html', '</div>');
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_ATTENDANCE, $attendance ? $attendance->getIid() : 0);
$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_ATTENDANCE, $attendance ? $attendance->getIid() : 0);
$form->addElement('html', '</div>');
}

@ -230,7 +230,7 @@ class Certificate extends Model
$courseId = $courseInfo['real_id'];
$sessionId = $category->get_session_id();
$skill = new Skill();
$skill = new SkillModel();
$skill->addSkillToUser(
$this->user_id,
$category,
@ -789,7 +789,7 @@ class Certificate extends Model
}
}
$skill = new Skill();
$skill = new SkillModel();
// Ofaj
$skills = $skill->getStudentSkills($this->user_id, 2);
$timeInSeconds = Tracking::get_time_spent_on_the_platform(

@ -4239,7 +4239,7 @@ class CourseManager
'session_category_id' => $session_category_id,
];
if (Skill::isAllowed($user_id, false)) {
if (SkillModel::isAllowed($user_id, false)) {
$em = Database::getManager();
$objUser = api_get_user_entity($user_id);
$objCourse = api_get_course_entity($course['real_id']);

@ -100,7 +100,7 @@ class Gradebook extends Model
$skill_list,
$deleteSkillNotInList = true
) {
$skill_gradebook = new SkillRelGradebook();
$skill_gradebook = new SkillRelGradebookModel();
$skill_gradebooks_source = $skill_gradebook->get_all(
['where' => ['gradebook_id = ?' => $gradebook_id]]
);
@ -172,7 +172,7 @@ class Gradebook extends Model
$form->addHeader($header);
$form->addElement('hidden', 'id', $id);
$skill = new Skill();
$skill = new SkillModel();
$skills = $skill->get_all();
$clean_skill_list = [];
foreach ($skills as $skill) {

@ -362,7 +362,7 @@ class Link extends Model
if ($link) {
$repo->delete($link);
self::delete_link_from_search_engine(api_get_course_id(), $id);
Skill::deleteSkillsFromItem($id, ITEM_TYPE_LINK);
SkillModel::deleteSkillsFromItem($id, ITEM_TYPE_LINK);
Display::addFlash(Display::return_message(get_lang('The link has been deleted')));
return true;
@ -1683,7 +1683,7 @@ Do you really want to delete this category and its links ?')."')) return false;\
}
}
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_LINK, $linkId);
$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_LINK, $linkId);
$form->addHidden('lp_id', $lpId);
$form->addButtonSave(get_lang('Save links'), 'submitLink');
$defaults['skills'] = array_keys($skillList);

@ -2478,11 +2478,11 @@ class SocialManager extends UserManager
*/
public static function getSkillBlock($userId, $orientation = 'horizontal')
{
if (false === Skill::isAllowed($userId, false)) {
if (false === SkillModel::isAllowed($userId, false)) {
return '';
}
$skill = new Skill();
$skill = new SkillModel();
$ranking = $skill->getUserSkillRanking($userId);
$template = new Template(null, false, false, false, false, false);

@ -6586,10 +6586,10 @@ class Tracking
*/
public static function displayUserSkills($userId, $courseId = 0, $sessionId = 0, $forceView = false)
{
if (false === Skill::isAllowed($userId, false) && false == $forceView) {
if (false === SkillModel::isAllowed($userId, false) && false == $forceView) {
return '';
}
$skillManager = new Skill();
$skillManager = new SkillModel();
$html = $skillManager->getUserSkillsTable($userId, $courseId, $sessionId)['table'];
return $html;

@ -286,7 +286,7 @@ class IndexManager
];
}
if (Skill::isAllowed(api_get_user_id(), false)) {
if (SkillModel::isAllowed(api_get_user_id(), false)) {
$items[] = [
'icon' => Display::return_icon('skill-badges.png', get_lang('My skills')),
'link' => api_get_path(WEB_CODE_PATH).'social/my_skills_report.php',
@ -2047,7 +2047,7 @@ class IndexManager
$badgeList[$id]['finished'] = true;
}
$objSkill = new Skill();
$objSkill = new SkillModel();
$skills = $category->get_skills();
$skillList = [];
foreach ($skills as $skill) {

@ -107,7 +107,7 @@ switch ($action) {
$link = new Link();
$link->setCourse($courseInfo);
$linkId = $link->save($form->exportValues());
Skill::saveSkills($form, ITEM_TYPE_LINK, $linkId);
SkillModel::saveSkills($form, ITEM_TYPE_LINK, $linkId);
Security::clear_token();
header('Location: '.$linkListUrl);
@ -120,7 +120,7 @@ switch ($action) {
$form = Link::getLinkForm($id, 'editlink');
if ($form->validate()) {
Link::editLink($id, $form->getSubmitValues());
Skill::saveSkills($form, ITEM_TYPE_LINK, $id);
SkillModel::saveSkills($form, ITEM_TYPE_LINK, $id);
header('Location: '.$linkListUrl);
exit;
}

@ -146,7 +146,7 @@ if ($subscriptionSettings['allow_add_users_to_lp']) {
$extraField = new ExtraField('lp');
$extra = $extraField->addElements($form, 0, ['lp_icon']);
Skill::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, 0);
SkillModel::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, 0);
$form->addElement('html', '</div>');
@ -193,7 +193,7 @@ if ($form->validate()) {
// Create temp form validator to save skills
$form = new FormValidator('lp_add');
$form->addSelect('skills', 'skills');
Skill::saveSkills($form, ITEM_TYPE_LEARNPATH, $lpId);
SkillModel::saveSkills($form, ITEM_TYPE_LEARNPATH, $lpId);
$extraFieldValue = new ExtraFieldValue('lp');
$_REQUEST['item_id'] = $lpId;

@ -726,7 +726,7 @@ switch ($action) {
} else {
Session::write('refresh', 1);
$oLP->delete(null, $lpId, 'remove');
Skill::deleteSkillsFromItem($lpId, ITEM_TYPE_LEARNPATH);
SkillModel::deleteSkillsFromItem($lpId, ITEM_TYPE_LEARNPATH);
Display::addFlash(Display::return_message(get_lang('Deleted')));
Session::erase('oLP');
require 'lp_list.php';

@ -288,7 +288,7 @@ $extra = $extraField->addElements(
['lp_icon', 'use_score_as_progress']
);
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, $lpId);
$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_LEARNPATH, $lpId);
// Submit button
$form->addButtonSave(get_lang('Save course settings'));
@ -378,7 +378,7 @@ if ($form->validate()) {
$form = new FormValidator('form1');
$form->addSelect('skills', 'skills');
Skill::saveSkills($form, ITEM_TYPE_LEARNPATH, $lpId);
SkillModel::saveSkills($form, ITEM_TYPE_LEARNPATH, $lpId);
if ('true' === api_get_setting('search_enabled')) {
$specific_fields = get_specific_field_list();

@ -245,7 +245,7 @@ function generateLPFinalItemTemplateBadgeLinks($userId, $courseId, $sessionId =
<div class='row'>
<div class='col-md-2 col-xs-4'>
<div class='thumbnail'>
<img class='skill-badge-img' src='".Skill::getWebIconPath($skill)."' >
<img class='skill-badge-img' src='".SkillModel::getWebIconPath($skill)."' >
</div>
</div>
<div class='col-md-8 col-xs-8'>

@ -725,7 +725,7 @@ if (api_can_login_as($studentId)) {
.Display::return_icon('login_as.png', get_lang('Login as'), null, ICON_SIZE_MEDIUM).'</a>&nbsp;&nbsp;';
}
if (Skill::isAllowed($studentId, false)) {
if (SkillModel::isAllowed($studentId, false)) {
$actions .= Display::url(
Display::return_icon(
'skill-badges.png',
@ -737,7 +737,7 @@ if (Skill::isAllowed($studentId, false)) {
);
}
if (Skill::isAllowed($studentId, false)) {
if (SkillModel::isAllowed($studentId, false)) {
$actions .= Display::url(
Display::return_icon(
'attendance.png',

@ -12,7 +12,7 @@ use Chamilo\CoreBundle\Framework\Container;
require_once __DIR__.'/../inc/global.inc.php';
$userId = api_get_user_id();
Skill::isAllowed($userId);
SkillModel::isAllowed($userId);
$isStudent = api_is_student();
$isStudentBoss = api_is_student_boss();
@ -41,7 +41,7 @@ $skillTable = Database::get_main_table(TABLE_MAIN_SKILL);
$skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$tableRows = [];
$objSkill = new Skill();
$objSkill = new SkillModel();
$tpl = new Template(get_lang('Skills'));
$tplPath = null;
@ -88,7 +88,7 @@ if ($isStudent) {
while ($resultData = Database::fetch_assoc($result)) {
$tableRow = [
'complete_name' => $followedStudents[$selectedStudent]['completeName'],
'skill_name' => Skill::translateName($resultData['name']),
'skill_name' => SkillModel::translateName($resultData['name']),
'achieved_at' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'course_image' => Display::return_icon(
'course.png',
@ -126,7 +126,7 @@ if ($isStudent) {
$tableRows = [];
$reportTitle = null;
$skills = $objSkill->get_all();
$skills = $objSkill->getAllSkills();
switch ($action) {
case 'filterByCourse':

@ -9,7 +9,7 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
Skill::isAllowed(api_get_user_id());
SkillModel::isAllowed(api_get_user_id());
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();

@ -7,7 +7,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_MYPROFILE;
api_block_anonymous_users();
Skill::isAllowed(api_get_user_id());
SkillModel::isAllowed(api_get_user_id());
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
@ -15,7 +15,7 @@ $htmlHeadXtra[] = api_get_js('jqueryui-touch-punch/jquery.ui.touch-punch.min.js'
$htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');
$htmlHeadXtra[] = api_get_js('skills.js');
$skill = new Skill();
$skill = new SkillModel();
$type = 'read'; //edit
$tree = $skill->getSkillsTree(api_get_user_id(), null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);

@ -8,7 +8,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_SOCIAL;
api_block_anonymous_users();
Skill::isAllowed(api_get_user_id());
SkillModel::isAllowed(api_get_user_id());
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_js('d3/d3.v3.5.4.min.js');
@ -23,7 +23,7 @@ $tpl = new Template(null, false, false);
$userId = api_get_user_id();
$userInfo = api_get_user_info();
$skill = new Skill();
$skill = new SkillModel();
$ranking = $skill->getUserSkillRanking($userId);
$skills = $skill->getUserSkills($userId, true);

@ -307,7 +307,7 @@ if ('edit' === $action && !empty($survey_id)) {
}
}
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_SURVEY, $survey_id);
$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_SURVEY, $survey_id);
$form->addElement('html', '</div><br />');
if (isset($_GET['survey_id']) && 'edit' === $action) {
@ -342,7 +342,7 @@ if ($form->validate()) {
$values = $form->getSubmitValues();
// Storing the survey
$return = SurveyManager::store_survey($values);
Skill::saveSkills($form, ITEM_TYPE_SURVEY, $return['id']);
SkillModel::saveSkills($form, ITEM_TYPE_SURVEY, $return['id']);
$values['item_id'] = $return['id'];
$extraFieldValue = new ExtraFieldValue('survey');

@ -575,7 +575,7 @@ class SurveyManager
api_get_user_id()
);*/
Skill::deleteSkillsFromItem($surveyId, ITEM_TYPE_SURVEY);
SkillModel::deleteSkillsFromItem($surveyId, ITEM_TYPE_SURVEY);
return true;
}

@ -2,8 +2,6 @@
/* For licensing terms, see /license.txt */
use Skill as SkillManager;
require_once __DIR__.'/../inc/global.inc.php';
ini_set('memory_limit', -1);
@ -457,7 +455,7 @@ function WSAssignSkill($params)
}
$em = Database::getManager();
$skillManager = new SkillManager();
$skillManager = new SkillModel();
$skillId = isset($params['skill_id']) ? $params['skill_id'] : 0;
$skillRepo = $em->getRepository('ChamiloCoreBundle:Skill');

@ -126,7 +126,7 @@ if ($form->validate()) {
updateWork($workData['iid'], $params, $courseInfo, $sessionId);
updatePublicationAssignment($workId, $params, $courseInfo, $groupId);
updateDirName($workData, $params['new_dir']);
Skill::saveSkills($form, ITEM_TYPE_STUDENT_PUBLICATION, $workData['iid']);
SkillModel::saveSkills($form, ITEM_TYPE_STUDENT_PUBLICATION, $workData['iid']);
Display::addFlash(Display::return_message(get_lang('Update successful'), 'success'));
header('Location: '.$currentUrl);
exit;

@ -869,7 +869,7 @@ function deleteDirWork($id)
WHERE publication_id = $id";
Database::query($sql);
Skill::deleteSkillsFromItem($id, ITEM_TYPE_STUDENT_PUBLICATION);
SkillModel::deleteSkillsFromItem($id, ITEM_TYPE_STUDENT_PUBLICATION);
Event::addEvent(
LOG_WORK_DIR_DELETE,
@ -4314,7 +4314,7 @@ function getWorkCommentForm(CStudentPublication $work, $workParent)
}
}
Skill::addSkillsToUserForm(
SkillModel::addSkillsToUserForm(
$form,
ITEM_TYPE_STUDENT_PUBLICATION,
$workParent['iid'],
@ -5584,7 +5584,7 @@ function getFormWork($form, $defaults = [], $workId = 0)
$form->addHtml('</div>');
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_STUDENT_PUBLICATION, $workId);
$skillList = SkillModel::addSkillsToForm($form, ITEM_TYPE_STUDENT_PUBLICATION, $workId);
if (!empty($defaults)) {
$defaults['skills'] = array_keys($skillList);

@ -170,7 +170,7 @@ switch ($action) {
);
if ($result) {
Skill::saveSkills($form, ITEM_TYPE_STUDENT_PUBLICATION, $result);
SkillModel::saveSkills($form, ITEM_TYPE_STUDENT_PUBLICATION, $result);
$message = Display::return_message(get_lang('Directory created'), 'success');
} else {

Loading…
Cancel
Save