work_list.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. $language_file = array('exercice', 'work', 'document', 'admin', 'gradebook');
  5. require_once '../inc/global.inc.php';
  6. $current_course_tool = TOOL_STUDENTPUBLICATION;
  7. /* Configuration settings */
  8. api_protect_course_script(true);
  9. // Including necessary files
  10. require_once 'work.lib.php';
  11. $this_section = SECTION_COURSES;
  12. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  13. if (empty($workId)) {
  14. api_not_allowed(true);
  15. }
  16. $my_folder_data = get_work_data_by_id($workId);
  17. if (empty($my_folder_data)) {
  18. api_not_allowed(true);
  19. }
  20. $work_data = get_work_assignment_by_id($workId);
  21. $tool_name = get_lang('StudentPublications');
  22. $group_id = api_get_group_id();
  23. $courseInfo = api_get_course_info();
  24. $htmlHeadXtra[] = api_get_jqgrid_js();
  25. $url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
  26. allowOnlySubscribedUser(api_get_user_id(), $workId, $courseInfo['real_id']);
  27. if (!empty($group_id)) {
  28. $group_properties = GroupManager :: get_group_properties($group_id);
  29. $show_work = false;
  30. if (api_is_allowed_to_edit(false, true)) {
  31. $show_work = true;
  32. } else {
  33. // you are not a teacher
  34. $show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
  35. }
  36. if (!$show_work) {
  37. api_not_allowed();
  38. }
  39. $interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
  40. $interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  41. }
  42. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  43. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
  44. Display :: display_header(null);
  45. echo '<div class="actions">';
  46. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
  47. if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
  48. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin.'&gradebook='.$gradebook.'">';
  49. echo Display::return_icon('upload_file.png', get_lang('UploadADocument'),'',ICON_SIZE_MEDIUM).'</a>';
  50. }
  51. echo '</div>';
  52. $error_message = isset($_GET['error_message']) ? Security::remove_XSS($_GET['error_message']) : null;
  53. if (!empty($error_message)) {
  54. echo $error_message;
  55. }
  56. if (!empty($my_folder_data['description'])) {
  57. echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
  58. }
  59. echo getAllDocumentsFromWorkToString($workId, $courseInfo);
  60. $check_qualification = intval($my_folder_data['qualification']);
  61. if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
  62. $type = 'simple';
  63. $columns = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('Title'), get_lang('Qualification'), get_lang('Date'), get_lang('Status'), get_lang('Actions'));
  64. $column_model = array (
  65. array('name'=>'type', 'index'=>'file', 'width'=>'12', 'align'=>'left', 'search' => 'false'),
  66. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  67. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  68. //array('name'=>'username', 'index'=>'username', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  69. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  70. // array('name'=>'file', 'index'=>'file', 'width'=>'20', 'align'=>'left', 'search' => 'false'),
  71. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  72. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  73. array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  74. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  75. );
  76. } else {
  77. $type = 'complex';
  78. $columns = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('Title'), get_lang('Date'), get_lang('Actions'));
  79. $column_model = array (
  80. array('name'=>'type', 'index'=>'file', 'width'=>'12', 'align'=>'left', 'search' => 'false'),
  81. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  82. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  83. //array('name'=>'username', 'index'=>'username', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  84. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  85. // array('name'=>'file', 'index'=>'file', 'width'=>'20', 'align'=>'left', 'search' => 'false'),
  86. //array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  87. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  88. //array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  89. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  90. );
  91. }
  92. $extra_params = array();
  93. // Auto width
  94. $extra_params['autowidth'] = 'true';
  95. // Height
  96. $extra_params['height'] = 'auto';
  97. $extra_params['sortname'] = 'firstname';
  98. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type;
  99. ?>
  100. <script>
  101. $(function() {
  102. <?php
  103. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  104. ?>
  105. });
  106. </script>
  107. <?php
  108. echo Display::grid_html('results');
  109. Display :: display_footer();