Add "table_of_hierarchical_skill_presentation" see BT#13587

pull/2458/head
jmontoyaa 8 years ago
parent e7403ee7b0
commit b12b7e5676
  1. 176
      main/inc/lib/skill.lib.php
  2. 3
      main/install/configuration.dist.php

@ -32,7 +32,7 @@ class SkillProfile extends Model
$sql = "SELECT * FROM $this->table p $sql = "SELECT * FROM $this->table p
INNER JOIN $this->table_rel_profile sp INNER JOIN $this->table_rel_profile sp
ON(p.id = sp.profile_id) "; ON(p.id = sp.profile_id) ";
$result = Database::query($sql); $result = Database::query($sql);
$profiles = Database::store_result($result, 'ASSOC'); $profiles = Database::store_result($result, 'ASSOC');
return $profiles; return $profiles;
@ -47,7 +47,11 @@ class SkillProfile extends Model
*/ */
public function updateProfileInfo($profileId, $name, $description) public function updateProfileInfo($profileId, $name, $description)
{ {
$profileId = intval($profileId); $profileId = (int) $profileId;
if (empty($profileId)) {
return false;
}
$name = Database::escape_string($name); $name = Database::escape_string($name);
$description = Database::escape_string($description); $description = Database::escape_string($description);
@ -720,16 +724,21 @@ class Skill extends Model
/** /**
* @param $skills * @param $skills
* @param string $imageSize * @param string $imageSize mini|small|big
* @param string $style * @param string $style
* @param bool $showBadge
* @param bool $showTitle
*
* @return string * @return string
*/ */
public function processSkillListSimple($skills, $imageSize = '', $style = '') public function processSkillListSimple($skills, $imageSize = '', $style = '', $showBadge = true, $showTitle = true)
{ {
if (empty($skills)) { if (empty($skills)) {
return ''; return '';
} }
$isHierarchicalTable = api_get_configuration_value('table_of_hierarchical_skill_presentation');
if (empty($imageSize)) { if (empty($imageSize)) {
$imageSize = 'img_small'; $imageSize = 'img_small';
} else { } else {
@ -737,30 +746,36 @@ class Skill extends Model
} }
$html = ''; $html = '';
$html .= '<ul class="list-badges">';
foreach ($skills as $skill) { foreach ($skills as $skill) {
if (isset($skill['data'])) { if (isset($skill['data'])) {
$skill = $skill['data']; $skill = $skill['data'];
} }
$item = $skill[$imageSize];
$name = '<div class="caption">'.$skill['name'].'</div>'; $item = '';
if ($showBadge) {
$item = $skill[$imageSize];
}
$name = $skill['name'];
if (!empty($skill['short_code'])) { if (!empty($skill['short_code'])) {
$name = $skill['short_code']; $name = $skill['short_code'];
} }
$item .= $name;
if (!$isHierarchicalTable) {
//$item .= '<br />';
}
if ($showTitle) {
$item .= $name;
}
if (isset($skill['url'])) { if (isset($skill['url'])) {
$html .= '<li class="thumbnail">';
$html .= Display::url($item, $skill['url'], ['target' => '_blank', 'style' => $style]); $html .= Display::url($item, $skill['url'], ['target' => '_blank', 'style' => $style]);
$html .= '</li>';
} else { } else {
$html .= '<li class="thumbnail">';
$html .= Display::url($item, '#', ['target' => '_blank', 'style' => $style]); $html .= Display::url($item, '#', ['target' => '_blank', 'style' => $style]);
$html .= '</li>';
} }
} }
$html .= '</li>';
return $html; return $html;
} }
@ -1198,13 +1213,19 @@ class Skill extends Model
/** /**
* @param Vertex $vertex * @param Vertex $vertex
* @param array $skills
* @param int $level
*
* @return string * @return string
*/ */
public function processVertex(Vertex $vertex, $skills = []) public function processVertex(Vertex $vertex, $skills = [], $level = 0)
{ {
$isHierarchicalTable = api_get_configuration_value('table_of_hierarchical_skill_presentation');
$subTable = ''; $subTable = '';
if ($vertex->getVerticesEdgeTo()->count() > 0) { if ($vertex->getVerticesEdgeTo()->count() > 0) {
$subTable .= '<ul>'; if ($isHierarchicalTable) {
$subTable .= '<ul>';
}
foreach ($vertex->getVerticesEdgeTo() as $subVertex) { foreach ($vertex->getVerticesEdgeTo() as $subVertex) {
$data = $subVertex->getAttribute('graphviz.data'); $data = $subVertex->getAttribute('graphviz.data');
$passed = in_array($data['id'], array_keys($skills)); $passed = in_array($data['id'], array_keys($skills));
@ -1213,21 +1234,40 @@ class Skill extends Model
// @todo use css class // @todo use css class
$transparency = 'opacity: 0.4; filter: alpha(opacity=40);'; $transparency = 'opacity: 0.4; filter: alpha(opacity=40);';
} }
$label = $this->processSkillListSimple([$data], 'mini', $transparency);
/*$subTable .= '<div style="float:left; margin-right:5px; ">'; if ($isHierarchicalTable) {
$subTable .= '<div style="'.$transparency.'">'; $label = $this->processSkillListSimple([$data], 'mini', $transparency);
$subTable .= $label; $subTable .= '<li>'.$label;
$subTable .= '</div>';*/ $subTable .= $this->processVertex($subVertex, $skills, $level + 1);
$subTable .= '</li>';
} else {
$imageSize = 'mini';
if ($level == 2) {
$imageSize = 'small';
}
$showTitle = true;
if ($level > 2) {
$showTitle = false;
}
$subTable .= '<li>'.$label; $label = $this->processSkillListSimple([$data], $imageSize, $transparency, true, $showTitle);
$subTable .= '<div class="thumbnail" style="float:left; margin-right:5px; ">';
$subTable .= '<div style="'.$transparency.'">';
$subTable .= $this->processVertex($subVertex, $skills); $subTable .= '<div style="text-align: center">';
$subTable .= $label;
$subTable .= '</div>';
$subTable .= '</li>';
$subTable .= '</div>';
$subTable .= $this->processVertex($subVertex, $skills, $level + 1);
$subTable .= '</div>';
}
} }
$subTable .= '</ul>'; if ($isHierarchicalTable) {
$subTable .= '</ul>';
}
} }
return $subTable; return $subTable;
@ -1284,12 +1324,19 @@ class Skill extends Model
} }
$tableRows[] = $tableRow; $tableRows[] = $tableRow;
} }
$isHierarchicalTable = api_get_configuration_value('table_of_hierarchical_skill_presentation');
$allowLevels = api_get_configuration_value('skill_levels_names'); $allowLevels = api_get_configuration_value('skill_levels_names');
$tableResult = '<div class="table-responsive">'; if ($isHierarchicalTable) {
$tableResult = '<div class="table-responsive">';
} else {
$tableResult = '<div id="skillList">';
}
if ($addTitle) { if ($addTitle) {
$tableResult .= ' $tableResult .= '
<table class="table" > <table class="table">
<thead> <thead>
<tr> <tr>
<th>'.get_lang('AchievedSkills').'</th> <th>'.get_lang('AchievedSkills').'</th>
@ -1331,32 +1378,64 @@ class Skill extends Model
} }
} }
$table = '<table class ="table table-bordered">'; if ($isHierarchicalTable) {
// Getting "root" vertex $table = '<table class ="table table-bordered">';
$root = $graph->getVertex(1); // Getting "root" vertex
$table .= '<tr>'; $root = $graph->getVertex(1);
/** @var Vertex $vertex */ $table .= '<tr>';
foreach ($root->getVerticesEdgeTo() as $vertex) { /** @var Vertex $vertex */
$data = $vertex->getAttribute('graphviz.data'); foreach ($root->getVerticesEdgeTo() as $vertex) {
$data = $vertex->getAttribute('graphviz.data');
$passed = in_array($data['id'], array_keys($skills));
$transparency = ''; $passed = in_array($data['id'], array_keys($skills));
if ($passed === false) { $transparency = '';
// @todo use a css class if ($passed === false) {
$transparency = 'opacity: 0.4; filter: alpha(opacity=40);'; // @todo use a css class
$transparency = 'opacity: 0.4; filter: alpha(opacity=40);';
}
$label = $this->processSkillListSimple([$data], 'mini', $transparency);
$table .= '<td >';
$table .= '<div class="skills_chart"> <ul><li>'.$label;
$table .= $this->processVertex($vertex, $skills);
$table .= '</ul></li></div>';
$table .= '</td>';
} }
$table .= '</tr></table>';
} else {
// Getting "root" vertex
$root = $graph->getVertex(1);
$table = '';
/** @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); $label = $this->processSkillListSimple([$data], 'mini', $transparency, false);
$table .= '<td >'; $skillTable = $this->processVertex($vertex, $skills, 2);
$table .= "<h3>$label</h3>";
//$table .= '<div style="'.$transparency.'">'; if (!empty($skillTable)) {
$table .= '<div class="skills_chart"> <ul><li>'.$label; $table .= '<table class ="table table-bordered">';
$table .= $this->processVertex($vertex, $skills); $table .= '<tr>';
$table .= '</ul></li></div>'; $table .= '<td>';
$table .= '</td>'; $table .= '<div>';
$table .= $skillTable;
$table .= '</div>';
$table .= '</td>';
$table .= '</tr></table>';
}
}
} }
$table .= '</tr></table>';
$tableResult .= $table; $tableResult .= $table;
} }
} else { } else {
@ -1372,7 +1451,6 @@ class Skill extends Model
} }
$tableResult .= '</div>'; $tableResult .= '</div>';
return [ return [
'skills' => $tableRows, 'skills' => $tableRows,
'table' => $tableResult, 'table' => $tableResult,

@ -722,6 +722,9 @@ $_configuration['gradebook_badge_sidebar'] = [
// Requires edit Entity Session: src/Chamilo/CoreBundle/Entity/Session.php uncomment "position" variable. // Requires edit Entity Session: src/Chamilo/CoreBundle/Entity/Session.php uncomment "position" variable.
//$_configuration['session_list_order'] = false; //$_configuration['session_list_order'] = false;
// Show skills as a hierarchical table
//$_configuration['table_of_hierarchical_skill_presentation'] = false;
// ------ Custom DB changes // ------ Custom DB changes
// Add user activation by confirmation email // Add user activation by confirmation email
// This option prevents the new user to login in the platform if your account is not confirmed via email // This option prevents the new user to login in the platform if your account is not confirmed via email

Loading…
Cancel
Save