I like to ask; which PHP file triggers to send this completed course email:
As we wish to create an automation when a student completes a course.
Wishing to apply some code into that send email function part to assign badge to the user.
Something like this:
$file = JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/easysocial.php';
$userId = 100; // need to assign the correct user id which you want to assign this badge to him
$assignBadgeMsg = JText::_('write your message here');
$badgeCommand = "plan1.subscribed";
$badge = ES::badges();
$badge->log('com_easysocial', $badgeCommand, $userId, $assignBadgeMsg);