Update skills changes from 1.11.x

pull/3063/head
jmontoyaa 8 years ago
parent 6a98afecf2
commit 20a97b75ac
  1. 2
      main/admin/skill_badge.php
  2. 2
      main/admin/skill_badge_create.php
  3. 2
      main/admin/skill_badge_list.php
  4. 2
      main/admin/skill_create.php
  5. 2
      main/admin/skill_edit.php
  6. 2
      main/admin/skill_list.php
  7. 2
      main/admin/skills.php
  8. 2
      main/admin/skills_gradebook.php
  9. 2
      main/admin/skills_profile.php
  10. 2
      main/admin/skills_wheel.php
  11. 4
      main/admin/user_information.php
  12. 2
      main/badge/issued.php
  13. 2
      main/badge/issued_all.php
  14. 2
      main/gradebook/get_badges.php
  15. 2
      main/inc/ajax/skill.ajax.php
  16. 2
      main/inc/lib/course.lib.php
  17. 309
      main/inc/lib/skill.lib.php
  18. 2
      main/inc/lib/social.lib.php
  19. 2
      main/inc/lib/tracking.lib.php
  20. 2
      main/inc/lib/userportal.lib.php
  21. 36
      main/social/my_skills_report.php
  22. 2
      main/social/skills_ranking.php
  23. 2
      main/social/skills_tree.php
  24. 2
      main/social/skills_wheel.php
  25. 84
      main/template/rainbow/skill/drh_report.tpl
  26. 44
      main/template/rainbow/skill/student_boss_report.tpl
  27. 152
      main/template/rainbow/skill/student_report.tpl

@ -12,7 +12,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
$backpack = 'https://backpack.openbadges.org/';

@ -14,7 +14,7 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
$this_section = SECTION_PLATFORM_ADMIN;

@ -14,7 +14,7 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
$this_section = SECTION_PLATFORM_ADMIN;

@ -16,7 +16,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'skill_list.php', 'name' => get_lang('ManageSkills'));

@ -16,7 +16,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'skill_list.php', 'name' => get_lang('ManageSkills'));

@ -14,7 +14,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
$action = isset($_GET['action']) ? $_GET['action'] : 'list';
$skillId = isset($_GET['id']) ? intval($_GET['id']) : 0;

@ -11,7 +11,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');

@ -11,7 +11,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();

@ -12,7 +12,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllow();
Skill::isAllowed();
$interbreadcrumb[] = array(
'url' => 'index.php',

@ -11,7 +11,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(false, true);
Skill::isAllow();
Skill::isAllowed();
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_js('d3/d3.v3.5.4.min.js');

@ -109,7 +109,7 @@ if (api_is_platform_admin()) {
api_get_path(WEB_CODE_PATH).'admin/add_drh_to_user.php?u='.$userId
);
if (Skill::isAllow($userId, false)) {
if (Skill::isAllowed($userId, false)) {
$actions[] = Display::url(
Display::return_icon(
'skill-badges.png',
@ -529,7 +529,7 @@ if (isset($_GET['action'])) {
*/
// ofaj
LegalManager::sendLegal($userId);
break;
case 'delete_legal':
// ofaj

@ -46,7 +46,7 @@ if (!$user || !$skill) {
exit;
}
Skill::isAllow($user->getId());
Skill::isAllowed($user->getId());
$userInfo = [
'id' => $user->getId(),

@ -20,7 +20,7 @@ if (!$userId || !$skillId) {
api_not_allowed(true);
}
Skill::isAllow($userId);
Skill::isAllowed($userId);
$em = Database::getManager();
$user = $em->find('ChamiloUserBundle:User', $userId);

@ -15,7 +15,7 @@ if (empty($userId)) {
api_not_allowed(true);
}
Skill::isAllow($userId);
Skill::isAllowed($userId);
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();

@ -10,7 +10,7 @@ $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
api_block_anonymous_users();
Skill::isAllow(api_get_user_id());
Skill::isAllowed(api_get_user_id());
$skill = new Skill();
$gradebook = new Gradebook();

@ -4368,7 +4368,7 @@ class CourseManager
'session_category_id' => $session_category_id
);
if (Skill::isAllow($user_id, false)) {
if (Skill::isAllowed($user_id, false)) {
$em = Database::getManager();
$objUser = $em->find('ChamiloUserBundle:User', $user_id);
$objCourse = $em->find('ChamiloCoreBundle:Course', $course['real_id']);

@ -3,6 +3,8 @@
use Chamilo\UserBundle\Entity\User;
use Chamilo\UserBundle\Entity\Repository\UserRepository;
use Fhaculty\Graph\Vertex;
use Fhaculty\Graph\Graph;
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
/**
@ -98,7 +100,7 @@ class SkillProfile extends Model
Database::delete(
$this->table_rel_profile,
array(
'profile_id' => $id
'profile_id' => $id,
)
);
@ -201,7 +203,7 @@ class SkillRelSkill extends Model
*/
public function getSkillParents($skill_id, $add_child_info = true)
{
$skill_id = (int) $skill_id;
$skill_id = intval($skill_id);
$sql = 'SELECT child.* FROM '.$this->table.' child
LEFT JOIN '.$this->table.' parent
ON child.parent_id = parent.skill_id
@ -223,15 +225,15 @@ class SkillRelSkill extends Model
}
/**
* @param int $skill_id
* @param int $skillId
* @return array
*/
public function getDirectParents($skill_id)
public function getDirectParents($skillId)
{
$skill_id = intval($skill_id);
$skillId = (int) $skillId;
$sql = 'SELECT parent_id as skill_id
FROM '.$this->table.'
WHERE skill_id = '.$skill_id.' ';
WHERE skill_id = '.$skillId.' ';
$result = Database::query($sql);
$skill = Database::store_result($result, 'ASSOC');
$skill = isset($skill[0]) ? $skill[0] : null;
@ -256,7 +258,7 @@ class SkillRelSkill extends Model
$order = ''
) {
$skill_id = (int) $skill_id;
$sql = 'SELECT skill.* FROM '.$this->tableSkill.' skill
$sql = 'SELECT parent.* FROM '.$this->tableSkill.' skill
INNER JOIN '.$this->table.' parent
ON parent.id = skill.id
WHERE parent_id = '.$skill_id.'
@ -277,11 +279,11 @@ class SkillRelSkill extends Model
if (!empty($skills)) {
foreach ($skills as &$skill) {
$skill['data'] = $skill_obj->get($skill['id']);
$skill['data'] = $skill_obj->get($skill['skill_id']);
if (isset($skill['data']) && !empty($skill['data'])) {
if (!empty($done_skills)) {
$skill['data']['passed'] = 0;
if (in_array($skill['id'], $done_skills)) {
if (in_array($skill['skill_id'], $done_skills)) {
$skill['data']['passed'] = 1;
}
}
@ -325,9 +327,9 @@ class SkillRelSkill extends Model
'where' => array(
'skill_id = ? AND parent_id = ?' => array(
$skill_id,
$parent_id
)
)
$parent_id,
),
),
)
);
@ -366,9 +368,9 @@ class SkillRelGradebook extends Model
'where' => array(
'gradebook_id = ? AND skill_id = ?' => array(
$gradebookId,
$skillId
)
)
$skillId,
),
),
)
);
if (!empty($result)) {
@ -392,9 +394,9 @@ class SkillRelGradebook extends Model
'where' => array(
'skill_id = ? AND gradebook_id = ? ' => array(
$skill_id,
$gradebookId
)
)
$gradebookId,
),
),
),
'first'
);
@ -444,7 +446,7 @@ class SkillRelGradebook extends Model
foreach ($gradebooks_to_add as $gradebook_id) {
$attributes = array(
'skill_id' => $skill_id,
'gradebook_id' => $gradebook_id
'gradebook_id' => $gradebook_id,
);
$this->save($attributes);
}
@ -533,7 +535,7 @@ class SkillRelUser extends Model
$courseId = intval($courseId);
$sessionId = $sessionId ? intval($sessionId) : null;
$whereConditions = array(
'user_id = ? ' => intval($userId)
'user_id = ? ' => intval($userId),
);
if ($courseId > 0) {
@ -545,7 +547,7 @@ class SkillRelUser extends Model
'skill_id',
$this->table,
array(
'where' => $whereConditions
'where' => $whereConditions,
),
'all'
);
@ -567,12 +569,12 @@ class SkillRelUser extends Model
intval($userId),
intval($skillId),
intval($courseId),
$sessionId ? intval($sessionId) : null
)
$sessionId ? intval($sessionId) : null,
),
);
return Database::select('*', $this->table, array(
'where' => $where
'where' => $where,
), 'first');
}
@ -590,7 +592,7 @@ class Skill extends Model
'access_url_id',
'short_code',
'icon',
'criteria'
'criteria',
);
public $required = array('name');
@ -629,6 +631,10 @@ class Skill extends Model
public function get($id)
{
$result = parent::get($id);
if (empty($result)) {
return [];
}
$path = api_get_path(WEB_UPLOAD_PATH).'badges/';
if (!empty($result['icon'])) {
@ -654,7 +660,6 @@ class Skill extends Model
$result['icon_big'] = $iconSmall;
$result['icon_small'] = $iconBig;
$result['icon_mini'] = $iconMini;
$result['img_mini'] = Display::img($iconBig, $result['name'], ['width' => ICON_SIZE_MEDIUM]);
$result['img_big'] = Display::img($iconBig, $result['name']);
$result['img_small'] = Display::img($iconSmall, $result['name']);
@ -688,6 +693,9 @@ class Skill extends Model
}
$html .= '<ul class="list-unstyled list-badges">';
foreach ($skills as $skill) {
if (isset($skill['data'])) {
$skill = $skill['data'];
}
$html .= '<li class="thumbnail">';
$item = $skill[$imageSize];
$item .= '<div class="caption">
@ -709,6 +717,41 @@ class Skill extends Model
return $html;
}
/**
* @param $skills
* @param string $imageSize
* @param string $style
* @return string
*/
public function processSkillListSimple($skills, $imageSize = '', $style = '')
{
if (empty($skills)) {
return '';
}
if (empty($imageSize)) {
$imageSize = 'img_small';
} else {
$imageSize = "img_$imageSize";
}
$html = '';
foreach ($skills as $skill) {
if (isset($skill['data'])) {
$skill = $skill['data'];
}
$item = $skill[$imageSize];
$item .= $skill['name'];
if (isset($skill['url'])) {
$html .= Display::url($item, $skill['url'], ['target' => '_blank', 'style' => $style]);
} else {
$html .= Display::url($item, '#', ['target' => '_blank', 'style' => $style]);
}
}
return $html;
}
/**
* @param int $id
* @return array
@ -888,7 +931,7 @@ class Skill extends Model
$skillRelSkill = new SkillRelSkill();
$skills = $skillRelSkill->getSkillParents($skillId, true);
foreach ($skills as &$skill) {
$skill['data'] = self::get($skill['skill_id']);
$skill['data'] = $this->get($skill['skill_id']);
}
return $skills;
}
@ -902,12 +945,22 @@ class Skill extends Model
{
$skillRelSkill = new SkillRelSkill();
$skills = $skillRelSkill->getDirectParents($skillId, true);
foreach ($skills as &$skill) {
$skill['data'] = self::get($skill['skill_id']);
$skill_info2 = $skillRelSkill->getSkillInfo($skill['skill_id']);
$skill['data']['parent_id'] = $skill_info2['parent_id'];
if (!empty($skills)) {
foreach ($skills as &$skill) {
$skillData = $this->get($skill['skill_id']);
if (empty($skillData)) {
continue;
}
$skill['data'] = $skillData;
$skill_info2 = $skillRelSkill->getSkillInfo($skill['skill_id']);
$parentId = isset($skill_info2['parent_id']) ? isset($skill_info2['parent_id']) : 0;
$skill['data']['parent_id'] = $parentId;
}
return $skills;
}
return $skills;
return [];
}
/**
@ -990,7 +1043,7 @@ class Skill extends Model
'skill_id' => $skill_gradebook['skill_id'],
'acquired_skill_at' => api_get_utc_datetime(),
'course_id' => intval($courseId),
'session_id' => $sessionId ? intval($sessionId) : null
'session_id' => $sessionId ? intval($sessionId) : null,
);
$skill_rel_user->save($params);
@ -1069,7 +1122,9 @@ class Skill extends Model
* Get user's skills
*
* @param int $userId User's id
* @param bool $get_skill_data
* @param bool $getSkillData
* @param int $courseId
* @param int $sessionId
*
* @return array
*/
@ -1089,22 +1144,21 @@ class Skill extends Model
$sessionCondition = " AND course_id = $sessionId ";
}
$sql = 'SELECT DISTINCT
s.id,
$sql = 'SELECT DISTINCT
s.id,
s.name,
s.icon,
u.id as issue,
u.acquired_skill_at,
s.icon,
u.id as issue,
u.acquired_skill_at,
u.course_id
FROM '.$this->table_skill_rel_user.' u
INNER JOIN '.$this->table.' s
ON u.skill_id = s.id
WHERE
WHERE
user_id = '.$userId.' '.$sessionCondition.' '.$courseCondition;
$result = Database::query($sql);
$skills = Database::store_result($result, 'ASSOC');
$uploadPath = api_get_path(WEB_UPLOAD_PATH);
$skillList = array();
if (!empty($skills)) {
foreach ($skills as $skill) {
@ -1121,30 +1175,67 @@ class Skill extends Model
return $skillList;
}
/**
* @param Vertex $vertex
* @return string
*/
public function processVertex(Vertex $vertex, $skills = [])
{
$subTable = '';
if ($vertex->getVerticesEdgeTo()->count() > 0) {
$subTable .= '<ul>';
foreach ($vertex->getVerticesEdgeTo() as $subVertex) {
$data = $subVertex->getAttribute('graphviz.data');
$passed = in_array($data['id'], array_keys($skills));
$transparency = '';
if ($passed === false) {
// @todo use css class
$transparency = 'opacity: 0.4; filter: alpha(opacity=40);';
}
$label = $this->processSkillListSimple([$data], 'mini', $transparency);
/*$subTable .= '<div style="float:left; margin-right:5px; ">';
$subTable .= '<div style="'.$transparency.'">';
$subTable .= $label;
$subTable .= '</div>';*/
$subTable .= '<li>'.$label;
$subTable .= $this->processVertex($subVertex, $skills);
$subTable .= '</li>';
}
$subTable .= '</ul>';
}
return $subTable;
}
/**
* @param int $userId
* @param int $courseId
* @param int $sessionId
*
* @return string
* @return array
*/
public function getUserSkillsTable($userId, $courseId = 0, $sessionId = 0)
{
$skills = $this->getUserSkills($userId, true, $courseId, $sessionId);
$courseTempList = [];
$skillParents = [];
$tableRows = [];
$skillParents = [];
foreach ($skills as $resultData) {
$parents = $this->get_parents($resultData['id']);
foreach ($parents as $parentData) {
if ($parentData['id'] == 1 || $parentData['parent_id'] == 1) {
continue;
}
$skillParents[$parentData['id']]['passed'] = in_array($parentData['id'], array_keys($skills));
$skillParents[$parentData['id']][] = $resultData;
$parentData['passed'] = in_array($parentData['id'], array_keys($skills));
$skillParents[$resultData['id']][$parentData['id']] = $parentData;
}
}
foreach ($skills as $resultData) {
$courseId = $resultData['course_id'];
if (!empty($courseId)) {
if (isset($courseTempList[$courseId])) {
@ -1157,10 +1248,10 @@ class Skill extends Model
$tableRow = array(
'skill_badge' => $resultData['img_mini'],
'skill_name' => Skill::translateName($resultData['name']),
'skill_name' => self::translateName($resultData['name']),
'achieved_at' => api_get_local_time($resultData['acquired_skill_at']),
'course_image' => '',
'course_name' => ''
'course_name' => '',
);
if (!empty($courseInfo)) {
@ -1169,11 +1260,10 @@ class Skill extends Model
}
$tableRows[] = $tableRow;
}
$allowLevels = api_get_configuration_value('skill_levels_names');
$tableResult = '<div class="table-responsive">
<table class="table" id="skillList">
$tableResult = '<div class="table-responsive" >
<table class="table" >
<thead>
<tr>
<th>'.get_lang('AchievedSkills').'</th>
@ -1181,47 +1271,66 @@ class Skill extends Model
</thead>
<tbody>
<tr><td>';
//$allowLevels = [];
if (!empty($skillParents)) {
if (empty($allowLevels)) {
$tableResult .= $this->processSkillList($skills);
$tableResult .= $this->processSkillListSimple($skills);
} else {
$table = new HTML_Table(['class' => 'table table-bordered']);
if (!empty($skillParents)) {
$column = 0;
$skillAdded = [];
foreach ($skillParents as $parentId => $data) {
if (in_array($parentId, $skillAdded)) {
continue;
}
$parentName = '';
if ($data['passed']) {
$parentInfo = $skills[$parentId];
$parentName = $this->processSkillList([$parentInfo], 'mini', false);
$graph = new Graph();
$graph->setAttribute('graphviz.graph.rankdir', 'LR');
foreach ($skillParents as $skillId => $parentList) {
$old = null;
foreach ($parentList as $parent) {
if ($graph->hasVertex($parent['id'])) {
$current = $graph->getVertex($parent['id']);
} else {
$current = $graph->createVertex($parent['id']);
$current->setAttribute('graphviz.data', $parent['data']);
}
$table->setHeaderContents(0, $column, $parentName);
$row = 1;
$skillsToShow = [];
foreach ($data as $skillData) {
if ($skillData['id'] == $parentId) {
continue;
if (!empty($old)) {
if ($graph->hasVertex($old['id'])) {
$nextVertex = $graph->getVertex($old['id']);
} else {
$nextVertex = $graph->createVertex($old['id']);
$nextVertex->setAttribute('graphviz.data', $old['data']);
}
if (empty($skillData['id'])) {
continue;
if (!$nextVertex->hasEdgeTo($current)) {
$nextVertex->createEdgeTo($current);
}
$skillAdded[] = $skillData['id'];
$skillsToShow[] = $skillData;
}
$table->setCellContents(
$row,
$column,
$this->processSkillList($skillsToShow, 'mini', false)
);
$row++;
$column++;
$old = $parent;
}
}
$tableResult .= $table->toHtml();
$table = '<table class ="table table-bordered">';
// Getting "root" vertex
$root = $graph->getVertex(1);
$table .= '<tr>';
/** @var Vertex $vertex */
foreach ($root->getVerticesEdgeTo() as $vertex) {
$data = $vertex->getAttribute('graphviz.data');
$passed = in_array($data['id'], array_keys($skills));
$transparency = '';
if ($passed === false) {
// @todo use a css class
$transparency = 'opacity: 0.4; filter: alpha(opacity=40);';
}
$label = $this->processSkillListSimple([$data], 'mini', $transparency);
$table .= '<td >';
//$table .= '<div style="'.$transparency.'">';
$table .= '<div class="organigrama"> <ul><li>'.$label;
$table .= $this->processVertex($vertex, $skills);
$table .= '</ul></li></div>';
$table .= '</td>';
}
$table .= '</tr></table>';
$tableResult .= $table;
}
} else {
$tableResult .= get_lang('WithoutAchievedSkills');
@ -1236,7 +1345,7 @@ class Skill extends Model
return [
'skills' => $tableRows,
'table' => $tableResult
'table' => $tableResult,
];
}
@ -1272,7 +1381,7 @@ class Skill extends Model
$skills[1] = array(
'id' => '1',
'name' => get_lang('Root'),
'parent_id' => '0'
'parent_id' => '0',
);
$skillInfo = $this->getSkillInfo($skill_id);
@ -1369,7 +1478,6 @@ class Skill extends Model
$flat_array[$skill_id] = $skills[$skill_id];
} else {
// Moving node to the children index of their parents
foreach ($skills as $my_skill_id => &$skill) {
if (isset($new_family_array[$skill['id']])) {
$skill['data']['family_id'] = $new_family_array[$skill['id']];
@ -1383,7 +1491,7 @@ class Skill extends Model
'name' => get_lang('SkillRootName'),
'id' => 'root',
'children' => $refs['root']['children'],
'data' => array()
'data' => array(),
);
}
@ -1424,7 +1532,7 @@ class Skill extends Model
}
$simple_tree[] = array(
'name' => $element['name'],
'children' => $children
'children' => $children,
);
}
}
@ -1613,7 +1721,7 @@ class Skill extends Model
$whereConditions = array(
'user_id = ? ' => intval($userId),
'AND skill_id = ? ' => intval($skillId)
'AND skill_id = ? ' => intval($skillId),
);
if ($courseId > 0) {
@ -1625,7 +1733,7 @@ class Skill extends Model
'COUNT(1) AS qty',
$this->table_skill_rel_user,
array(
'where' => $whereConditions
'where' => $whereConditions,
),
'first'
);
@ -1659,8 +1767,8 @@ class Skill extends Model
$skillRelProfileTable,
array(
'where' => array(
'skill_id = ?' => $id
)
'skill_id = ?' => $id,
),
),
'first'
);
@ -1851,7 +1959,7 @@ class Skill extends Model
*
* @return bool
*/
public static function isAllow($studentId = 0, $blockPage = true)
public static function isAllowed($studentId = 0, $blockPage = true)
{
if (self::isToolAvailable()) {
if (api_is_platform_admin()) {
@ -1889,7 +1997,7 @@ class Skill extends Model
{
$allowTool = api_get_setting('allow_skills_tool');
if ($allowTool == 'true') {
if ($allowTool === 'true') {
return true;
}
@ -1907,13 +2015,14 @@ class Skill extends Model
if (api_is_platform_admin()) {
return true;
}
// ofaj
if (api_is_student_boss()) {
$isBoss = UserManager::userIsBossOfStudent($currentUserId, $studentId);
if ($isBoss) {
return true;
}
}
$allow = api_get_configuration_value('allow_private_skills');
if ($allow === true) {
if (api_is_teacher()) {
@ -1955,7 +2064,7 @@ class Skill extends Model
foreach ($result as $item) {
$skills[] = [
'name' => self::translateName($item['name']),
'acquired_skill_at' => $item['acquired_skill_at']
'acquired_skill_at' => $item['acquired_skill_at'],
];
}
@ -1973,6 +2082,10 @@ class Skill extends Model
return isset($GLOBALS[$variable]) ? $GLOBALS[$variable] : $name;
}
/**
* @param string $code
* @return mixed|string
*/
public static function translateCode($code)
{
if (empty($code)) {

@ -2155,7 +2155,7 @@ class SocialManager extends UserManager
*/
public static function getSkillBlock($userId)
{
if (Skill::isAllow($userId, false) === false) {
if (Skill::isAllowed($userId, false) === false) {
return '';
}

@ -6454,7 +6454,7 @@ class Tracking
*/
public static function displayUserSkills($userId, $courseId = 0, $sessionId = 0)
{
if (Skill::isAllow($userId, false) === false) {
if (Skill::isAllowed($userId, false) === false) {
return '';
}
$skillManager = new Skill();

@ -395,7 +395,7 @@ class IndexManager
];
}
if (Skill::isAllow(0, false)) {
if (Skill::isAllowed(0, false)) {
$items[] = [
'icon' => Display::return_icon('skill-badges.png', get_lang('MySkills')),
'link' => api_get_path(WEB_CODE_PATH).'social/my_skills_report.php',

@ -10,7 +10,7 @@
require_once __DIR__.'/../inc/global.inc.php';
$userId = api_get_user_id();
Skill::isAllow($userId);
Skill::isAllowed($userId);
$isStudent = api_is_student();
$isStudentBoss = api_is_student_boss();
@ -46,7 +46,7 @@ if ($isStudent) {
$tpl->assign('skill_table', $result['table']);
$tplPath = 'skill/student_report.tpl';
} elseif ($isStudentBoss) {
$selectedStudent = isset($_REQUEST['student']) ? intval($_REQUEST['student']) : 0;
$selectedStudent = isset($_REQUEST['student']) ? (int) $_REQUEST['student'] : 0;
$tableRows = array();
$followedStudents = UserManager::getUsersFollowedByStudentBoss($userId);
@ -68,10 +68,10 @@ if ($isStudent) {
while ($resultData = Database::fetch_assoc($result)) {
$tableRow = array(
'completeName' => $followedStudents[$selectedStudent]['completeName'],
'skillName' => Skill::translateName($resultData['name']),
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'courseImage' => Display::return_icon(
'complete_name' => $followedStudents[$selectedStudent]['completeName'],
'skill_name' => Skill::translateName($resultData['name']),
'achieved_at' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'course_image' => Display::return_icon(
'course.png',
null,
null,
@ -79,7 +79,7 @@ if ($isStudent) {
null,
true
),
'courseName' => $resultData['title']
'course_name' => $resultData['title']
);
$imageSysPath = sprintf("%s%s/course-pic.png", api_get_path(SYS_COURSE_PATH), $resultData['directory']);
@ -100,8 +100,8 @@ if ($isStudent) {
}
$tplPath = 'skill/student_boss_report.tpl';
$tpl->assign('followedStudents', $followedStudents);
$tpl->assign('selectedStudent', $selectedStudent);
$tpl->assign('followed_students', $followedStudents);
$tpl->assign('selected_student', $selectedStudent);
} elseif ($isDRH) {
$selectedCourse = isset($_REQUEST['course']) ? intval($_REQUEST['course']) : null;
$selectedSkill = isset($_REQUEST['skill']) ? intval($_REQUEST['skill']) : 0;
@ -152,9 +152,9 @@ if ($isStudent) {
}
foreach ($tableRows as &$row) {
$row['completeName'] = api_get_person_name($row['firstname'], $row['lastname']);
$row['achievedAt'] = api_format_date($row['acquired_skill_at'], DATE_FORMAT_NUMBER);
$row['courseImage'] = Display::return_icon(
$row['complete_name'] = api_get_person_name($row['firstname'], $row['lastname']);
$row['achieved_at'] = api_format_date($row['acquired_skill_at'], DATE_FORMAT_NUMBER);
$row['course_image'] = Display::return_icon(
'course.png',
null,
null,
@ -175,20 +175,22 @@ if ($isStudent) {
$courseImageThumb->send_image($thumbSysPath);
}
$row['courseImage'] = $thumbWebPath;
$row['course_image'] = $thumbWebPath;
}
}
$tplPath = 'skill/drh_report.tpl';
$tpl->assign('action', $action);
$tpl->assign('courses', $courses);
$tpl->assign('skills', $skills);
$tpl->assign('selectedCourse', $selectedCourse);
$tpl->assign('selectedSkill', $selectedSkill);
$tpl->assign('reportTitle', $reportTitle);
$tpl->assign('selected_course', $selectedCourse);
$tpl->assign('selected_skill', $selectedSkill);
$tpl->assign('report_title', $reportTitle);
}
if (empty($tableRows)) {
Display::addFlash(Display::return_message(get_lang('NoResults')));
}
$tpl->assign('rows', $tableRows);
$templateName = $tpl->get_template($tplPath);
$contentTemplate = $tpl->fetch($templateName);

@ -10,7 +10,7 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
Skill::isAllow(api_get_user_id());
Skill::isAllowed(api_get_user_id());
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();

@ -11,7 +11,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_MYPROFILE;
api_block_anonymous_users();
Skill::isAllow(api_get_user_id());
Skill::isAllowed(api_get_user_id());
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();

@ -10,7 +10,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_SOCIAL;
api_block_anonymous_users();
Skill::isAllow(api_get_user_id());
Skill::isAllowed(api_get_user_id());
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_js('d3/d3.v3.5.4.min.js');

@ -1,14 +1,17 @@
{% if allowSkillsTool %}
{% if allow_skill_tool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
{% if allowDrhSkillsManagement %}
<a class="btn btn-default" href="{{ _p.web_main }}admin/skills_wheel.php">{{ 'ManageSkills' | get_lang }}</a>
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">
{{ 'SkillsWheel' | get_lang }}
</a>
{% if allow_drh_skills_management %}
<a class="btn btn-default" href="{{ _p.web_main }}admin/skills_wheel.php">
{{ 'ManageSkills' | get_lang }}
</a>
{% endif %}
</div>
{% endif %}
<h1 class="page-header">{{ 'Skills' | get_lang }}</h1>
<div class="row">
<div class="col-md-6">
<form class="form-inline" method="post" action="{{ _p.web_self }}">
@ -16,10 +19,12 @@
<select name="course" id="course">
<option value="0">{{ 'Select' | get_lang }}</option>
{% for course in courses %}
<option value="{{ course.id }}" {{ (course.id == selectedCourse) ? 'selected' : '' }}>{{ course.title }}</option>
<option value="{{ course.id }}" {{ (course.id == selected_course) ? 'selected' : '' }}>{{ course.title }}</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-default">{{ 'Filter' | get_lang }}</button>
<button type="submit" class="btn btn-default">
{{ 'Filter' | get_lang }}
</button>
</form>
</div>
<div class="col-md-6">
@ -28,53 +33,52 @@
<select name="skill" id="skill">
<option value="0">{{ 'Select' | get_lang }}</option>
{% for skill in skills %}
<option value="{{ skill.id }}" {{ (skill.id == selectedSkill) ? 'selected' : '' }}>{{ skill.name }}</option>
<option value="{{ skill.id }}" {{ (skill.id == selected_skill) ? 'selected' : '' }}>
{{ skill.name }}
</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-default"><em class="fa fa-filter"></em>{{ 'Filter' | get_lang }}</button>
<button type="submit" class="btn btn-default"><em class="fa fa-filter"></em>
{{ 'Filter' | get_lang }}
</button>
</form>
</div>
</div>
<h2 class="page-header">{{ reportTitle }} <small>{{ reportSubTitle }}</small></h2>
<h2 class="page-header">{{ report_title }}</h2>
{% if rows %}
<table class="table">
<thead>
<tr>
{% if action == 'filterByCourse' %}
<th>{{ 'Course' | get_lang }}</th>
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
{% elseif action == 'filterBySkill' %}
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
{% if action == 'filterByCourse' %}
<th>{{ 'Course' | get_lang }}</th>
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<td><img src="{{ row.courseImage }}" alt="{{ row.c_name }}"> {{ row.c_name }}</td>
<td>{{ row.skill_name }}</td>
<td>{{ row.complete_name }}</td>
<td>{{ row.achieved_at }}</td>
{% elseif action == 'filterBySkill' %}
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
<td>{{ row.skill_name }}</td>
<td>{{ row.complete_name }}</td>
<td>{{ row.achieved_at }}</td>
<td><img src="{{ row.course_image }}" alt="{{ row.c_name }}"> {{ row.c_name }}</td>
{% endif %}
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
{% if action == 'filterByCourse' %}
<td><img src="{{ row.courseImage }}" alt="{{ row.c_name }}"> {{ row.c_name }}</td>
<td>{{ row.skill_name }}</td>
<td>{{ row.completeName }}</td>
<td>{{ row.achievedAt }}</td>
{% elseif action == 'filterBySkill' %}
<td>{{ row.skill_name }}</td>
<td>{{ row.completeName }}</td>
<td>{{ row.achievedAt }}</td>
<td><img src="{{ row.courseImage }}" alt="{{ row.c_name }}"> {{ row.c_name }}</td>
{% endif %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}

@ -1,6 +1,8 @@
{% if allowSkillsTool %}
{% if allow_skill_tool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">
{{ 'SkillsWheel' | get_lang }}
</a>
</div>
{% endif %}
@ -10,8 +12,10 @@
<label>{{ 'Students' | get_lang }}</label>
<select name="student" id="student">
<option value="0">{{ 'Select' | get_lang }}</option>
{% for student in followedStudents %}
<option value="{{ student.user_id }}" {{ (student.user_id == selectedStudent) ? 'selected' : '' }}>{{ student.completeName }}</option>
{% for student in followed_students %}
<option value="{{ student.user_id }}" {{ (student.user_id == selected_student) ? 'selected' : '' }}>
{{ student.completeName }}
</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-primary">{{ 'Search' | get_lang }}</button>
@ -20,26 +24,22 @@
{% if rows %}
<table class="table">
<thead>
<tr>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'SkillsAcquired' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
</tr>
<tr>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'SkillsAcquired' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.completeName }}</td>
<td>{{ row.skillName }}</td>
<td>{{ row.achievedAt }}</td>
<td><img src="{{ row.courseImage }}" alt="{{ row.courseName }}"> {{ row.courseName }}</td>
</tr>
{% endfor %}
{% for row in rows %}
<tr>
<td>{{ row.complete_name }}</td>
<td>{{ row.skill_name }}</td>
<td>{{ row.achieved_at }}</td>
<td><img src="{{ row.course_image }}" alt="{{ row.course_name }}"> {{ row.course_name }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}

@ -1,32 +1,146 @@
{% if allowSkillsTool %}
{% if allow_skill_tool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">
{{ 'SkillsWheel' | get_lang }}
</a>
</div>
{% endif %}
<h1 class="page-header">{{ 'SkillsAcquired' | get_lang }}</h1>
<style>
.organigrama * {
margin: 0px;
padding: 0px;
}
.organigrama ul {
padding-top: 20px;
position: relative;
}
.organigrama li {
float: left;
text-align: center;
list-style-type: none;
padding: 20px 5px 0px 5px;
position: relative;
}
.organigrama li::before, .organigrama li::after {
content: '';
position: absolute;
top: 0px;
right: 50%;
border-top: 1px solid #A4DC2D;
width: 50%;
height: 20px;
}
.organigrama li::after{
right: auto;
left: 50%;
border-left: 1px solid #A4DC2D;
}
.organigrama li:only-child::before, .organigrama li:only-child::after {
display: none;
}
.organigrama li:only-child {
padding-top: 0;
}
.organigrama li:first-child::before, .organigrama li:last-child::after{
border: 0 none;
}
.organigrama li:last-child::before{
border-right: 1px solid #A4DC2D;
-webkit-border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
border-radius: 0 5px 0 0;
}
.organigrama li:first-child::after{
border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
}
.organigrama ul ul::before {
content: '';
position: absolute;
top: 0;
left: 50%;
border-left: 1px solid #A4DC2D;
width: 0;
height: 20px;
}
.organigrama li a {
border: 1px solid #A4DC2D;
padding: 1em 0.75em;
text-decoration: none;
color: #333;
background-color: rgba(255,255,255,0.5);
font-family: arial, verdana, tahoma;
font-size: 0.85em;
display: inline-block;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-webkit-transition: all 500ms;
-moz-transition: all 500ms;
transition: all 500ms;
}
.organigrama li a:hover {
border: 1px solid #fff;
color: #ddd;
background-color: rgba(185, 244, 46, 0.7);
display: inline-block;
}
.organigrama > ul > li > a {
font-size: 1em;
font-weight: bold;
}
.organigrama > ul > li > ul > li > a {
width: 8em;
}
</style>
{% if rows %}
<h1 class="page-header">{{ 'SkillsAcquired' | get_lang }}</h1>
<table class="table">
<thead>
<tr>
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
</tr>
<tr>
<th>{{ 'Badge' | get_lang }}</th>
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.skillName }}</td>
<td>{{ row.achievedAt }}</td>
<td><img src="{{ row.courseImage }}" alt="{{ row.courseName }}" width="32"> {{ row.courseName }}</td>
</tr>
{% endfor %}
{% for row in rows %}
<tr>
<td>{{ row.skill_badge }}</td>
<td>{{ row.skill_name }}</td>
<td>{{ row.achieved_at }}</td>
{% if row.course_name %}
<td>
<img src="{{ row.course_image }}" alt="{{ row.course_name }}" width="32">
{{ row.course_name }}
</td>
{% else %}
<td> - </td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% if skill_table %}
{{ skill_table }}
{% endif %}
{% endif %}

Loading…
Cancel
Save