diff --git a/main/admin/skills.php b/main/admin/skills.php
index 4121d7b38b..f8ce3a8c63 100644
--- a/main/admin/skills.php
+++ b/main/admin/skills.php
@@ -19,6 +19,7 @@ $this_section = SECTION_PLATFORM_ADMIN;
//Adds the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jquery_ui_js(true);
$htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');
+$htmlHeadXtra[] = api_get_js('skills.js');
//Display::display_header();
//Display::display_reduced_header();
diff --git a/main/inc/lib/javascript/skills.js b/main/inc/lib/javascript/skills.js
new file mode 100644
index 0000000000..ab7d656554
--- /dev/null
+++ b/main/inc/lib/javascript/skills.js
@@ -0,0 +1,173 @@
+ var exampleDropOptions = {
+ tolerance:'touch',
+ hoverClass:'dropHover',
+ activeClass:'dragActive'
+ };
+
+ var connectorPaintStyle = {
+ lineWidth:5,
+ strokeStyle:"#deea18",
+ joinstyle:"round"
+ };
+ // .. and this is the hover style.
+ var connectorHoverStyle = {
+ lineWidth:7,
+ strokeStyle:"#2e2aF8"
+ };
+
+
+ //Settings when editing stuff
+ var edit_arrow_color = '#ccc';
+
+ var editEndpoint = {
+ //connectorStyle:connectorPaintStyle,
+ connector:[ "Flowchart", { stub:28 } ],
+ hoverPaintStyle:connectorHoverStyle,
+ connectorHoverStyle:connectorHoverStyle,
+ anchors: ['BottomCenter','TopCenter'],
+ endpoint:"Rectangle",
+ paintStyle:{ width:10, height:10, fillStyle:edit_arrow_color },
+ isSource:true,
+ scope:'blue rectangle',
+ maxConnections:10,
+ connectorStyle : {
+ gradient:{
+ stops:[[0, edit_arrow_color], [0.5, edit_arrow_color], [1, edit_arrow_color]]
+ }, //gradient stuff
+ lineWidth:2,
+ strokeStyle: edit_arrow_color
+ },
+ isTarget:true,
+ dropOptions : exampleDropOptions
+ };
+
+
+
+
+
+ /* Clean window block classes*/
+ function cleanclass(obj) {
+ obj.removeClass('first_window');
+ obj.removeClass('second_window');
+ obj.removeClass('third_window');
+ }
+
+ function open_parent(parent_id, id) {
+ console.log("open_parent call : id " + id + " parent_id:" + parent_id);
+ var numeric_parent_id = parent_id.split('_')[1];
+ var numeric_id = id.split('_')[1];
+ load_parent(numeric_parent_id, numeric_id);
+ }
+
+ //open block function
+ function open_block(id) {
+ console.log("open_block id : " + id);
+ var numeric_id = id.split('_')[1];
+ for (var i = 0; i < skills.length; i++) {
+ //Remove everything except parents
+ if (jQuery.inArray(skills[i].element, parents) == -1) {
+ //console.log('deleting this'+ skills[i].element);
+ jsPlumb.deleteEndpoint(skills[i].endp);
+ $("#"+skills[i].element).remove();
+ //skills.splice(i,1);
+ //console.log('Removing '+skills[i].element);
+ }
+ }
+ /*if ($('#'+id).length == 0) {
+ $('body').append('
'+id+'
');
+ }*/
+
+ //Modifying current block position
+ pos = $('#'+id).position();
+ left_value = center_x;
+
+ if (parents.length == 2) {
+ top_value = space_between_blocks_y + offset_y;
+ } else {
+ top_value = pos.left;
+ }
+ jsPlumb.animate(id, { left: left_value, top:top_value }, { duration:duration_value });
+
+ //Modifying root block position
+ pos_parent = $('#'+parents[0]).position();
+ jsPlumb.animate(parents[0], { left: center_x, top:offset_y }, { duration:duration_value });
+
+ top_value = 2*space_between_blocks_y +offset_y ;
+ load_children(numeric_id, top_value);
+ }
+
+ function load_parent(parent_id, id) {
+ console.log("load_parent call : id " + id + " parent_id:" + parent_id);
+ var ix= 0;
+ $.ajax({
+ url: url+'&a=load_direct_parents&id='+id,
+ async: false,
+ success: function(json) {
+ var json = jQuery.parseJSON(json);
+
+ $.each(json,function(i,item) {
+ left_value = center_x + space_between_blocks_x * ix;
+ top_value = offset_y;
+
+ $('body').append(''+item.name+'
');
+ var es = prepare("block_" + item.id, editEndpoint);
+ var es2 = prepare("block_" + id, editEndpoint);
+
+ jsPlumb.connect({
+ source: es, target:es2
+ });
+ jsPlumb.animate("block_" + item.id, { left: left_value, top : top_value }, { duration : duration_value});
+
+ if (item.parent_id) {
+ console.log('setting hidden_parent '+item.parent_id);
+ hidden_parent = "block_" + item.parent_id;
+ } else {
+ console.log('setting NO--- hidden_parent ');
+ }
+ ix++;
+ });
+
+ }
+ });
+ }
+
+ function load_children(my_id, top_value) {
+ console.log("load_children call : my_id " + my_id + " top_value:" + top_value);
+ //Loading children
+ var ix = 0;
+ $.getJSON(url+'&a=load_children&id='+my_id, {},
+ function(json) {
+ $.each(json,function(i,item) {
+ left_value = ix*space_between_blocks_x + center_x/2 - block_size / 2;
+ //top_value = 300;
+ //Display::url($skill['name'], '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block'))
+ item.name = ''+item.name+'';
+
+ $('body').append(''+item.name+'
');
+
+ var es = prepare("block_" + item.id, editEndpoint);
+ var e2 = prepare("block_" + my_id, editEndpoint);
+
+ jsPlumb.connect({
+ source: es, target:e2
+ });
+ jsPlumb.animate("block_" + item.id, {
+ left: left_value, top : top_value
+ }, { duration:duration_value});
+ ix++;
+ });
+ }
+ );
+ }
+
+ function checkLength( o, n, min, max ) {
+ if ( o.val().length > max || o.val().length < min ) {
+ o.addClass( "ui-state-error" );
+ updateTips( "Length of " + n + " must be between " +
+ min + " and " + max + "." );
+ return false;
+ } else {
+ return true;
+ }
+ }
+
diff --git a/main/social/skills_tree.php b/main/social/skills_tree.php
index 1bbbf7da43..c79bdaa198 100644
--- a/main/social/skills_tree.php
+++ b/main/social/skills_tree.php
@@ -1 +1,46 @@
-ski
\ No newline at end of file
+get_all(true);
+$type = 'edit'; //edit
+
+$tree = $skill->get_skills_tree(null, true);
+$skill_visualizer = new SkillVisualizer($tree, $type);
+
+$html = $skill_visualizer->return_html();
+$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
+
+$tpl = new Template(null, false, false);
+
+$tpl->assign('url', $url);
+$tpl->assign('html', $html);
+$tpl->assign('skill_visualizer', $skill_visualizer);
+$tpl->assign('js', $skill_visualizer->return_js());
+
+//
+$content = $tpl->fetch('default/skill/skill_tree_student.tpl');
+$tpl->assign('content', $content);
+$tpl->display_no_layout_template();
+
\ No newline at end of file
diff --git a/main/template/default/skill/skill_tree.tpl b/main/template/default/skill/skill_tree.tpl
index 9817a810d9..4332f5c836 100644
--- a/main/template/default/skill/skill_tree.tpl
+++ b/main/template/default/skill/skill_tree.tpl
@@ -19,12 +19,7 @@ var block_size = {$skill_visualizer->block_size};
//Setting the parent by default
var parents = ['block_1'];
-/* Clean window block classes*/
-function cleanclass(obj) {
- obj.removeClass('first_window');
- obj.removeClass('second_window');
- obj.removeClass('third_window');
-}
+
jsPlumb.bind("ready", function() {
@@ -114,114 +109,6 @@ jsPlumb.bind("ready", function() {
console.log('hidden_parent : ' + hidden_parent);
});
- function open_parent(parent_id, id) {
- console.log("open_parent call : id " + id + " parent_id:" + parent_id);
- var numeric_parent_id = parent_id.split('_')[1];
- var numeric_id = id.split('_')[1];
- load_parent(numeric_parent_id, numeric_id);
- }
-
- //open block function
- function open_block(id) {
- console.log("open_block id : " + id);
- var numeric_id = id.split('_')[1];
- for (var i = 0; i < skills.length; i++) {
- //Remove everything except parents
- if (jQuery.inArray(skills[i].element, parents) == -1) {
- //console.log('deleting this'+ skills[i].element);
- jsPlumb.deleteEndpoint(skills[i].endp);
- $("#"+skills[i].element).remove();
- //skills.splice(i,1);
- //console.log('Removing '+skills[i].element);
- }
- }
- /*if ($('#'+id).length == 0) {
- $('body').append(''+id+'
');
- }*/
-
- //Modifying current block position
- pos = $('#'+id).position();
- left_value = center_x;
-
- if (parents.length == 2) {
- top_value = space_between_blocks_y + offset_y;
- } else {
- top_value = pos.left;
- }
- jsPlumb.animate(id, { left: left_value, top:top_value }, { duration:duration_value });
-
- //Modifying root block position
- pos_parent = $('#'+parents[0]).position();
- jsPlumb.animate(parents[0], { left: center_x, top:offset_y }, { duration:duration_value });
-
- top_value = 2*space_between_blocks_y +offset_y ;
- load_children(numeric_id, top_value);
- }
-
- function load_parent(parent_id, id) {
- console.log("load_parent call : id " + id + " parent_id:" + parent_id);
- var ix= 0;
- $.ajax({
- url: url+'&a=load_direct_parents&id='+id,
- async: false,
- success: function(json) {
- var json = jQuery.parseJSON(json);
-
- $.each(json,function(i,item) {
- left_value = center_x + space_between_blocks_x * ix;
- top_value = offset_y;
-
- $('body').append(''+item.name+'
');
- var es = prepare("block_" + item.id, editEndpoint);
- var es2 = prepare("block_" + id, editEndpoint);
-
- jsPlumb.connect({
- source: es, target:es2
- });
- jsPlumb.animate("block_" + item.id, { left: left_value, top : top_value }, { duration : duration_value});
-
- if (item.parent_id) {
- console.log('setting hidden_parent '+item.parent_id);
- hidden_parent = "block_" + item.parent_id;
- } else {
- console.log('setting NO--- hidden_parent ');
- }
- ix++;
- });
-
- }
- });
- }
-
- function load_children(my_id, top_value) {
- console.log("load_children call : my_id " + my_id + " top_value:" + top_value);
- //Loading children
- var ix = 0;
- $.getJSON(url+'&a=load_children&id='+my_id, {},
- function(json) {
- $.each(json,function(i,item) {
- left_value = ix*space_between_blocks_x + center_x/2 - block_size / 2;
- //top_value = 300;
- //Display::url($skill['name'], '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block'))
- item.name = ''+item.name+'';
-
- $('body').append(''+item.name+'
');
-
- var es = prepare("block_" + item.id, editEndpoint);
- var e2 = prepare("block_" + my_id, editEndpoint);
-
- jsPlumb.connect({
- source: es, target:e2
- });
- jsPlumb.animate("block_" + item.id, {
- left: left_value, top : top_value
- }, { duration:duration_value});
- ix++;
- });
- }
- );
- }
-
$(".edit_block").live('click',function() {
var my_id = $(this).attr('id');
my_id = my_id.split('_')[2];
@@ -244,12 +131,10 @@ jsPlumb.bind("ready", function() {
$("#gradebook_id option[value='"+data.id+"']").attr('selected', 'selected');
});
},
- });
-
+ });
$("#gradebook_id").trigger("liszt:updated");
- $("#parent_id").trigger("liszt:updated");
-
+ $("#parent_id").trigger("liszt:updated");
$("#dialog-form").dialog("open");
return false;
@@ -328,49 +213,7 @@ jsPlumb.bind("ready", function() {
resetRenderMode(jsPlumb.CANVAS);
});
- var exampleDropOptions = {
- tolerance:'touch',
- hoverClass:'dropHover',
- activeClass:'dragActive'
- };
-
- var connectorPaintStyle = {
- lineWidth:5,
- strokeStyle:"#deea18",
- joinstyle:"round"
- };
- // .. and this is the hover style.
- var connectorHoverStyle = {
- lineWidth:7,
- strokeStyle:"#2e2aF8"
- };
-
-
- //Settings when editing stuff
- var edit_arrow_color = '#ccc';
-
- var editEndpoint = {
- //connectorStyle:connectorPaintStyle,
- connector:[ "Flowchart", { stub:28 } ],
- hoverPaintStyle:connectorHoverStyle,
- connectorHoverStyle:connectorHoverStyle,
- anchors: ['BottomCenter','TopCenter'],
- endpoint:"Rectangle",
- paintStyle:{ width:10, height:10, fillStyle:edit_arrow_color },
- isSource:true,
- scope:'blue rectangle',
- maxConnections:10,
- connectorStyle : {
- gradient:{
- stops:[[0, edit_arrow_color], [0.5, edit_arrow_color], [1, edit_arrow_color]]
- }, //gradient stuff
- lineWidth:2,
- strokeStyle: edit_arrow_color
- },
- isTarget:true,
- dropOptions : exampleDropOptions
- };
-
+
;(function() {
prepare = function(elId, endpoint) {
@@ -575,16 +418,7 @@ $(document).ready( function() {
};
})();
-function checkLength( o, n, min, max ) {
- if ( o.val().length > max || o.val().length < min ) {
- o.addClass( "ui-state-error" );
- updateTips( "Length of " + n + " must be between " +
- min + " and " + max + "." );
- return false;
- } else {
- return true;
- }
-}
+
Add item
diff --git a/main/template/default/skill/skill_tree_student.tpl b/main/template/default/skill/skill_tree_student.tpl
new file mode 100644
index 0000000000..9e79d45d3c
--- /dev/null
+++ b/main/template/default/skill/skill_tree_student.tpl
@@ -0,0 +1,416 @@
+
+
+{$html}
+
+
\ No newline at end of file