Merge branch '1.10.x' into advsub

1.10.x
Daniel Barreto 10 years ago
commit 4864080f13
  1. 2
      main/admin/session_edit.php
  2. 2
      main/admin/skill_badge.php
  3. 2
      main/admin/skill_badge_create.php
  4. 2
      main/admin/skill_badge_issuer.php
  5. 2
      main/admin/skill_badge_list.php
  6. 13
      main/badge/assertion.php
  7. 2
      main/badge/class.php
  8. 20
      main/gradebook/get_badges.php
  9. 28
      main/gradebook/lib/be/category.class.php
  10. 6
      main/inc/lib/sessionmanager.lib.php
  11. 74
      main/inc/lib/skill.lib.php

@ -292,7 +292,7 @@ if ($form->validate()) {
$startDate = $params['date_start'];
$endDate = $params['date_end'];
$nb_days_acess_before = $params['nb_days_access_before'];
$nb_days_acess_after = $params['nb_days_acc ess_after'];
$nb_days_acess_after = $params['nb_days_access_after'];
$id_coach = $params['id_coach'];
$id_session_category = $params['session_category'];
$id_visibility = $params['session_visibility'];

@ -11,7 +11,7 @@ require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
if (!api_is_platform_admin()) {
if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') {
api_not_allowed(true);
}

@ -10,7 +10,7 @@ $cidReset = true;
require_once '../inc/global.inc.php';
require_once '../inc/lib/fileUpload.lib.php';
if (!api_is_platform_admin()) {
if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') {
api_not_allowed(true);
}

@ -9,7 +9,7 @@ $cidReset = true;
require_once '../inc/global.inc.php';
if (!api_is_platform_admin()) {
if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') {
api_not_allowed(true);
}

@ -10,7 +10,7 @@ $cidReset = true;
require_once '../inc/global.inc.php';
require_once '../inc/lib/fileUpload.lib.php';
if (!api_is_platform_admin()) {
if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true') {
api_not_allowed(true);
}

@ -11,6 +11,8 @@ require_once '../inc/global.inc.php';
$userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
$skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
$courseId = isset($_GET['course']) ? intval($_GET['course']) : 0;
$sessionId = isset($_GET['session']) ? intval($_GET['session']) : 0;
if ($userId === 0 || $skillId === 0) {
exit;
@ -18,12 +20,12 @@ if ($userId === 0 || $skillId === 0) {
$objSkill = new Skill();
if (!$objSkill->user_has_skill($userId, $skillId)) {
if (!$objSkill->user_has_skill($userId, $skillId, $courseId, $sessionId)) {
exit;
}
$objSkillRelUser = new SkillRelUser();
$userSkill = $objSkillRelUser->getByUserAndSkill($userId, $skillId);
$userSkill = $objSkillRelUser->getByUserAndSkill($userId, $skillId, $courseId, $sessionId);
if ($userSkill == false) {
exit;
@ -42,7 +44,12 @@ $json = array(
'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"
'url' => api_get_path(WEB_CODE_PATH) . "badge/assertion.php?" . http_build_query(array(
'user' => $userId,
'skill' => $skillId,
'course' => $courseId,
'session' => $sessionId
))
)
);

@ -17,7 +17,7 @@ $skill = $objSkill->get($skillId);
$json = array(
'name' => $skill['name'],
'description' => $skill['description'],
'image' => api_get_path(WEB_PATH) . $skill['icon'],
'image' => api_get_path(WEB_DATA_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",
);

@ -5,18 +5,22 @@
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.badge
*/
$cidReset = true;
require_once '../inc/global.inc.php';
if (api_get_setting('allow_skills_tool') !== 'true') {
api_not_allowed(true);
}
$userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
if ($userId === 0) {
exit;
}
$objSkillRelUser = new SkillRelUser();
$userSkills = $objSkillRelUser->get_user_skills($userId);
$userSkills = $objSkillRelUser->get_user_skills($userId, $courseId, $sessionId);
if (empty($userSkills)) {
exit;
@ -27,7 +31,15 @@ $assertions = array();
foreach ($userSkills as $skill) {
$skillId = current($skill);
$assertions[] = api_get_path(WEB_CODE_PATH) . "badge/assertion.php?user=$userId&skill=$skillId";
$assertionUrl = api_get_path(WEB_CODE_PATH) . "badge/assertion.php?";
$assertionUrl .= http_build_query(array(
'user' => $userId,
'skill' => $skillId,
'course' => $courseId,
'session' => $sessionId
));
$assertions[] = $assertionUrl;
}
$backpack = 'https://backpack.openbadges.org/';

@ -1666,14 +1666,6 @@ class Category implements GradebookItem
'class' => 'btn'
)
);
$badges = Display::url(
get_lang('DownloadBadges'),
api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
array(
'target' => '_blank',
'class' => 'btn'
)
);
$exportToPDF = Display::url(
Display::return_icon(
'pdf.png',
@ -1684,10 +1676,28 @@ class Category implements GradebookItem
"$url&action=export"
);
$html = array(
'badge_link' => $badges,
'certificate_link' => $certificates,
'pdf_link' => $exportToPDF
);
if (api_get_setting('allow_skills_tool') == 'true') {
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$objSkillRelUser = new SkillRelUser();
$userSkills = $objSkillRelUser->get_user_skills($user_id, $courseId, $sessionId);
if (!empty($userSkills)) {
$html['badge_link'] = Display::url(
get_lang('DownloadBadges'),
api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
array(
'target' => '_blank',
'class' => 'btn'
)
);
}
}
}
return $html;
}

@ -1361,12 +1361,6 @@ class SessionManager
$extraFields = array()
) {
$name = trim(stripslashes($name));
$year_start = intval($year_start);
$month_start = intval($month_start);
$day_start = intval($day_start);
$year_end = intval($year_end);
$month_end = intval($month_end);
$day_end = intval($day_end);
$id_coach = intval($id_coach);
$nb_days_acess_before = intval($nb_days_acess_before);
$nb_days_acess_after = intval($nb_days_acess_after);

@ -358,15 +358,37 @@ class SkillRelUser extends Model
return $users;
}
public function get_user_skills($user_id)
/**
* Get the achieved skills for the user
* @param int $userId
* @param int $courseId Optional. The course id
* @param int $sessionId Optional. The session id
* @return array The skill list. Otherwise return false
*/
public function get_user_skills($userId, $courseId = 0, $sessionId = 0)
{
if (empty($user_id)) {
if (empty($userId)) {
return array();
}
$courseId = intval($courseId);
$sessionId = intval($sessionId);
$whereConditions = array(
'user_id = ? ' => intval($userId)
);
if ($courseId > 0) {
$whereConditions['AND course_id = ? '] = $courseId;
$whereConditions['AND session_id = ?'] = $sessionId;
}
$result = Database::select(
'skill_id',
$this->table,
array('where' => array('user_id = ?' => intval($user_id))),
array(
'where' => $whereConditions
),
'all'
);
return $result;
@ -376,12 +398,19 @@ class SkillRelUser extends Model
* Get the relation data between user and skill
* @param int $userId The user id
* @param int $skillId The skill id
* @param int $courseId The course id
* @param int $sessionId Optional. The session id
* @return array The relation data. Otherwise return false
*/
public function getByUserAndSkill($userId, $skillId)
public function getByUserAndSkill($userId, $skillId, $courseId, $sessionId = 0)
{
$where = array(
'user_id = ? AND skill_id = ?' => array($userId, $skillId)
'user_id = ? AND skill_id = ? AND course_id = ? AND session_id = ?' => array(
intval($userId),
intval($skillId),
intval($courseId),
intval($sessionId)
)
);
return Database::select('*', $this->table, array(
@ -622,9 +651,6 @@ class Skill extends Model
public function add_skill_to_user($user_id, $gradebook_id, $courseId = 0, $sessionId = 0)
{
$courseId = intval($courseId);
$sessionId = intval($sessionId);
$skill_gradebook = new SkillRelGradebook();
$skill_rel_user = new SkillRelUser();
@ -637,8 +663,8 @@ class Skill extends Model
'user_id' => $user_id,
'skill_id' => $skill_gradebook['skill_id'],
'acquired_skill_at' => api_get_utc_datetime(),
'course_id' => $courseId,
'session_id' => $sessionId
'course_id' => intval($courseId),
'session_id' => intval($sessionId)
);
$skill_rel_user->save($params);
@ -994,26 +1020,28 @@ class Skill extends Model
}
/**
* Return true if the user has the skill
*
* @param int $userId User's id
* @param int $skillId Skill's id
* @param int $checkInParents if true, function will search also in parents of the given skill id
*
* @return bool
* Check if the user has the skill
* @param int $userId The user id
* @param int $skillId The skill id
* @param int $courseId Optional. The course id
* @param int $sessionId Optional. The session id
* @return boolean Wheter the user has the skill return true. Otherwise return false
*/
public function user_has_skill($user_id, $skill_id, $courseId = 0, $sessionId = 0)
{
public function user_has_skill($userId, $skillId, $courseId = 0, $sessionId = 0)
{
$courseId = intval($courseId);
$sessionId = intval($sessionId);
$whereConditions = array(
'user_id = ? ' => $user_id,
'AND skill_id = ? ' => $skill_id,
'AND course_id = ? ' => $courseId,
'AND session_id = ? ' => $sessionId
'user_id = ? ' => intval($userId),
'AND skill_id = ? ' => intval($skillId)
);
if ($courseId > 0) {
$whereConditions['AND course_id = ? '] = $courseId;
$whereConditions['AND session_id = ? '] = $sessionId;
}
$result = Database::select('COUNT(1) AS qty', $this->table_skill_rel_user, array(
'where' => $whereConditions
), 'first');

Loading…
Cancel
Save