diff --git a/index.php b/index.php index 23e2d83039..e5edb2fdfa 100644 --- a/index.php +++ b/index.php @@ -186,4 +186,11 @@ $controller->tpl->assign('home_page_block', $controller->return_home_page()); $controller->tpl->assign('notice_block', $controller->return_notice()); $controller->tpl->assign('plugin_campushomepage', $controller->return_plugin_campushomepage()); +if (api_is_platform_admin() || api_is_drh()) { + $controller->tpl->assign('skills_block', $controller->return_skills_links()); +} + + + + $controller->tpl->display_two_col_template(); \ No newline at end of file diff --git a/main/admin/index.php b/main/admin/index.php index 94208a02e9..8ef745af14 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -115,6 +115,10 @@ if (api_is_platform_admin()) { $items[] = array('url'=>'course_category.php', 'label' => get_lang('AdminCategories')); $items[] = array('url'=>'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse')); $items[] = array('url'=>'course_user_import.php', 'label' => get_lang('ImportUsersToACourse')); + + $items[] = array('url'=>'skills.php', 'label' => get_lang('SkillsTree')); + $items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsGradebook')); + if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { $items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse')); diff --git a/main/admin/promotions.php b/main/admin/promotions.php index b50e23d9b9..02a4e34d77 100644 --- a/main/admin/promotions.php +++ b/main/admin/promotions.php @@ -10,7 +10,6 @@ $language_file = array('admin'); $cidReset = true; require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'promotion.lib.php'; require_once api_get_path(LIBRARY_PATH).'career.lib.php'; diff --git a/main/admin/skills.php b/main/admin/skills.php new file mode 100644 index 0000000000..f0146f51b8 --- /dev/null +++ b/main/admin/skills.php @@ -0,0 +1,472 @@ +get_all(true); +$type = 'edit'; //edit +$skill_visualizer = new SkillVisualizer($skills, $type); + +$skill_visualizer->display_html(); + +$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1'; +//$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?load_user_data=1'; +?> + + + +Add item + +
+assign('content', $content); +$tpl->display_one_col_template(); + + * + */ \ No newline at end of file diff --git a/main/admin/skills_gradebook.php b/main/admin/skills_gradebook.php new file mode 100644 index 0000000000..9a20a76580 --- /dev/null +++ b/main/admin/skills_gradebook.php @@ -0,0 +1,84 @@ + 'index.php','name' => get_lang('PlatformAdmin')); +$interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions')); + + +//jqgrid will use this URL to do the selects + +$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_gradebooks'; + +//The order is important you need to check the the $column variable in the model.ajax.php file +$columns = array(get_lang('Name'), get_lang('Skills'), get_lang('Actions')); + +//Column config +$column_model = array( + array('name'=>'name', 'index'=>'name', 'width'=>'200', 'align'=>'left'), + array('name'=>'skills', 'index'=>'skills', 'width'=>'300', 'align'=>'left','sortable'=>'false'), + array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false') + ); +//Autowidth +$extra_params['autowidth'] = 'true'; +//height auto +$extra_params['height'] = 'auto'; + +//With this function we can add actions to the jgrid (edit, delete, etc) +$action_links = 'function action_formatter(cellvalue, options, rowObject) { + return \''.Display::return_icon('addd.gif', get_lang('AddSkill'),'',22).''. + '\'; + }'; +?> + +display(); + break; + case 'add_skill': + $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; + $gradebook_info = $gradebook->get($id); + $url = api_get_self().'?action='.$action.'&id='.$id; + $form = $gradebook->show_skill_form($id, $url); + if ($form->validate()) { + $values = $form->exportValues(); + $res = $gradebook->update_skills_to_gradebook($values['id'], $values['skill']); + if ($res) { + Display::display_confirmation_message(get_lang('ItemAdded')); + } + } + echo Display::tag('h1',$gradebook_info['name']); + $form->display(); + break; +} +Display::display_footer(); diff --git a/main/css/base.css b/main/css/base.css index 6d9bcf80f5..e42b699d85 100644 --- a/main/css/base.css +++ b/main/css/base.css @@ -3240,7 +3240,7 @@ div.admin_section h4 { /* chosen javascript checkbox select width fix */ .chzn-select { - width: 200px; + min-width: 250px; } #lp_item_list { width:90%; @@ -3785,8 +3785,9 @@ form div.error input, form div.error textarea { } .label_tag { - /* padding: 1px 3px 2px; */ - padding:5px; + padding: 1px 3px 2px; + margin-right:3px; + /* padding:5px;*/ background-color: #bfbfbf; font-size: 9.75px; font-weight: bold; @@ -3878,4 +3879,55 @@ form div.error input, form div.error textarea { .lp_content_type_label { font-style: italic; color:#999; -} \ No newline at end of file +} + + +/* Plumb */ + +.window { + cursor:pointer; + box-shadow: 2px 2px 19px #aaa; + -o-box-shadow: 2px 2px 19px #aaa; + -webkit-box-shadow: 2px 2px 19px #aaa; + -moz-box-shadow: 2px 2px 19px #aaa; +} + +.window { + background-color: white; + border: 0.1em dotted #D4E06B; + color: black; + font-family: helvetica,sans; + font-size: 0.9em; + height: 4em; + opacity: 0.8; + padding-top: 0.9em; + position: absolute; + text-align: center; + width: 100px; + z-index: 40; +} + +.done_window { + background-color: #73982C; +} + +._jsPlumb_endpoint { + z-index: 50; +} + +.drag-locked { + border: 1px solid red; +} +._jsPlumb_endpoint { + z-index: 50; +} +._jsPlumb_connector { + z-index: 1; +} +.dropHover { + border: 1px dotted red; +} + +.dragActive { + border: 2px dotted orange; +} diff --git a/main/gradebook/gradebook_add_cat.php b/main/gradebook/gradebook_add_cat.php index c8a3855df7..ba778d79f6 100644 --- a/main/gradebook/gradebook_add_cat.php +++ b/main/gradebook/gradebook_add_cat.php @@ -20,6 +20,71 @@ require_once 'lib/gradebook_functions.inc.php'; require_once 'lib/fe/catform.class.php'; api_block_anonymous_users(); block_students(); + + + + +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; + +$htmlHeadXtra[] = ''; + $get_select_cat = intval($_GET['selectcat']); $catadd = new Category(); @@ -56,6 +121,8 @@ if ($form->validate()) { } //Always add the gradebook to the course $cat->set_course_code(api_get_course_id()); + + $cat->set_skills($values['skills']); $cat->set_description($values['description']); $cat->set_user_id($values['hid_user_id']); diff --git a/main/gradebook/gradebook_edit_cat.php b/main/gradebook/gradebook_edit_cat.php index 67d31ec888..8e11bbd07f 100644 --- a/main/gradebook/gradebook_edit_cat.php +++ b/main/gradebook/gradebook_edit_cat.php @@ -10,6 +10,7 @@ $language_file = 'gradebook'; require_once '../inc/global.inc.php'; + require_once 'lib/be.inc.php'; require_once 'lib/gradebook_functions.inc.php'; require_once 'lib/fe/catform.class.php'; @@ -18,10 +19,79 @@ api_block_anonymous_users(); block_students(); $edit_cat = isset($_REQUEST['editcat']) ? $_REQUEST['editcat'] : ''; + + +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; + +$htmlHeadXtra[] = ''; + + $catedit = Category :: load($edit_cat); -$form = new CatForm(CatForm :: TYPE_EDIT, $catedit[0], 'edit_cat_form'); +$form = new CatForm(CatForm :: TYPE_EDIT, $catedit[0], 'edit_cat_form'); + if ($form->validate()) { - $values = $form->exportValues(); + $values = $form->getSubmitValues(); + if (isset($values['skills'])) { + //$res = $gradebook->update_skills_to_gradebook($values['hid_id'], $values['skills']); + } + $cat = new Category(); $cat->set_id($values['hid_id']); $cat->set_name($values['name']); @@ -31,6 +101,9 @@ if ($form->validate()) { $cat->set_course_code($values['course_code']); } $cat->set_description($values['description']); + + $cat->set_skills($values['skills']); + $cat->set_user_id($values['hid_user_id']); $cat->set_parent_id($values['hid_parent_id']); $cat->set_weight($values['weight']); diff --git a/main/gradebook/index.php b/main/gradebook/index.php index 2afb0c2f9a..8811851a2a 100644 --- a/main/gradebook/index.php +++ b/main/gradebook/index.php @@ -63,7 +63,7 @@ $filter_warning_msg = true; ///direct access to one evaluation $cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init - +$first_time = null; if (empty($cats)) { $cats = Category :: load(0, null, $course_code, null, null, $session_id, false);//first time $first_time=1; @@ -618,7 +618,7 @@ if (isset ($_GET['studentoverview'])) { // one) category for this course or for this session. //hack for delete a gradebook from inside course - $clean_deletecat=Security::remove_XSS($_GET['deletecat']); + $clean_deletecat = isset($_GET['deletecat']) ? intval($_GET['deletecat']) : null; if (!empty($clean_deletecat)) { exit; } @@ -765,7 +765,7 @@ if (api_is_allowed_to_edit(null, true)) { } } } -if ($first_time==1 && api_is_allowed_to_edit(null,true)) { +if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) { echo ''; } else { $cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index 83c2c1fda9..5e07617a60 100644 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -8,10 +8,14 @@ * Class * @package chamilo.gradebook */ + +require_once api_get_path(LIBRARY_PATH).'skill.lib.php'; +require_once api_get_path(LIBRARY_PATH).'gradebook.lib.php'; + class Category implements GradebookItem { -// PROPERTIES + // PROPERTIES private $id; private $name; @@ -23,15 +27,12 @@ class Category implements GradebookItem private $visible; private $certificate_min_score; private $session_id; - - -// CONSTRUCTORS + private $skills = array(); function __construct() { } - -// GETTERS AND SETTERS + // GETTERS AND SETTERS public function get_id() { return $this->id; @@ -54,8 +55,9 @@ class Category implements GradebookItem return $this->certificate_min_score; } else { return null; - } + } } + public function get_course_code() { return $this->course_code; } @@ -114,13 +116,34 @@ class Category implements GradebookItem $this->visible = $visible; } - public function get_type() - { + public function get_type() { return 'category'; } + + public function get_skills($from_db = true) { + if ($from_db) { + $cat_id = $this->get_id(); + + $gradebook = new Gradebook(); + $skills = $gradebook->get_skills_by_gradebook($cat_id); + } else { + $skills = $this->skills; + } + return $skills; + } + + function get_skills_for_select() { + $skills = $this->get_skills(); + $skill_select = array(); + if (!empty($skills)) { + foreach($skills as $skill) { + $skill_select[$skill['id']] = $skill['name']; + } + } + return $skill_select; + } - -// CRUD FUNCTIONS + // CRUD FUNCTIONS /** * Retrieve categories and return them as an array of Category objects @@ -197,7 +220,8 @@ class Category implements GradebookItem $paramcount ++; } //echo $sql; - $result = Database::query($sql); + $result = Database::query($sql); + $allcat = array(); if (Database::num_rows($result) > 0) { $allcat = Category::create_category_objects_from_sql_result($result); } @@ -280,6 +304,10 @@ class Category implements GradebookItem Database::query($sql); $id = Database::insert_id(); $this->set_id($id); + + $gradebook= new Gradebook(); + $res = $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false)); + return $id; } } @@ -319,6 +347,10 @@ class Category implements GradebookItem .', visible = '.intval($this->is_visible()) .' WHERE id = '.intval($this->id); Database::query($sql); + + $gradebook= new Gradebook(); + $res = $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false)); + } /** @@ -1097,6 +1129,10 @@ class Category implements GradebookItem public function get_item_type() { return 'C'; } + + public function set_skills($skills) { + $this->skills = $skills; + } public function get_date() { return null; diff --git a/main/gradebook/lib/fe/catform.class.php b/main/gradebook/lib/fe/catform.class.php index 6caeec54a9..124903f3fd 100644 --- a/main/gradebook/lib/fe/catform.class.php +++ b/main/gradebook/lib/fe/catform.class.php @@ -19,10 +19,11 @@ require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; class CatForm extends FormValidator { - const TYPE_ADD = 1; - const TYPE_EDIT = 2; - const TYPE_MOVE = 3; - const TYPE_SELECT_COURSE = 4; + const TYPE_ADD = 1; + const TYPE_EDIT = 2; + const TYPE_MOVE = 3; + const TYPE_SELECT_COURSE = 4; + private $category_object; /** @@ -115,11 +116,14 @@ class CatForm extends FormValidator { * Builds an form to edit a category */ protected function build_editing_form() { + $skills = $this->category_object->get_skills_for_select(); + $this->setDefaults(array( 'name' => $this->category_object->get_name(), 'description' => $this->category_object->get_description(), 'hid_user_id' => $this->category_object->get_user_id(), 'hid_parent_id' => $this->category_object->get_parent_id(), + 'skills' => $skills, 'weight' => $this->category_object->get_weight(), 'visible' => $this->category_object->is_visible(), 'certif_min_score' => $this->category_object->get_certificate_min_score(), @@ -138,7 +142,7 @@ class CatForm extends FormValidator { //we can't change the root category $this->freeze('name'); } - $models = api_get_settings_options('grading_model'); + $models = api_get_settings_options('grading_model'); $course_grading_model_id = api_get_course_setting('course_grading_model'); $grading_model = ''; if (!empty($course_grading_model_id)) { @@ -165,13 +169,26 @@ class CatForm extends FormValidator { //$this->addRule('weight',get_lang('ThisFieldIsRequired'),'required'); $this->freeze('weight'); } else { - $this->add_textfield('weight', get_lang('TotalWeight'),true,array('value'=>$value,'size'=>'4','maxlength'=>'5')); + $this->add_textfield('weight', array(get_lang('TotalWeight'), get_lang('TotalSumOfWeights')), true, array('value'=>$value,'size'=>'4','maxlength'=>'5')); $this->addRule('weight',get_lang('ThisFieldIsRequired'),'required'); } - - - $this->addElement('static', null, null, ''.get_lang('TotalSumOfWeights').''); - + + if (api_is_platform_admin() || api_is_drh()) { + //the magic should be here + + $skills = $this->category_object->get_skills(); + $this->addElement('select', 'skills', array(get_lang('SkillsAchievedWhenAchievingThisGradebook')), null, array('id'=>'skills', 'multiple'=>'multiple')); + $content = ''; + if (!empty($skills)) { + foreach($skills as $skill) { + $content .= Display::tag('li', $skill['name'].'', array('id'=>'skill_'.$skill['id'], 'class'=>'bit-box')); + } + } + $this->addElement('html', '