Improve wheel speed.

1.10.x
Julio Montoya 11 years ago
parent e157494e46
commit aae5bc319a
  1. 5
      main/inc/ajax/skill.ajax.php
  2. 34
      main/template/default/skill/skill_wheel.js.tpl

@ -155,6 +155,11 @@ switch ($action) {
echo 0;
}
break;
case 'get_all_user_skills':
$userId = api_get_user_id();
$skills = $skill->get_user_skills($user_id, true);
echo json_encode($skills);
break;
case 'get_user_skills':
$skills = $skill->get_user_skills($user_id, true);
Display::display_no_header();

@ -78,7 +78,6 @@ function is_multiline(word) {
return false;
}
/* Interpolate the scales! */
function arcTween(d, arc, x, y, r) {
var my = maxY(d),
@ -150,6 +149,7 @@ bright green for skills looked for by a HR director ("Profile search" view)
dark green for skills most searched for, summed up from the different saved searches from HR directors ("Most wanted skills")
bright red for missing skills, in the "Required skills" view for a student when looking at the "Most wanted skills" (or later, when we will have developed that, for the "Matching position" view)
*/
var userSkills;
/**
Manage the partition background colors
@ -177,9 +177,20 @@ function set_skill_style(d, attribute, searched_skill_id) {
return_fill = '#B94A48';
}
if (!userSkills) {
$.ajax({
url: url + '&a=get_all_user_skills',
async: false,
success: function (skills) {
userSkills = jQuery.parseJSON(skills);
}
});
}
// Old way (it makes a lot of ajax calls)
//4. Blue - if user achieved that skill
//var skill = false;
$.ajax({
/*$.ajax({
url: url+'&a=get_user_skill&profile_id='+d.id,
async: false,
success: function(skill) {
@ -187,7 +198,13 @@ function set_skill_style(d, attribute, searched_skill_id) {
return_fill = '#3A87AD';
}
}
});
});*/
// New way (Only 1 ajax call)
// 4. Blue - if user achieved that skill
if (userSkills[d.id]) {
return_fill = '#3A87AD';
}
switch (attribute) {
case 'fill':
@ -225,7 +242,6 @@ function click_partition(d, path, text, icon, arc, x, y, r, p, vis) {
if (d.id) {
console.log('Getting skill info');
skill_info = get_skill_info(d.parent_id);
console.log(skill_info);
main_parent_id = skill_info.extra.parent_id;
main_parent_id = d.parent_id;
console.log('Setting main_parent_id: ' + main_parent_id);
@ -433,7 +449,6 @@ function handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis)
}
}
/*
Loads the skills partitions thanks to a json call
*/
@ -459,7 +474,6 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
main_parent_id = 0;
}
/** Define constants and size of the wheel */
/** Total width of the wheel (also counts for the height) */
var w = 900,
@ -670,10 +684,7 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
});
}
/* Icon settings */
/*
var icon_click = icon.enter().append("text")
.style("fill-opacity", 1)
@ -710,9 +721,7 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
}
}
/* Skill AJAX calls */
function get_skill_info(my_id) {
var skill = false;
$.ajax({
@ -739,7 +748,4 @@ function get_gradebook_info(id) {
return item;
}
$(document).ready(function() {
});
</script>

Loading…
Cancel
Save