';
+ $this->html .= '
';
$gradebook_string = '';
if (!empty($skill['gradebooks'])) {
foreach($skill['gradebooks'] as $gradebook) {
- $gradebook_string .= Display::span($gradebook['name'], array('class'=>'label_tag notice','style'=>'width:50px'));
+ $gradebook_string .= Display::span($gradebook['name'], array('class'=>'label_tag notice','style'=>'width:50px')).'
';
}
}
+ $skill['name'] = Display::url($skill['name'], '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block'));
+
$this->html .= $skill['name'].' '.$gradebook_string;
if ($this->type == 'edit' && $skill['parent_id'] != 0) {
- $this->html .= Display::url(get_lang('Edit'), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));
- $this->html .= Display::url(get_lang('Add'), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));
- $this->html .= Display::url(get_lang('Delete'), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));
+ //$this->html .= Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), 22), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block'));
+ //$this->html .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), 22), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block'));
+ //$this->html .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), 22), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block'));
+ //$this->html .= Display::url(Display::return_icon('up.png', get_lang('Close'), array(), 22), '#', array('id'=>'close_block_'.$block_id,'class'=>'close_block'));
+ //$this->html .= Display::url(Display::return_icon('down.png', get_lang('Open'), array(), 22), '#', array('id'=>'open_block_'.$block_id,'class'=>'open_block'));
}
$this->html .= '
';
}
@@ -43,8 +47,7 @@
* Adds a node using jplumb
*/
private function add_item($skill, $position) {
- $block_id = $skill['id'];
-
+ $block_id = $skill['id'];
$end_point = 'readEndpoint';
//var_dump($skill);
@@ -88,23 +91,63 @@
$brothers = array();
+ $constant = 100;
+
+ $canvas = 1000;
//$this->add_item($skill, array('x' => $x + $this->offsetX, 'y' => $y + $this->offsetY));
- foreach ($this->skills as $skill) {
- if (isset($brothers[$skill['parent_id']])) {
+ foreach ($this->skills as &$skill) {
+ if (!in_array($skill['parent_id'], array(0,1))) {
+ continue;
+ }
+ $childs = isset($skill['children']) ? count($skill['children']) : 0 ;
+
+
+ //$x = round($this->offsetX * sin(deg2rad($corner * $count)));
+ //$y = round($this->offsetY * cos(deg2rad($corner * $count)));
+
+ /*if (isset($brothers[$skill['parent_id']])) {
$brothers[$skill['parent_id']] +=2;
} else {
$brothers[$skill['parent_id']] = 1;
- }
- //$x = round($this->offsetX * sin(deg2rad($corner * $count)));
- //$y = round($this->offsetY * cos(deg2rad($corner * $count)));
+ }*/
+ $my_count = 0;
+ $brother_count = $brothers[$skill['id']];
- $x = $brothers[$skill['parent_id']]*100;
- $y = $skill['level']*120;
+ $parent_x = 0;
+ if ($skill['parent_id'] == 0) {
+
+ $x = $constant*$childs/2;
+ //$this->offsetX = $constant*$childs;
+ } else {
+
+ $max = isset($this->skills[$skill['parent_id']]['children']) ? count($this->skills[$skill['parent_id']]['children']) : 0;
+ foreach($this->skills[$skill['parent_id']]['children'] as $id => $sk) {
+ if ($skill['id'] == $sk['id']) {
+ break;
+ }
+ $my_count++;
+ }
+ $parent_x = isset($this->skills[$skill['parent_id']]['x']) ? $this->skills[$skill['parent_id']]['x'] : 0;
+ $x = $my_count*150 + $parent_x - (150*$max/2) ;
+ //$x = $my_count*150 + $parent_x - (150*$max/2) - 20*$childs;
+ //$x = $my_count*150 + $parent_x - 100*$childs;
+ }
+
+ $y = $skill['level']*150;
+
+ $skill['x'] = $x;
+ $skill['y'] = $y;
+
+
+ // var_dump($skill);
//$skill['description'] = "{$brothers[$skill['parent_id']]} $x - $y";
+ //$skill['name'] = $skill['name']." | $x = $my_count * 150 + $parent_x - (150* $max/2) - 10*$childs ";
$this->add_item($skill, array('x' => $this->offsetX + $x, 'y' => $this->offsetY +$y));
- }
+ }
+
echo $this->get_html();
+
}
/**