Add skill badge in list see BT#13587

pull/2487/head
Julio 8 years ago
parent 136623afb5
commit eb5ad4f9f1
  1. 15
      main/inc/lib/skill.lib.php
  2. 57
      main/social/my_skills_report.php
  3. 24
      main/template/default/skill/student_report.tpl
  4. 4
      main/template/default/social/skills_block.tpl

@ -995,7 +995,8 @@ class Skill extends Model
public function getUserSkills($userId, $get_skill_data = false)
{
$userId = intval($userId);
$sql = 'SELECT DISTINCT s.id, s.name, s.icon, u.id as issue
$sql = 'SELECT DISTINCT
s.id, s.name, 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
@ -1005,12 +1006,13 @@ class Skill extends Model
$skills = Database::store_result($result, 'ASSOC');
$uploadPath = api_get_path(WEB_UPLOAD_PATH);
$clean_skill = array();
$defaultIcon = Display::returnIconPath('badges-default.png', ICON_SIZE_BIG);
if (!empty($skills)) {
foreach ($skills as $skill) {
if ($get_skill_data) {
$iconThumb = null;
$iconPath = null;
if (!empty($skill['icon'])) {
$iconThumb = sprintf(
"badges/%s-small.png",
@ -1021,7 +1023,14 @@ class Skill extends Model
"badges/%s.png",
sha1($skill['name'])
);
$skill['icon_image'] = Display::img($uploadPath.$iconThumb, $skill['name']);
$skill['icon'] = $uploadPath.$iconThumb;
} else {
$iconImage = Display::return_icon('badges-default.png', $skill['name'], null, ICON_SIZE_BIG);
$skill['icon_image'] = $iconImage;
$skill['icon'] = $defaultIcon;
}
$clean_skill[$skill['id']] = array_merge(
$skill,
array(
@ -1731,7 +1740,7 @@ class Skill extends Model
*/
public function getStudentSkills($userId)
{
$sql = "SELECT s.name, sru.acquired_skill_at
$sql = "SELECT s.id, s.name, sru.acquired_skill_at
FROM {$this->table} s
INNER JOIN {$this->table_skill_rel_user} sru
ON s.id = sru.skill_id

@ -25,6 +25,7 @@ $skillTable = Database::get_main_table(TABLE_MAIN_SKILL);
$skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$tableRows = array();
$objSkill = new Skill();
$tpl = new Template(get_lang('Skills'));
$tplPath = null;
@ -32,41 +33,31 @@ $tpl->assign('allow_skill_tool', api_get_setting('allow_skills_tool') === 'true'
$tpl->assign('allow_drh_skills_management', api_get_setting('allow_hr_skills_management') === 'true');
if ($isStudent) {
$sql = "SELECT s.name, sru.acquired_skill_at, c.title, c.directory
FROM $skillTable s
INNER JOIN $skillRelUserTable sru
ON s.id = sru.skill_id
LEFT JOIN $courseTable c
ON sru.course_id = c.id
WHERE sru.user_id = $userId";
$result = Database::query($sql);
while ($resultData = Database::fetch_assoc($result)) {
$skills = $objSkill->getUserSkills($userId, true);
$courseTempList = [];
foreach ($skills as $resultData) {
$courseId = $resultData['course_id'];
if (!empty($courseId)) {
if (isset($courseTempList[$courseId])) {
$courseInfo = $courseTempList[$courseId];
} else {
$courseInfo = api_get_course_info_by_id($courseId);
$courseTempList[$courseId] = $courseInfo;
}
}
$tableRow = array(
'skillName' => $resultData['name'],
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'courseImage' => Display::return_icon(
'course.png',
null,
null,
ICON_SIZE_MEDIUM,
null,
true
),
'courseName' => $resultData['title']
'skill_badge' => $resultData['icon_image'],
'skill_name' => $resultData['name'],
'achieved_at' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'course_image' => '',
'course_name' => ''
);
$imageSysPath = sprintf("%s%s/course-pic.png", api_get_path(SYS_COURSE_PATH), $resultData['directory']);
if (file_exists($imageSysPath)) {
$thumbSysPath = sprintf("%s%s/course-pic32.png", api_get_path(SYS_COURSE_PATH), $resultData['directory']);
$thumbWebPath = sprintf("%s%s/course-pic32.png", api_get_path(WEB_COURSE_PATH), $resultData['directory']);
if (!file_exists($thumbSysPath)) {
$courseImageThumb = new Image($imageSysPath);
$courseImageThumb->resize(32);
$courseImageThumb->send_image($thumbSysPath);
}
$tableRow['courseImage'] = $thumbWebPath;
if (!empty($courseInfo)) {
$tableRow['course_image'] = $courseInfo['course_image_source'];
$tableRow['course_name'] = $courseInfo['title'];
}
$tableRows[] = $tableRow;
}
@ -143,8 +134,6 @@ if ($isStudent) {
$tableRows = array();
$reportTitle = null;
$objSkill = new Skill();
$skills = $objSkill->get_all();
switch ($action) {

@ -10,23 +10,25 @@
<table class="table">
<thead>
<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>
{% if row.courseName %}
<td><img src="{{ row.courseImage }}" alt="{{ row.courseName }}" width="32"> {{ row.courseName }}</td>
{% else %}
<td> - </td>
{% endif %}
</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 %}

@ -38,7 +38,7 @@ jQuery(document).ready(function(){
{% for skill in skills %}
<li class="thumbnail">
<a href="{{ _p.web }}skill/{{ skill.id }}/user/{{ user_id }}" target="_blank">
<img title="{{ skill.name }}" class="img-responsive" src="{{ skill.icon ? skill.web_icon_thumb_path : 'badges-default.png'|icon(64) }}" width="64" height="64" alt="{{ skill.name }}">
<img title="{{ skill.name }}" class="img-responsive" src="{{ skill.icon }}" width="64" height="64" alt="{{ skill.name }}">
<div class="caption">
<p class="text-center">{{ skill.name }}</p>
</div>
@ -56,4 +56,4 @@ jQuery(document).ready(function(){
</div>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save