Skip to content

Commit

Permalink
Gradebook - Add notification of skills from gradebook - refs BT#19823
Browse files Browse the repository at this point in the history
  • Loading branch information
cfasanando committed May 16, 2022
1 parent 644b881 commit 7f9ce3e
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions main/inc/lib/skill.lib.php
Expand Up @@ -577,11 +577,14 @@ public function getUserSkills($userId, $courseId = 0, $sessionId = 0)
'user_id = ? ' => (int) $userId,
];

if ($courseId > 0) {
if ($sessionId > 0) {
$whereConditions['AND course_id = ? '] = $courseId;
$whereConditions['AND session_id = ?'] = $sessionId;
$whereConditions['AND session_id = ? '] = $sessionId;
} else {
$whereConditions['AND course_id = ? AND session_id is NULL'] = $courseId;
}


$result = Database::select(
'skill_id',
$this->table,
Expand Down Expand Up @@ -1241,6 +1244,29 @@ public function addSkillToUser(
];

$skill_rel_user->save($params);

// It sends notifications about user skills from gradebook
$badgeAssignationNotification = api_get_configuration_value('badge_assignation_notification');
if ($badgeAssignationNotification) {
$entityManager = Database::getManager();
$skillRepo = $entityManager->getRepository('ChamiloCoreBundle:Skill');
$skill = $skillRepo->find($skill_gradebook['skill_id']);
if ($skill) {
$user = api_get_user_entity($userId);
$url = api_get_path(WEB_PATH)."skill/{$skill_gradebook['skill_id']}/user/{$userId}";
$message = sprintf(
get_lang('YouXHaveAchievedTheSkillYToSeeFollowLinkZ'),
$user->getFirstname(),
$skill->getName(),
Display::url($url, $url, ['target' => '_blank'])
);
MessageManager::send_message(
$user->getId(),
get_lang('YouHaveAchievedANewSkill'),
$message
);
}
}
}
}
}
Expand Down

0 comments on commit 7f9ce3e

Please sign in to comment.