From 354d26e6e1014d014fcc094d9a3344a1ed331df7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 22 Aug 2012 14:31:29 +0200 Subject: [PATCH] More fixes see #1791 --- main/inc/lib/skill.lib.php | 59 +++++++++++++-------- main/template/default/skill/skill_wheel.tpl | 33 ++++++------ 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php index 86839b9122..bec19afb24 100644 --- a/main/inc/lib/skill.lib.php +++ b/main/inc/lib/skill.lib.php @@ -587,58 +587,70 @@ class Skill extends Model { } $original_skill = $skills; - + //var_dump($skills); //Show 1 item - if ($add_root) { - if (!empty($skill_id)) { - $skills[1] = array('id' => '1', 'name' => get_lang('Root'), 'parent_id' => '0'); - $skill_info = $this->get_skill_info($skill_id); - $skills[$skill_id] = $skill_info; - $skills[$skill_id]['parent_id'] = $skill_info['extra']['parent_id']; + if (!empty($skill_id)) { + if ($add_root) { + if (!empty($skill_id)) { + $skills[1] = array('id' => '1', 'name' => get_lang('Root'), 'parent_id' => '0'); + $skill_info = $this->get_skill_info($skill_id); + $skills[$skill_id] = $skill_info; + $skills[$skill_id]['parent_id'] = $skill_info['extra']['parent_id']; + } } } + + //var_dump($skills); $refs = array(); $skills_tree = null; // Create references for all nodes - $flat_array = array(); - $css_attributes = array('fill' => 'red'); + $flat_array = array(); $family = array(); if (!empty($skills)) { foreach ($skills as &$skill) { - if ($skill['parent_id'] == 0) { - $skill['parent_id'] = 'root'; + if (!empty($skill_id)) { + if ($skill['id'] == $skill_id) { + $skill['parent_id'] = 'root'; + } + } else { + if ($skill['parent_id'] == 0) { + $skill['parent_id'] = 'root'; + } } + //In order to paint all members of a family with the same color if ($skill['parent_id'] == 1) { $family[$skill['id']] = $this->get_all_children($skill['id']); } - $skill['data'] = array('parent_id' => $skill['parent_id']); // because except main keys (id, name, children) others keys are not saved while in the space tree - - $skill['data']['achieved'] = false; + // because except main keys (id, name, children) others keys are not saved while in the space tree + $skill['data'] = array('parent_id' => $skill['parent_id']); + //User achieved the skill (depends in the gradebook with certification) + $skill['data']['achieved'] = false; if ($user_id) { - $css_attributes = array('fill' => 'green'); $skill['data']['achieved'] = $this->user_has_skill($user_id, $skill['id']); } - $skill['data']['skill_has_gradebook'] = false; - + //Check if the skill has related gradebooks + $skill['data']['skill_has_gradebook'] = false; if (isset($skill['gradebooks']) && !empty($skill['gradebooks'])) { $skill['data']['skill_has_gradebook'] = true; - } - - $skill['data']['css_attributes'] = $css_attributes; + } + $refs[$skill['id']] = &$skill; $flat_array[$skill['id']] = &$skill; } +// var_dump($skills); + + //Checking family value $family_id = 1; $new_family_array = array(); @@ -650,21 +662,24 @@ class Skill extends Model { } $new_family_array[$main_family_id] = $family_id; $family_id++; - } + } if (empty($original_skill)) { $refs['root']['children'][0] = $skills[1]; $refs['root']['children'][0]['children'][0] = $skills[$skill_id]; $flat_array[$skill_id] = $skills[$skill_id]; } else { + + + // Moving node to the children index of their parents foreach ($skills as $my_skill_id => &$skill) { $skill['data']['family_id'] = $new_family_array[$skill['id']]; $refs[$skill['parent_id']]['children'][] = &$skill; $flat_array[$my_skill_id] = $skill; } + } - $skills_tree = array( 'name' => get_lang('SkillRootName'), 'id' => 'root', diff --git a/main/template/default/skill/skill_wheel.tpl b/main/template/default/skill/skill_wheel.tpl index 5aadcab8cc..e24a0dd0d3 100644 --- a/main/template/default/skill/skill_wheel.tpl +++ b/main/template/default/skill/skill_wheel.tpl @@ -516,7 +516,7 @@ $(document).ready(function() { .attr("fill-rule", "evenodd") .attr("class", "skill_partition skill_background") // .style("fill", colour) - .style("fill", function(d) { + .style("fill", function(d) { return set_skill_style(d, 'fill'); }) .style("stroke", function(d) { @@ -586,18 +586,20 @@ $(document).ready(function() { }); /* Icon settings */ - + + + /* var icon_click = icon.enter().append("text") .style("fill-opacity", 1) .style("fill", function(d) { - return "#000"; + //return "#000"; }) .attr("text-anchor", function(d) { return x(d.x + d.dx / 2) > Math.PI ? "end" : "start"; }) .attr("dy", ".2em") .attr("transform", function(d) { - /** Get the text details and define the rotation and general position */ + ///Get the text details and define the rotation and general position angle = x(d.x + d.dx / 2) * 180 / Math.PI - 90, rotate = angle; return "rotate(" + rotate + ")translate(" + (y(d.y) + padding +80) + ")rotate(" + (angle > 90 ? -180 : 0) + ")"; @@ -614,7 +616,7 @@ $(document).ready(function() { .attr("display", 'none') .text(function(d) { //return "Click"; - }); + });*/ }); } @@ -759,12 +761,10 @@ $(document).ready(function() { //console.log(d.depth + " - " + d.name + " + "+ color+ "+ " +d.counter); } else { color = colors[d.family_id]; - } - d.color = color; + } return color; } - color = '#fefefe'; - d.color = color; + color = '#fefefe'; return color; //missing colors } @@ -780,8 +780,7 @@ $(document).ready(function() { function set_skill_style(d, attribute) { //Nice rainbow colors - return_fill = get_color(d); - + return_fill = get_color(d); /*var p = color_patterns[18]; color = p(depth -1 + d.counter); @@ -798,16 +797,17 @@ $(document).ready(function() { //return_stroke = '#FCD23A'; } - //darkblue - + //darkblue //If the skill has a gradebook attached - if (d.skill_has_gradebook) { - return_fill = 'yellow'; + if (d.skill_has_gradebook) { + return_fill = '#FEF664'; //return_stroke = 'grey'; } switch (attribute) { case 'fill': + //In order to the text could identify the background + d.color = return_fill; return return_fill; break; case 'stroke': @@ -978,6 +978,9 @@ $(document).ready(function() {

{{ 'MySkills'|get_lang }}


+
+
+

{{ 'GetNewSkills'|get_lang }}