More fixes see #1791

skala
Julio Montoya 12 years ago
parent 7603767ec2
commit 354d26e6e1
  1. 45
      main/inc/lib/skill.lib.php
  2. 19
      main/template/default/skill/skill_wheel.tpl

@ -591,54 +591,66 @@ class Skill extends Model {
//var_dump($skills); //var_dump($skills);
//Show 1 item //Show 1 item
if ($add_root) { if (!empty($skill_id)) {
if (!empty($skill_id)) { if ($add_root) {
$skills[1] = array('id' => '1', 'name' => get_lang('Root'), 'parent_id' => '0'); if (!empty($skill_id)) {
$skill_info = $this->get_skill_info($skill_id); $skills[1] = array('id' => '1', 'name' => get_lang('Root'), 'parent_id' => '0');
$skills[$skill_id] = $skill_info; $skill_info = $this->get_skill_info($skill_id);
$skills[$skill_id]['parent_id'] = $skill_info['extra']['parent_id']; $skills[$skill_id] = $skill_info;
$skills[$skill_id]['parent_id'] = $skill_info['extra']['parent_id'];
}
} }
} }
//var_dump($skills);
$refs = array(); $refs = array();
$skills_tree = null; $skills_tree = null;
// Create references for all nodes // Create references for all nodes
$flat_array = array(); $flat_array = array();
$css_attributes = array('fill' => 'red');
$family = array(); $family = array();
if (!empty($skills)) { if (!empty($skills)) {
foreach ($skills as &$skill) { foreach ($skills as &$skill) {
if ($skill['parent_id'] == 0) { if (!empty($skill_id)) {
$skill['parent_id'] = 'root'; 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) { if ($skill['parent_id'] == 1) {
$family[$skill['id']] = $this->get_all_children($skill['id']); $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 // 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; $skill['data']['achieved'] = false;
if ($user_id) { if ($user_id) {
$css_attributes = array('fill' => 'green');
$skill['data']['achieved'] = $this->user_has_skill($user_id, $skill['id']); $skill['data']['achieved'] = $this->user_has_skill($user_id, $skill['id']);
} }
//Check if the skill has related gradebooks
$skill['data']['skill_has_gradebook'] = false; $skill['data']['skill_has_gradebook'] = false;
if (isset($skill['gradebooks']) && !empty($skill['gradebooks'])) { if (isset($skill['gradebooks']) && !empty($skill['gradebooks'])) {
$skill['data']['skill_has_gradebook'] = true; $skill['data']['skill_has_gradebook'] = true;
} }
$skill['data']['css_attributes'] = $css_attributes;
$refs[$skill['id']] = &$skill; $refs[$skill['id']] = &$skill;
$flat_array[$skill['id']] = &$skill; $flat_array[$skill['id']] = &$skill;
} }
// var_dump($skills);
//Checking family value
$family_id = 1; $family_id = 1;
$new_family_array = array(); $new_family_array = array();
@ -657,14 +669,17 @@ class Skill extends Model {
$refs['root']['children'][0]['children'][0] = $skills[$skill_id]; $refs['root']['children'][0]['children'][0] = $skills[$skill_id];
$flat_array[$skill_id] = $skills[$skill_id]; $flat_array[$skill_id] = $skills[$skill_id];
} else { } else {
// Moving node to the children index of their parents // Moving node to the children index of their parents
foreach ($skills as $my_skill_id => &$skill) { foreach ($skills as $my_skill_id => &$skill) {
$skill['data']['family_id'] = $new_family_array[$skill['id']]; $skill['data']['family_id'] = $new_family_array[$skill['id']];
$refs[$skill['parent_id']]['children'][] = &$skill; $refs[$skill['parent_id']]['children'][] = &$skill;
$flat_array[$my_skill_id] = $skill; $flat_array[$my_skill_id] = $skill;
} }
}
}
$skills_tree = array( $skills_tree = array(
'name' => get_lang('SkillRootName'), 'name' => get_lang('SkillRootName'),
'id' => 'root', 'id' => 'root',

@ -587,17 +587,19 @@ $(document).ready(function() {
/* Icon settings */ /* Icon settings */
/*
var icon_click = icon.enter().append("text") var icon_click = icon.enter().append("text")
.style("fill-opacity", 1) .style("fill-opacity", 1)
.style("fill", function(d) { .style("fill", function(d) {
return "#000"; //return "#000";
}) })
.attr("text-anchor", function(d) { .attr("text-anchor", function(d) {
return x(d.x + d.dx / 2) > Math.PI ? "end" : "start"; return x(d.x + d.dx / 2) > Math.PI ? "end" : "start";
}) })
.attr("dy", ".2em") .attr("dy", ".2em")
.attr("transform", function(d) { .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, angle = x(d.x + d.dx / 2) * 180 / Math.PI - 90,
rotate = angle; rotate = angle;
return "rotate(" + rotate + ")translate(" + (y(d.y) + padding +80) + ")rotate(" + (angle > 90 ? -180 : 0) + ")"; return "rotate(" + rotate + ")translate(" + (y(d.y) + padding +80) + ")rotate(" + (angle > 90 ? -180 : 0) + ")";
@ -614,7 +616,7 @@ $(document).ready(function() {
.attr("display", 'none') .attr("display", 'none')
.text(function(d) { .text(function(d) {
//return "Click"; //return "Click";
}); });*/
}); });
} }
@ -760,11 +762,9 @@ $(document).ready(function() {
} else { } else {
color = colors[d.family_id]; color = colors[d.family_id];
} }
d.color = color;
return color; return color;
} }
color = '#fefefe'; color = '#fefefe';
d.color = color;
return color; //missing colors return color; //missing colors
} }
@ -782,7 +782,6 @@ $(document).ready(function() {
//Nice rainbow colors //Nice rainbow colors
return_fill = get_color(d); return_fill = get_color(d);
/*var p = color_patterns[18]; /*var p = color_patterns[18];
color = p(depth -1 + d.counter); color = p(depth -1 + d.counter);
return_fill = d.color = color;*/ return_fill = d.color = color;*/
@ -799,15 +798,16 @@ $(document).ready(function() {
} }
//darkblue //darkblue
//If the skill has a gradebook attached //If the skill has a gradebook attached
if (d.skill_has_gradebook) { if (d.skill_has_gradebook) {
return_fill = 'yellow'; return_fill = '#FEF664';
//return_stroke = 'grey'; //return_stroke = 'grey';
} }
switch (attribute) { switch (attribute) {
case 'fill': case 'fill':
//In order to the text could identify the background
d.color = return_fill;
return return_fill; return return_fill;
break; break;
case 'stroke': case 'stroke':
@ -978,6 +978,9 @@ $(document).ready(function() {
<h3>{{ 'MySkills'|get_lang }}</h3> <h3>{{ 'MySkills'|get_lang }}</h3>
<hr> <hr>
<div id="my_skills">
</div>
<h3>{{ 'GetNewSkills'|get_lang }}</h3> <h3>{{ 'GetNewSkills'|get_lang }}</h3>
<hr> <hr>

Loading…
Cancel
Save