|
|
|
@ -17,7 +17,9 @@ if (!api_is_platform_admin(false, true) && !api_is_student_boss()) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isset($_REQUEST['user'])) { |
|
|
|
|
$userId = isset($_REQUEST['user']) ? (int) $_REQUEST['user'] : 0; |
|
|
|
|
|
|
|
|
|
if (empty($userId)) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -26,7 +28,7 @@ $skillRepo = $entityManager->getRepository('ChamiloCoreBundle:Skill'); |
|
|
|
|
$skillRelSkill = $entityManager->getRepository('ChamiloCoreBundle:SkillRelSkill'); |
|
|
|
|
$skillLevelRepo = $entityManager->getRepository('ChamiloSkillBundle:Level'); |
|
|
|
|
$skillUserRepo = $entityManager->getRepository('ChamiloCoreBundle:SkillRelUser'); |
|
|
|
|
$user = $entityManager->find('ChamiloUserBundle:User', $_REQUEST['user']); |
|
|
|
|
$user = $entityManager->find('ChamiloUserBundle:User', $userId); |
|
|
|
|
|
|
|
|
|
if (!$user) { |
|
|
|
|
Display::addFlash( |
|
|
|
@ -41,7 +43,7 @@ $skills = $skillRepo->findBy([ |
|
|
|
|
'status' => Skill::STATUS_ENABLED |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$url = api_get_path(WEB_CODE_PATH)."badge/assign.php?user=".$_REQUEST['user']."&id="; |
|
|
|
|
$url = api_get_path(WEB_CODE_PATH).'badge/assign.php?user='.$userId.'&id='; |
|
|
|
|
|
|
|
|
|
$htmlHeadXtra[] = '<script> |
|
|
|
|
$( document ).ready(function() { |
|
|
|
@ -60,11 +62,9 @@ foreach ($skills as $skill) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$skillId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : key($skillsOptions); |
|
|
|
|
|
|
|
|
|
$profile = $skillRepo->find($skillId)->getProfile(); |
|
|
|
|
|
|
|
|
|
if (!$profile) { |
|
|
|
|
|
|
|
|
|
$skillRelSkill = new SkillRelSkill(); |
|
|
|
|
$parents = $skillRelSkill->get_skill_parents($skillId); |
|
|
|
|
|
|
|
|
@ -116,7 +116,12 @@ $form->addSelect('acquired_level', get_lang('AcquiredLevel'), $acquiredLevel); |
|
|
|
|
$form->addRule('acquired_level', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
|
$form->addTextarea('argumentation', get_lang('Argumentation'), ['rows' => 6]); |
|
|
|
|
$form->addRule('argumentation', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
|
$form->addRule('argumentation', sprintf(get_lang('ThisTextShouldBeAtLeastXCharsLong'), 10), 'mintext', 10); |
|
|
|
|
$form->addRule( |
|
|
|
|
'argumentation', |
|
|
|
|
sprintf(get_lang('ThisTextShouldBeAtLeastXCharsLong'), 10), |
|
|
|
|
'mintext', |
|
|
|
|
10 |
|
|
|
|
); |
|
|
|
|
$form->applyFilter('argumentation', 'trim'); |
|
|
|
|
$form->addButtonSave(get_lang('Save')); |
|
|
|
|
$form->setDefaults($formDefaultValues); |
|
|
|
@ -138,7 +143,11 @@ if ($form->validate()) { |
|
|
|
|
if ($user->hasSkill($skill)) { |
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message( |
|
|
|
|
sprintf(get_lang('TheUserXHasAlreadyAchievedTheSkillY'), $user->getCompleteName(), $skill->getName()), |
|
|
|
|
sprintf( |
|
|
|
|
get_lang('TheUserXHasAlreadyAchievedTheSkillY'), |
|
|
|
|
$user->getCompleteName(), |
|
|
|
|
$skill->getName() |
|
|
|
|
), |
|
|
|
|
'warning' |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
@ -162,7 +171,11 @@ if ($form->validate()) { |
|
|
|
|
|
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message( |
|
|
|
|
sprintf(get_lang('SkillXAssignedToUserY'), $skill->getName(), $user->getCompleteName()), |
|
|
|
|
sprintf( |
|
|
|
|
get_lang('SkillXAssignedToUserY'), |
|
|
|
|
$skill->getName(), |
|
|
|
|
$user->getCompleteName() |
|
|
|
|
), |
|
|
|
|
'success' |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|