WIP: use new UI see BT#13587

pull/2487/head
jmontoyaa 9 years ago
parent 88282984f0
commit 0a637c9bbd
  1. 107
      main/inc/lib/skill.lib.php
  2. 105
      main/template/default/skill/student_report.tpl

@ -717,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
@ -1109,17 +1144,17 @@ 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);
@ -1146,28 +1181,34 @@ class Skill extends Model
*/
public function processVertex(Vertex $vertex, $skills = [])
{
$subTable = '<div>';
foreach ($vertex->getVerticesEdgeTo() as $subVertex) {
$data = $subVertex->getAttribute('graphviz.data');
$label = $this->processSkillList([$data], 'mini', false);
$passed = in_array($data['id'], array_keys($skills));
$transparency = '';
if ($passed === false) {
// @todo use css class
$transparency = 'opacity: 0.4; filter: alpha(opacity=40);';
}
$subTable .= '<div style="float:left; margin-right:5px; ">';
$subTable .= '<div style="'.$transparency.'">';
$subTable .= $label;
$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 >';
$subTable .= $this->processVertex($subVertex, $skills);
/*$subTable .= '<div style="float:left; margin-right:5px; ">';
$subTable .= '<div style="'.$transparency.'">';
$subTable .= $label;
$subTable .= '</div>';*/
$subTable .= '</div >';
}
$subTable .= '<li>'.$label;
$subTable .= $this->processVertex($subVertex, $skills);
$subTable .= '</div>';
$subTable .= '</li>';
}
$subTable .= '</ul>';
}
return $subTable;
}
@ -1177,7 +1218,7 @@ class Skill extends Model
* @param int $courseId
* @param int $sessionId
*
* @return string
* @return array
*/
public function getUserSkillsTable($userId, $courseId = 0, $sessionId = 0)
{
@ -1220,7 +1261,7 @@ class Skill extends Model
$tableRows[] = $tableRow;
}
$allowLevels = api_get_configuration_value('skill_levels_names');
//id="skillList"
$tableResult = '<div class="table-responsive" >
<table class="table" >
<thead>
@ -1233,7 +1274,7 @@ class Skill extends Model
if (!empty($skillParents)) {
if (empty($allowLevels)) {
$tableResult .= $this->processSkillList($skills);
$tableResult .= $this->processSkillListSimple($skills);
} else {
$graph = new Graph();
$graph->setAttribute('graphviz.graph.rankdir', 'LR');
@ -1270,7 +1311,6 @@ class Skill extends Model
/** @var Vertex $vertex */
foreach ($root->getVerticesEdgeTo() as $vertex) {
$data = $vertex->getAttribute('graphviz.data');
$label = $this->processSkillList([$data], 'mini', false);
$passed = in_array($data['id'], array_keys($skills));
$transparency = '';
@ -1279,13 +1319,14 @@ class Skill extends Model
$transparency = 'opacity: 0.4; filter: alpha(opacity=40);';
}
$table .= '<td >';
$label = $this->processSkillListSimple([$data], 'mini', $transparency);
$table .= '<div style="'.$transparency.'">';
$table .= $label;
$table .= '<td >';
$table .= '</div>';
//$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>';

@ -6,6 +6,111 @@
</div>
{% endif %}
<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 #f80;
width: 50%;
height: 20px;
}
.organigrama li::after{
right: auto;
left: 50%;
border-left: 1px solid #f80;
}
.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 #f80;
-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 #f80;
width: 0;
height: 20px;
}
.organigrama li a {
border: 1px solid #f80;
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(255,128,0,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">

Loading…
Cancel
Save