parent
							
								
									ec87d31ac3
								
							
						
					
					
						commit
						2e96584422
					
				@ -0,0 +1,49 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
/** | 
				
			||||
 * Show information about a new assertion | 
				
			||||
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> | 
				
			||||
 * @package chamilo.badge | 
				
			||||
 */ | 
				
			||||
header('Content-Type: application/json'); | 
				
			||||
 | 
				
			||||
require_once '../inc/global.inc.php'; | 
				
			||||
 | 
				
			||||
$userId = isset($_GET['user']) ? intval($_GET['user']) : 0; | 
				
			||||
$skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0; | 
				
			||||
 | 
				
			||||
if ($userId === 0 || $skillId === 0) { | 
				
			||||
    exit; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$objSkill = new Skill(); | 
				
			||||
 | 
				
			||||
if (!$objSkill->user_has_skill($userId, $skillId)) { | 
				
			||||
    exit; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$objSkillRelUser = new SkillRelUser(); | 
				
			||||
$userSkill = $objSkillRelUser->getByUserAndSkill($userId, $skillId); | 
				
			||||
 | 
				
			||||
if ($userSkill == false) { | 
				
			||||
    exit; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$user = api_get_user_info($userSkill['user_id']); | 
				
			||||
 | 
				
			||||
$json = array( | 
				
			||||
    'uid' => $userSkill['id'], | 
				
			||||
    'recipient' => array( | 
				
			||||
        'type' => 'email', | 
				
			||||
        'hashed' => false, | 
				
			||||
        'identity' => $user['email'] | 
				
			||||
    ), | 
				
			||||
    'issuedOn' => strtotime($userSkill['acquired_skill_at']), | 
				
			||||
    'badge' => api_get_path(WEB_CODE_PATH) . "badge/class.php?id=$skillId", | 
				
			||||
    'verify' => array( | 
				
			||||
        'type' => 'hosted', | 
				
			||||
        'url' => api_get_path(WEB_CODE_PATH) . "badge/assertion.php?user=$userId&skill=$skillId" | 
				
			||||
    ) | 
				
			||||
); | 
				
			||||
 | 
				
			||||
echo json_encode($json); | 
				
			||||
@ -0,0 +1,25 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
/** | 
				
			||||
 * Show information about the OpenBadge class | 
				
			||||
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> | 
				
			||||
 * @package chamilo.badge | 
				
			||||
 */ | 
				
			||||
header('Content-Type: application/json'); | 
				
			||||
 | 
				
			||||
require_once '../inc/global.inc.php'; | 
				
			||||
 | 
				
			||||
$skillId = isset($_GET['id']) ? intval($_GET['id']) : 0; | 
				
			||||
 | 
				
			||||
$objSkill = new Skill(); | 
				
			||||
$skill = $objSkill->get($skillId); | 
				
			||||
 | 
				
			||||
$json = array( | 
				
			||||
    'name' => $skill['name'], | 
				
			||||
    'description' => $skill['description'], | 
				
			||||
    'image' => api_get_path(WEB_CODE_PATH) . $skill['icon'], | 
				
			||||
    'criteria' => api_get_path(WEB_CODE_PATH) . "badge/criteria.php?id=$skillId", | 
				
			||||
    'issuer' => api_get_path(WEB_CODE_PATH) . "badge/issuer.php", | 
				
			||||
); | 
				
			||||
 | 
				
			||||
echo json_encode($json); | 
				
			||||
@ -0,0 +1,17 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
/** | 
				
			||||
 * Show information about OpenBadge citeria | 
				
			||||
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> | 
				
			||||
 * @package chamilo.badge | 
				
			||||
 */ | 
				
			||||
header('Content-Type: text/plain'); | 
				
			||||
 | 
				
			||||
require_once '../inc/global.inc.php'; | 
				
			||||
 | 
				
			||||
$skillId = isset($_GET['id']) ? intval($_GET['id']) : 0; | 
				
			||||
 | 
				
			||||
$objSkill = new Skill(); | 
				
			||||
$skill = $objSkill->get($skillId); | 
				
			||||
 | 
				
			||||
echo $skill['criteria']; | 
				
			||||
@ -0,0 +1,17 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
/** | 
				
			||||
 * Show information about the OpenBadge issuer | 
				
			||||
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> | 
				
			||||
 * @package chamilo.badge | 
				
			||||
 */ | 
				
			||||
require_once '../inc/global.inc.php'; | 
				
			||||
 | 
				
			||||
header('Content-Type: application/json'); | 
				
			||||
 | 
				
			||||
$json = array( | 
				
			||||
    'name' => api_get_setting('Institution'), | 
				
			||||
    'url' => api_get_path(WEB_PATH) | 
				
			||||
); | 
				
			||||
 | 
				
			||||
echo json_encode($json); | 
				
			||||
@ -0,0 +1,48 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
/** | 
				
			||||
 * Show the achieved badges by an user | 
				
			||||
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> | 
				
			||||
 * @package chamilo.badge | 
				
			||||
 */ | 
				
			||||
$cidReset = true; | 
				
			||||
 | 
				
			||||
require_once '../inc/global.inc.php'; | 
				
			||||
 | 
				
			||||
$userId = isset($_GET['user']) ? intval($_GET['user']) : 0; | 
				
			||||
 | 
				
			||||
if ($userId === 0) { | 
				
			||||
    exit; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$objSkillRelUser = new SkillRelUser(); | 
				
			||||
$userSkills = $objSkillRelUser->get_user_skills($userId); | 
				
			||||
 | 
				
			||||
if (empty($userSkills)) { | 
				
			||||
    exit; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$assertions = array(); | 
				
			||||
 | 
				
			||||
foreach ($userSkills as $skill) { | 
				
			||||
    $skillId = current($skill); | 
				
			||||
 | 
				
			||||
    $assertions[] = api_get_path(WEB_CODE_PATH) . "badge/assertion.php?user=$userId&skill=$skillId"; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$backpack = 'https://backpack.openbadges.org/'; | 
				
			||||
 | 
				
			||||
if (array_key_exists('openbadges_backpack', $_configuration)) { | 
				
			||||
    $backpack = $_configuration['openbadges_backpack']; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$htmlHeadXtra[] = '<script src="' . $backpack . 'issuer.js"></script>'; | 
				
			||||
 | 
				
			||||
$tpl = new Template(get_lang('Badges'), false, false); | 
				
			||||
 | 
				
			||||
$tpl->assign( | 
				
			||||
    'content', | 
				
			||||
    "<script>OpenBadges.issue_no_modal(" . json_encode($assertions) . ");</script>" | 
				
			||||
); | 
				
			||||
 | 
				
			||||
$tpl->display_one_col_template(); | 
				
			||||
					Loading…
					
					
				
		Reference in new issue