Minor - format code

1.10.x
Julio Montoya 11 years ago
parent e54706f469
commit 8bc3b9a38e
  1. 3
      main/admin/skills_wheel.php
  2. 200
      main/template/default/skill/skill_wheel.js.tpl
  3. 309
      main/template/default/skill/skill_wheel.tpl

@ -40,11 +40,10 @@ if (isset($_GET['skill_id'])) {
$url = api_get_path(WEB_AJAX_PATH)."skill.ajax.php?a=get_skills_tree_json&load_user=$load_user";
$tpl->assign('wheel_url', $url);
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
$tpl->assign('url', $url);
$tpl->assign('isAdministration', true);
$content = $tpl->fetch('default/skill/skill_wheel.tpl');
$tpl->assign('content', $content);
$tpl->display_no_layout_template();
$tpl->display_no_layout_template();

@ -13,7 +13,7 @@ var main_parent_id = 0;
// Used to split in two word or not
var max_size_text_length = 20;
/* ColorBrewer settings */
var my_domain = [1,2,3,4,5,6,7,8,9];
var col = 9;
@ -22,16 +22,16 @@ var color_patterns = [];
/*
See colorbrewer documentation
color_patterns[1] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Blues[col]);
color_patterns[1] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Blues[col]);
color_patterns[2] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Purples[col]);
color_patterns[2] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Blues[6]);
color_patterns[3] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Greens[col]);
color_patterns[3] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Greens[col]);
color_patterns[4] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Reds[col]);
color_patterns[5] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.Oranges[col]);
color_patterns[6] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.YlOrBr[col]);
color_patterns[7] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.YlGn[col]);
color_patterns[7] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.YlGn[col]);
color_patterns[8] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.YlGnBu[col]);
color_patterns[9] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.GnBu[col]);
color_patterns[10] = d3.scale.ordinal().domain(my_domain).range(colorbrewer.BuGn[col]);
@ -58,7 +58,7 @@ var color_loops = 4;
// Generating array of colors thanks to the "$.xcolor.analogous" function we can create a rainbow style!
for (i= 0; i < color_loops; i++) {
//Getting the latest color hex of the 8 colors loaded
//Getting the latest color hex of the 8 colors loaded
last_color = colors[colors.length-1].getHex();
//Getting the complementary
glue_color = $.xcolor.complementary(last_color);
@ -116,32 +116,32 @@ function isParentOf(p, c) {
});
}
return false;
}
}
function get_color(d) {
depth = d.depth;
if (d.family_id) {
/*var p = color_patterns[d.family_id];
if (d.family_id) {
/*var p = color_patterns[d.family_id];
color = p(depth -1 + d.counter);
d.color = color;*/
if (depth > 1) {
d.color = color;*/
if (depth > 1) {
family1 = colors[d.family_id];
family2 = colors[d.family_id + 2];
position = d.depth*d.counter;
family2 = colors[d.family_id + 2];
position = d.depth*d.counter;
//part_color = $.xcolor.gradientlevel(family1, family2, position, 100);
part_color = $.xcolor.lighten(family1, position, 15);
part_color = $.xcolor.lighten(family1, position, 15);
color = part_color.getHex();
//console.log(d.depth + " - " + d.name + " + "+ color+ "+ " +d.counter);
} else {
color = colors[d.family_id];
}
color = colors[d.family_id];
}
return color;
}
color = '#fefefe';
return color; //missing colors
}
/*
/*
gray tones for all skills that have no particular property ("Basic skills wheel" view)
yellow tones for skills that are provided by courses in Chamilo ("Teachable skills" view)
bright blue tones for personal skills already acquired by the student currently looking at the weel ("My skills" view)
@ -152,7 +152,7 @@ bright red for missing skills, in the "Required skills" view for a student when
*/
/**
Manage the partition background colors
Manage the partition background colors
**/
function set_skill_style(d, attribute, searched_skill_id) {
//Default border color (stroke)
@ -160,14 +160,14 @@ function set_skill_style(d, attribute, searched_skill_id) {
//0. Nice rainbow colors (Comment 1.0 to see the rainbow!)
return_fill = get_color(d);
//1. Grey colors using colorbrewer
var p = color_patterns[18];
color = p(depth -1 + d.counter);
return_fill = color;
return_fill = color;
//2. Yellow - If the skill has a gradebook attached
if (d.skill_has_gradebook) {
if (d.skill_has_gradebook) {
return_fill = '#F89406';
//return_stroke = 'grey';
}
@ -176,7 +176,7 @@ function set_skill_style(d, attribute, searched_skill_id) {
if (d.isSearched) {
return_fill = '#B94A48';
}
//4. Blue - if user achieved that skill
//var skill = false;
$.ajax({
@ -187,7 +187,7 @@ function set_skill_style(d, attribute, searched_skill_id) {
return_fill = '#3A87AD';
}
}
});
});
switch (attribute) {
case 'fill':
@ -203,7 +203,7 @@ function set_skill_style(d, attribute, searched_skill_id) {
/* When you click a skill partition */
function click_partition(d, path, text, icon, arc, x, y, r, p, vis) {
//console.log(d.depth);
//console.log(d.depth);
if (debug) {
console.log('Clicking a partition skill id: '+d.id);
console.log(d);
@ -213,27 +213,27 @@ function click_partition(d, path, text, icon, arc, x, y, r, p, vis) {
console.log('main_parent_id: ' + main_parent_id);
}
if (d.depth >= main_depth) {
if (d.depth >= main_depth) {
//main_depth += main_depth;
if (main_parent_id) {
load_nodes(main_parent_id, main_depth);
if (main_parent_id) {
load_nodes(main_parent_id, main_depth);
} else {
load_nodes(d.id, main_depth);
load_nodes(d.id, main_depth);
}
}
if (d.id) {
if (d.id) {
console.log('Getting skill info');
skill_info = get_skill_info(d.parent_id);
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;
main_parent_id = skill_info.extra.parent_id;
main_parent_id = d.parent_id;
console.log('Setting main_parent_id: ' + main_parent_id);
}
//console.log(main_parent_id);
/* "No id" means that we reach the center of the wheel go to the root*/
/* "No id" means that we reach the center of the wheel go to the root*/
if (!d.id) {
load_nodes(main_parent_id, main_depth);
}
@ -285,7 +285,7 @@ function click_partition(d, path, text, icon, arc, x, y, r, p, vis) {
return x(d.x + d.dx / 2) > Math.PI ? "end" : "start";
};
})
.attrTween("transform", function(d) {
.attrTween("transform", function(d) {
return function() {
var angle = x(d.x + d.dx / 2) * 180 / Math.PI - 90,
rotate = angle;
@ -300,12 +300,12 @@ function click_partition(d, path, text, icon, arc, x, y, r, p, vis) {
});*/
}
/*
Open a popup in order to modify the skill
/*
Open a popup in order to modify the skill
*/
function open_popup(skill_id, parent_id) {
//Cleaning selects
$("#gradebook_id").find('option').remove();
// Cleaning selects
$("#gradebook_id").find('option').remove();
$("#parent_id").find('option').remove();
//Cleaning lists
$("#gradebook_holder").find('li').remove();
@ -335,15 +335,15 @@ function open_popup(skill_id, parent_id) {
$("#description").text(skill.description);
}
//Filling parent_id
$("#parent_id").append('<option class="selected" value="'+skill.extra.parent_id+'" selected="selected" >');
// Filling parent_id
$("#parent_id").append('<option class="selected" value="'+skill.extra.parent_id+'" selected="selected" >');
$("#skill_edit_holder").append('<li class="bit-box">'+parent_info.name+'</li>');
//Filling the gradebook_id
jQuery.each(skill.gradebooks, function(index, data) {
jQuery.each(skill.gradebooks, function(index, data) {
$("#gradebook_id").append('<option class="selected" value="'+data.id+'" selected="selected" >');
$("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
$("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
});
if ("{{ isAdministration }}") {
@ -377,7 +377,7 @@ function open_popup(skill_id, parent_id) {
});
$("#dialog-form").dialog("open");
}
}
if (parent) {
$("#id").attr('value','');
@ -385,31 +385,31 @@ function open_popup(skill_id, parent_id) {
$("#short_code").attr('value', '');
$("#description").attr('value', '');
//Filling parent_id
$("#parent_id").append('<option class="selected" value="'+parent.id+'" selected="selected" >');
//Filling parent_id
$("#parent_id").append('<option class="selected" value="'+parent.id+'" selected="selected" >');
$("#skill_edit_holder").append('<li class="bit-box">'+parent.name+'</li>');
//Filling the gradebook_id
jQuery.each(parent.gradebooks, function(index, data) {
jQuery.each(parent.gradebooks, function(index, data) {
$("#gradebook_id").append('<option class="selected" value="'+data.id+'" selected="selected" >');
$("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
});
$("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
});
$("#dialog-form").dialog({
buttons: {
"{{ "Save"|get_lang }}" : function() {
var params = $("#add_item").find(':input').serialize();
add_skill(params);
add_skill(params);
}
},
close: function() {
close: function() {
$("#name").attr('value', '');
$("#description").attr('value', '');
load_nodes(0, main_depth);
load_nodes(0, main_depth);
}
});
$("#dialog-form").dialog("open");
$("#dialog-form").dialog("open");
}
return false;
}
@ -417,24 +417,24 @@ function open_popup(skill_id, parent_id) {
/* Handles mouse clicks */
function handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis) {
switch (d3.event.which) {
case 1:
//alert('Left mouse button pressed');
case 1:
//alert('Left mouse button pressed');
click_partition(d, path, text, icon, arc, x, y, r, padding, vis);
break;
case 2:
//alert('Middle mouse button pressed');
break;
case 3:
open_popup(d.id);
break;
case 3:
open_popup(d.id);
//alert('Right mouse button pressed');
break;
default:
//alert('You have a strange mouse :D '); //
}
}
/*
/*
Loads the skills partitions thanks to a json call
*/
function load_nodes(load_skill_id, main_depth, extra_parent_id) {
@ -444,20 +444,20 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
console.log('main_parent_id before: ' + main_parent_id);
}
//"Root partition" on click switch
if (main_parent_id && load_skill_id) {
skill_info = get_skill_info(load_skill_id);
//"Root partition" on click switch
if (main_parent_id && load_skill_id) {
skill_info = get_skill_info(load_skill_id);
if (skill_info && skill_info.extra) {
main_parent_id = skill_info.extra.parent_id;
} else {
main_parent_id = 0;
}
console.log('main_parent_id after: ' + main_parent_id);
console.log('main_parent_id after: ' + main_parent_id);
}
if (load_skill_id && load_skill_id == 1) {
main_parent_id = 0;
}
}
/** Define constants and size of the wheel */
@ -469,7 +469,7 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
x = d3.scale.linear().range([0, 2 * Math.PI]),
y = d3.scale.pow().exponent(1.1).domain([0, 1]).range([0, r]),
/** Padding in pixels before the string starts */
padding = 3,
padding = 3,
/** Levels to show */
levels_to_show = 3;
reduce_top = 1;
@ -534,22 +534,22 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
}
//The JS load
if (load_skill_id != 0) {
load_skill_condition = 'skill_id=' + load_skill_id;
if (load_skill_id != 0) {
load_skill_condition = 'skill_id=' + load_skill_id;
}
d3.json("{{ wheel_url }}&main_depth="+main_depth+"&"+load_skill_condition, function(json) {
/** Define the list of nodes based on the JSON */
var nodes = partition.nodes({
children: json
children: json
});
/* Setting all skills */
var path = vis.selectAll("path").data(nodes);
/* Setting all texts */
var text = vis.selectAll("text").data(nodes);
var text = vis.selectAll("text").data(nodes);
/* Setting icons */
var icon = vis.selectAll("icon").data(nodes);
@ -570,20 +570,20 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
return set_skill_style(d, 'stroke');
})
.on("mouseover", function(d, i) {
//$("#icon-" + i).show();
//$("#icon-" + i).show();
})
.on("mouseout", function(d, i) {
//$("#icon-" + i).hide();
})
.on("contextmenu", function(d, i) {
//Handles mouse clicks
handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis);
handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis);
//Blocks "right click menu"
d3.event.preventDefault();
d3.event.preventDefault();
return false;
})
.on("mousedown", function(d, i) {
})
.on("mousedown", function(d, i) {
})
.on("click", function(d) {
//Simple click
handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis);
@ -597,14 +597,14 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
click_partition(d, path, text, icon, arc, x, y, r, padding, vis);
});*/
/* End setting skills */
/* End setting skills */
/* Text settings */
/* Text settings */
var textEnter = text.enter().append("text")
.style("fill-opacity", 1)
.style("fill", function(d) {
return brightness(d3.rgb(d.color)) < 125 ? "#eee" : "#000";
})
.style("fill", function(d) {
return brightness(d3.rgb(d.color)) < 125 ? "#eee" : "#000";
})
.attr("text-anchor", function(d) {
return x(d.x + d.dx / 2) > Math.PI ? "end" : "start";
})
@ -620,47 +620,47 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
rotate = angle + (multiline ? -.5 : 0);
return "rotate(" + rotate + ")translate(" + (y(d.y) + padding) + ")rotate(" + (angle > 90 ? -180 : 0) + ")";
})
.on("mouseover", function(d, i) {
//$("#icon-" + i).show();
.on("mouseover", function(d, i) {
//$("#icon-" + i).show();
})
.on("mouseout", function(d, i) {
//$("#icon-" + i).hide();
//$("#icon-" + i).hide();
})
.on("contextmenu", function(d, i) {
handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis);
.on("contextmenu", function(d, i) {
handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis);
d3.event.preventDefault();
})
.on("mousedown", function(d, i) {
})
})
.on("click", function(d) {
handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis);
handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis);
});
/** Managing text - maximum two words */
/** Managing text - maximum two words */
var insert_two_words = false;
textEnter.append("tspan")
.attr("x", 0)
.text(function(d) {
if (d.depth && d.name.length > max_size_text_length) {
if (d.depth) {
if (d.depth) {
first_part = d.name.split(" ")[0];
second_part = d.name.split(" ")[1];
second_part = d.name.split(" ")[1];
if (first_part.length >= max_size_text_length) {
insert_two_words = false;
return first_part.substring(0, max_size_text_length -3) + ' ... ';
} else {
return first_part;
}
}
} else {
return "";
}
} else {
insert_two_words = false;
return d.depth ? d.name : "";
}
}
});
if (insert_two_words) {
textEnter.append("tspan")
.attr("x", 0)
@ -677,13 +677,13 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
/*
var icon_click = icon.enter().append("text")
.style("fill-opacity", 1)
.style("fill", function(d) {
.style("fill", function(d) {
//return "#000";
})
})
.attr("text-anchor", function(d) {
return x(d.x + d.dx / 2) > Math.PI ? "end" : "start";
})
.attr("dy", ".2em")
.attr("dy", ".2em")
.attr("transform", function(d) {
///Get the text details and define the rotation and general position
angle = x(d.x + d.dx / 2) * 180 / Math.PI - 90,
@ -695,11 +695,11 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
});
icon_click.append("tspan")
.attr("id", function(d, i) {
.attr("id", function(d, i) {
return "icon-" + i;
})
.attr("x", 0)
.attr("display", 'none')
.attr("display", 'none')
.text(function(d) {
//return "Click";
});*/
@ -717,7 +717,7 @@ function get_skill_info(my_id) {
var skill = false;
$.ajax({
url: url+'&a=get_skill_info&id='+my_id,
async: false,
async: false,
success: function(json) {
skill = jQuery.parseJSON(json);
return skill;
@ -730,12 +730,12 @@ function get_gradebook_info(id) {
var item = false;
$.ajax({
url: url+'&a=get_gradebook_info&id='+id,
async: false,
async: false,
success: function(json) {
item = jQuery.parseJSON(json);
return item;
}
});
});
return item;
}

@ -8,54 +8,53 @@ function add_skill(params) {
url: url+'&a=add&'+params,
success:function(my_id) {
//Close dialog
$("#dialog-form").dialog("close");
}
$("#dialog-form").dialog("close");
}
});
}
/* Skill search input in the left menu */
function check_skills_sidebar() {
//Selecting only selected skills
$("#skill_id option:selected").each(function() {
var skill_id = $(this).val();
var skill_id = $(this).val();
if (skill_id != "" ) {
$.ajax({
url: "{{ url }}&a=skill_exists",
url: "{{ url }}&a=skill_exists",
data: "skill_id="+skill_id,
// async: false,
success: function(return_value) {
// async: false,
success: function(return_value) {
if (return_value == 0 ) {
alert("{{ 'SkillDoesNotExist'|get_lang }}");
//Deleting select option tag
//$("#skill_id option[value="+skill_id+"]").remove();
//$("#skill_id option[value="+skill_id+"]").remove();
$("#skill_id").empty();
//Deleting holder
$("#skill_search .holder li").each(function () {
if ($(this).attr("rel") == skill_id) {
$(this).remove();
}
});
});
} else {
$("#skill_id option[value="+skill_id+"]").remove();
//Deleting holder
$("#skill_search .holder li").each(function () {
if ($(this).attr("rel") == skill_id) {
$(this).remove();
}
});
if ($('#skill_to_select_id_'+skill_id).length == 0) {
skill_info = get_skill_info(skill_id);
skill_info = get_skill_info(skill_id);
li = fill_skill_search_li(skill_id, skill_info.name);
$("#skill_holder").append(li);
}
$("#skill_holder").append(li);
}
}
},
});
}
});
}
});
}
@ -64,23 +63,23 @@ function fill_skill_search_li(skill_id, skill_name, checked) {
checked_condition = '';
if (checked == 1) {
checked_condition = 'checked=checked';
}
}
return '<li><input id="skill_to_select_id_'+skill_id+'" rel="'+skill_id+'" name="'+skill_name+'" class="skill_to_select" '+checked_condition+' type="checkbox" value=""> <a href="#" class="load_wheel" rel="'+skill_id+'">'+skill_name+'</a></li>';
}
function check_skills_edit_form() {
//selecting only selected parents
$("#parent_id option:selected").each(function() {
var skill_id = $(this).val();
var skill_id = $(this).val();
if (skill_id != "" ) {
$.ajax({
$.ajax({
async: false,
url: "{{ url }}&a=skill_exists",
url: "{{ url }}&a=skill_exists",
data: "skill_id="+skill_id,
success: function(return_value) {
if (return_value == 0 ) {
success: function(return_value) {
if (return_value == 0 ) {
alert("{{ 'SkillDoesNotExist'|get_lang }}");
//Deleting select option tag
$("#parent_id").find('option').remove();
//Deleting holder
@ -88,25 +87,25 @@ function check_skills_edit_form() {
if ($(this).attr("rel") == skill_id) {
$(this).remove();
}
});
});
} else {
$("#parent_id").empty();
$("#parent_id").empty();
$("#skill_edit_holder").find('li').remove();
//Deleting holder
$("#skill_row .holder li").each(function () {
if ($(this).attr("rel") == skill_id) {
$(this).remove();
}
});
skill = get_skill_info(skill_id);
skill = get_skill_info(skill_id);
$("#skill_edit_holder").append('<li class="bit-box" id="skill_option_'+skill_id+'"> '+skill.name+'</li>');
$("#parent_id").append('<option class="selected" selected="selected" value="'+skill_id+'"></option>');
}
},
});
}
});
}
});
}
@ -115,39 +114,39 @@ function check_gradebook() {
//selecting only selected users
$("#gradebook_id option:selected").each(function() {
var gradebook_id = $(this).val();
if (gradebook_id != "" ) {
$.ajax({
url: "{{ url }}&a=gradebook_exists",
$.ajax({
url: "{{ url }}&a=gradebook_exists",
data: "gradebook_id="+gradebook_id,
success: function(return_value) {
success: function(return_value) {
if (return_value == 0 ) {
alert("{{ 'GradebookDoesNotExist'|get_lang }}");
alert("{{ 'GradebookDoesNotExist'|get_lang }}");
//Deleting select option tag
$("#gradebook_id option[value="+gradebook_id+"]").remove();
$("#gradebook_id option[value="+gradebook_id+"]").remove();
//Deleting holder
$("#gradebook_row .holder li").each(function () {
if ($(this).attr("rel") == gradebook_id) {
$(this).remove();
}
});
} else {
//Deleting holder
});
} else {
//Deleting holder
$("#gradebook_row .holder li").each(function () {
if ($(this).attr("rel") == gradebook_id) {
$(this).remove();
}
});
if ($('#gradebook_item_'+gradebook_id).length == 0) {
gradebook = get_gradebook_info(gradebook_id);
gradebook = get_gradebook_info(gradebook_id);
if (gradebook) {
$("#gradebook_holder").append('<li id="gradebook_item_'+gradebook_id+'" class="bit-box"> '+gradebook.name+' <a rel="'+gradebook_id+'" class="closebutton" href="#"></a></li>');
}
}
}
}
},
});
}
});
}
});
}
@ -155,7 +154,7 @@ function check_gradebook() {
function delete_gradebook_from_skill(skill_id, gradebook_id) {
$.ajax({
url: url+'&a=delete_gradebook_from_skill&skill_id='+skill_id+'&gradebook_id='+gradebook_id,
async: false,
async: false,
success: function(result) {
//if (result == 1) {
$('#gradebook_item_'+gradebook_id).remove();
@ -172,29 +171,29 @@ function delete_gradebook_from_skill(skill_id, gradebook_id) {
function return_skill_list_from_profile_search() {
var skill_list = {};
if ($("#profile_search li").length != 0) {
if ($("#profile_search li").length != 0) {
$("#profile_search li").each(function(index) {
id = $(this).attr("id").split('_')[3];
if (id) {
id = $(this).attr("id").split('_')[3];
if (id) {
skill_list[index] = id;
}
});
});
}
return skill_list;
}
function submit_profile_search_form() {
$("#skill_wheel").remove();
var skill_list = return_skill_list_from_profile_search();
if (skill_list.length != 0) {
skill_list = { 'skill_id' : skill_list };
skill_params = $.param(skill_list);
skill_params = $.param(skill_list);
$.ajax({
url: url+'&a=profile_matches&'+skill_params,
async: false,
async: false,
success: function (html) {
//users = jQuery.parseJSON(users);
$('#wheel_container').html(html);
@ -206,104 +205,100 @@ function submit_profile_search_form() {
}
function add_skill_in_profile_list(skill_id, skill_name) {
if ($('#profile_match_item_'+skill_id).length == 0 ) {
$('#profile_search').append('<li class="bit-box" id="profile_match_item_'+skill_id+'">'+skill_name+' <a rel="'+skill_id+'" class="closebutton" href="#"></a> </li>');
} else {
if ($('#profile_match_item_'+skill_id).length == 0 ) {
$('#profile_search').append('<li class="bit-box" id="profile_match_item_'+skill_id+'">'+skill_name+' <a rel="'+skill_id+'" class="closebutton" href="#"></a> </li>');
} else {
$('#profile_match_item_'+skill_id).remove();
}
toogle_save_profile_form();
}
function toogle_save_profile_form() {
//Hiding showing the save this search
//Hiding showing the save this search
if ($('#profile_search li').length == 0) {
$('#profile-options-container').hide();
$('#profile-options-container').hide();
} else {
$('#profile-options-container').show();
}
}
$(document).ready(function() {
/* Skill search */
/* Skill search */
//Tool tip (in exercises)
var tip_options = {
placement : 'right'
}
$('.tooltip_skill').tooltip(tip_options);
/* Skill item list onclick */
$("#skill_holder").on("click", "input.skill_to_select", function() {
skill_id = $(this).attr('rel');
skill_name = $(this).attr('name');
add_skill_in_profile_list(skill_id, skill_name);
});
/* URL link when searching skills */
$("#skill_holder").on("click", "a.load_wheel", function() {
skill_id = $(this).attr('rel');
skill_to_load_from_get = 0;
load_nodes(skill_id, main_depth);
});
/* URL link when searching skills */
$("#skill_search").on("click", "a.load_root", function() {
skill_id = $(this).attr('rel');
skill_to_load_from_get = 0;
load_nodes(skill_id, main_depth);
});
/*$("#skill_search").on("click", "a#clear_selection", function() {
});*/
/* Profile matcher */
/* Submit button */
$("#search_profile_form").submit(function() {
submit_profile_search_form();
return false;
});
$("#save_profile_form_button").submit(function() {
$("#save_profile_form_button").submit(function() {
open_save_profile_popup();
return false;
});
/* Close button in profile matcher items */
$("#profile_search").on("click", "a.closebutton", function() {
skill_id = $(this).attr('rel');
skill_id = $(this).attr('rel');
$('input[id=skill_to_select_id_'+skill_id+']').attr('checked', false);
$('#profile_match_item_'+skill_id).remove();
submit_profile_search_form();
toogle_save_profile_form();
});
//Fill saved profiles list
// Fill saved profiles list
update_my_saved_profiles();
/* Click in profile */
$("#saved_profiles").on("click", "li.load_profile", function() {
profile_id = $(this).attr('rel');
$('#profile_id').attr('value',profile_id);
$('#profile_id').attr('value',profile_id);
$.ajax({
url: '{{ url }}&a=get_skills_by_profile&profile_id='+profile_id,
success:function(json) {
skill_list = jQuery.parseJSON(json);
skill_list = jQuery.parseJSON(json);
$('#profile_search').empty();
$('#skill_holder').empty();
jQuery.each(skill_list, function(index, skill_id) {
skill_info = get_skill_info(skill_id);
$('#skill_holder').empty();
jQuery.each(skill_list, function(index, skill_id) {
skill_info = get_skill_info(skill_id);
li = fill_skill_search_li(skill_id, skill_info.name, 1);
$("#skill_holder").append(li);
add_skill_in_profile_list(skill_id, skill_info.name);
});
submit_profile_search_form();
}
});
});
submit_profile_search_form();
}
});
});
$("#saved_profiles").on('click', 'li.load_profile button.close', function () {
var $parent = $(this).parent();
var profileId = $parent.attr('rel');
@ -318,13 +313,13 @@ $(document).ready(function() {
});
/* Wheel skill popup form */
/* Close button in gradebook select */
$("#gradebook_holder").on("click", "a.closebutton", function() {
gradebook_id = $(this).attr('rel');
skill_id = $('#id').attr('value');
delete_gradebook_from_skill(skill_id, gradebook_id);
});
skill_id = $('#id').attr('value');
delete_gradebook_from_skill(skill_id, gradebook_id);
});
$("#skill_id").fcbkcomplete({
json_url: "{{ url }}&a=find_skills",
@ -337,8 +332,8 @@ $(document).ready(function() {
onselect:"check_skills_sidebar",
filter_selected: true,
newel: true
});
});
$("#parent_id").fcbkcomplete({
json_url: "{{ url }}&a=find_skills",
cache: false,
@ -350,8 +345,8 @@ $(document).ready(function() {
onselect:"check_skills_edit_form",
filter_selected: true,
newel: true
});
});
$("#gradebook_id").fcbkcomplete({
json_url: "{{ url }}&a=find_gradebooks",
cache: false,
@ -368,21 +363,21 @@ $(document).ready(function() {
//Skill popup (edit, create child... )
$("#dialog-form").dialog({
autoOpen: false,
modal : true,
width : 600,
modal : true,
width : 600,
height : 630
});
//Save search profile dialog
$("#dialog-form-profile").dialog({
autoOpen: false,
modal : true,
width : 500,
modal : true,
width : 500,
height : 400
});
load_nodes(0, main_depth);
function open_save_profile_popup() {
var profileId = $("#profile_id").val();
$.ajax({
@ -395,16 +390,16 @@ $(document).ready(function() {
}
}
});
$("#dialog-form-profile").dialog({
buttons: {
"{{ "Save"|get_lang }}" : function() {
var name = $("#name_profile").val();
var description = $("#description_profile").val();
var skill_list = return_skill_list_from_profile_search();
var skill_list = return_skill_list_from_profile_search();
skill_list = { 'skill_id' : skill_list };
skill_params = $.param(skill_list);
$.ajax({
url: '{{ url }}&a=save_profile&name='+name+'&description='+description+'&'+skill_params+'&profile='+profileId,
success:function(data) {
@ -414,33 +409,34 @@ $(document).ready(function() {
} else {
alert("{{ "Error"|get_lang }}");
}
$("#dialog-form-profile").dialog("close");
$("#dialog-form-profile").dialog("close");
$("#name_profile").attr('value', '');
$("#description_profile").attr('value', '');
$("#profile_id").attr('value', '0');
}
$("#profile_id").attr('value', '0');
}
});
}
},
close: function() {
close: function() {
$("#name_profile").attr('value', '');
$("#description_profile").attr('value', '');
$("#profile_id").attr('value', '0');
$("#profile_id").attr('value', '0');
}
});
$("#dialog-form-profile").dialog("open");
}
function update_my_saved_profiles() {
$.ajax({
url: '{{ url }}&a=get_saved_profiles',
success:function(data) {
$("#saved_profiles").html(data);
}
}
});
}
/* change background color */
/* change background color */
$(document).ready(function () {
$("#celestial").click(function () {
$("#page-back").css("background","#A9E2F3");
@ -458,10 +454,11 @@ $(document).ready(function() {
$("#page-back").css("background","#F7F8E0");
});
});
/* Generated random colour */
/*
function colour(d) {
if (d.children) {
// There is a maximum of two children!
var colours = d.children.map(colour),
@ -469,7 +466,7 @@ $(document).ready(function() {
b = d3.hsl(colours[1]);
// L*a*b* might be better here...
return d3.hsl((a.h + b.h) / 2, a.s * 1.2, a.levels_to_show / 1.2);
}
}
return d.colour || "#fff";
}*/
});
@ -483,7 +480,6 @@ $(document).ready(function() {
<a class="btn btn-large btn-block btn-success" href="{{ _p.web }}user_portal.php">{{ "ReturnToCourseList"|get_lang }}</a>
</div>
<!-- ACCORDION -->
<div class="panel-group" id="accordion2">
@ -585,72 +581,73 @@ $(document).ready(function() {
<form id="add_item" class="form-horizontal" name="form">
<fieldset>
<input type="hidden" name="id" id="id"/>
<div class="control-group">
<label class="control-label" for="name">{{ 'Name' | get_lang }}</label>
<div class="controls">
<input type="text" name="name" id="name" class="col-md-4" />
<div class="form-group">
<label class="col-sm-2 control-label" for="name">{{ 'Name' | get_lang }}</label>
<div class="col-sm-8">
<input type="text" name="name" id="name" />
</div>
</div>
<div class="control-group">
<label class="control-label">{{ 'ShortCode' | get_lang }}</label>
<div class="controls">
<input type="text" name="short_code" id="short_code" class="span2" />
<div class="form-group">
<label class="col-sm-2 control-label">{{ 'ShortCode' | get_lang }}</label>
<div class="col-sm-8">
<input type="text" name="short_code" id="short_code" />
</div>
</div>
<div id="skill_row" class="control-group">
<label class="control-label" for="name">{{'Parent'|get_lang}}</label>
<div class="controls">
<div id="skill_row" class="form-group">
<label class="col-sm-2 control-label" for="name">{{'Parent'|get_lang}}</label>
<div class="col-sm-8">
<select id="parent_id" name="parent_id" />
</select>
<ul id="skill_edit_holder" class="holder holder_simple">
</ul>
</div>
</div>
<div id="gradebook_row" class="control-group">
<label class="control-label" for="name">{{'Gradebook'|get_lang}}</label>
<div class="controls">
<div id="gradebook_row" class="form-group">
<label class="col-sm-2 control-label" for="name">{{'Gradebook'|get_lang}}</label>
<div class="col-sm-8">
<select id="gradebook_id" name="gradebook_id" multiple="multiple"/>
</select>
</select>
<ul id="gradebook_holder" class="holder holder_simple">
</ul>
<span class="help-block">
{{ 'WithCertificate'|get_lang }}
</span>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">{{ 'Description'|get_lang }}</label>
<div class="controls">
<textarea name="description" id="description" class="col-md-4" rows="7"></textarea>
<div class="form-group">
<label class="col-sm-2 control-label" for="name">{{ 'Description'|get_lang }}</label>
<div class="col-sm-8">
<textarea name="description" id="description" rows="7"></textarea>
</div>
</div>
</div>
</fieldset>
</form>
</form>
</div>
<div id="dialog-form-profile" style="display:none;">
<form id="save_profile_form" class="form-horizontal" name="form">
<input type="hidden" id="profile_id" name="profile_id"/>
<fieldset>
<div class="control-group">
<label class="control-label" for="name">{{"Name"|get_lang}}</label>
<div class="controls">
<div class="form-group">
<label class="col-sm-2 control-label" for="name">{{"Name"|get_lang}}</label>
<div class="col-sm-8">
<input type="text" name="name" id="name_profile" size="40" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="name">{{"Description"|get_lang}}</label>
<div class="controls">
<textarea name="description" id="description_profile" class="span2" rows="7"></textarea>
<div class="form-group">
<label class="col-sm-2 control-label" for="name">{{"Description"|get_lang}}</label>
<div class="col-sm-8">
<textarea name="description" id="description_profile" rows="7"></textarea>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save