skills_gradebook.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. // Language files that need to be included.
  7. $language_file = array('admin');
  8. $cidReset = true;
  9. require_once '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'skill.lib.php';
  11. require_once api_get_path(LIBRARY_PATH).'gradebook.lib.php';
  12. $this_section = SECTION_PLATFORM_ADMIN;
  13. api_protect_admin_script();
  14. //Adds the JS needed to use the jqgrid
  15. $htmlHeadXtra[] = api_get_jquery_ui_js(true);
  16. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'display';
  17. // setting breadcrumbs
  18. $tool_name = get_lang('SkillGradebook');
  19. $interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
  20. if ($action == 'add_skill') {
  21. $interbreadcrumb[]=array('url' => 'skills_gradebook.php','name' => get_lang('SkillGradebook'));
  22. $tool_name = get_lang('Add');
  23. }
  24. Display::display_header($tool_name);
  25. //jqgrid will use this URL to do the selects
  26. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_gradebooks';
  27. //The order is important you need to check the the $column variable in the model.ajax.php file
  28. $columns = array(get_lang('Name'), get_lang('Skills'), get_lang('Actions'));
  29. //Column config
  30. $column_model = array(
  31. array('name'=>'name', 'index'=>'name', 'width'=>'200', 'align'=>'left'),
  32. array('name'=>'skills', 'index'=>'skills', 'width'=>'300', 'align'=>'left','sortable'=>'false'),
  33. array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false')
  34. );
  35. //Autowidth
  36. $extra_params['autowidth'] = 'true';
  37. //height auto
  38. $extra_params['height'] = 'auto';
  39. //With this function we can add actions to the jgrid (edit, delete, etc)
  40. $action_links = 'function action_formatter(cellvalue, options, rowObject) {
  41. return \'<a href="?action=add_skill&id=\'+options.rowId+\'">'.Display::return_icon('addd.gif', get_lang('AddSkill'),'',22).'</a>'.
  42. '\';
  43. }';
  44. ?>
  45. <script>
  46. $(function() {
  47. <?php
  48. // grid definition see the $career->display() function
  49. echo Display::grid_js('gradebooks', $url,$columns,$column_model,$extra_params, array(), $action_links,true);
  50. ?>
  51. });
  52. </script>
  53. <?php
  54. $gradebook = new Gradebook();
  55. switch($action) {
  56. case 'display':
  57. $gradebook->display();
  58. break;
  59. case 'add_skill':
  60. $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
  61. $gradebook_info = $gradebook->get($id);
  62. $url = api_get_self().'?action='.$action.'&id='.$id;
  63. $form = $gradebook->show_skill_form($id, $url, $gradebook_info['name']);
  64. if ($form->validate()) {
  65. $values = $form->exportValues();
  66. $res = $gradebook->update_skills_to_gradebook($values['id'], $values['skill']);
  67. if ($res) {
  68. Display::display_confirmation_message(get_lang('ItemAdded'));
  69. }
  70. }
  71. $form->display();
  72. //echo Display::tag('h2',$gradebook_info['name']);
  73. break;
  74. }
  75. Display::display_footer();