Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/public/main/gradebook/get_badges.php

67 lines
1.5 KiB

<?php
/* For licensing terms, see /license.txt */
10 years ago
/**
* Show the achieved badges by an user.
*
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*/
require_once __DIR__.'/../inc/global.inc.php';
$userId = isset($_GET['user']) ? (int) $_GET['user'] : 0;
if (empty($userId)) {
api_not_allowed(true);
}
SkillModel::isAllowed($userId);
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$objSkillRelUser = new SkillRelUserModel();
$userSkills = $objSkillRelUser->getUserSkills($userId, $courseId, $sessionId);
if (empty($userSkills)) {
api_not_allowed(true);
}
$assertions = [];
foreach ($userSkills as $skill) {
$skillId = current($skill);
$assertionUrl = api_get_path(WEB_CODE_PATH).'skills/assertion.php?';
$assertionUrl .= http_build_query([
'user' => $userId,
'skill' => $skillId,
'course' => $courseId,
'session' => $sessionId,
]);
$assertions[] = $assertionUrl;
}
$backpack = 'https://backpack.openbadges.org/';
10 years ago
$configBackpack = api_get_setting('openbadges_backpack');
if (0 !== strcmp($backpack, $configBackpack)) {
$backpack = $configBackpack;
if ('/' !== substr($backpack, -1)) {
$backpack .= '/';
}
}
$htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';
$tpl = new Template(get_lang('Badges'), false, false);
$tpl->assign(
'content',
9 years ago
"<script>
$(function() {
OpenBadges.issue_no_modal(".json_encode($assertions).");
9 years ago
});
</script>"
);
$tpl->display_one_col_template();