work_list_all.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. $language_file = array(
  5. 'exercice',
  6. 'document',
  7. 'admin',
  8. 'gradebook',
  9. 'tracking'
  10. );
  11. require_once '../inc/global.inc.php';
  12. $current_course_tool = TOOL_STUDENTPUBLICATION;
  13. api_protect_course_script(true);
  14. // Including necessary files
  15. require_once 'work.lib.php';
  16. $this_section = SECTION_COURSES;
  17. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  18. $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
  19. if (empty($workId)) {
  20. api_not_allowed(true);
  21. }
  22. $my_folder_data = get_work_data_by_id($workId);
  23. if (empty($my_folder_data)) {
  24. api_not_allowed(true);
  25. }
  26. $work_data = get_work_assignment_by_id($workId);
  27. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  28. api_get_user_id(),
  29. api_get_course_info()
  30. );
  31. if (!($is_allowed_to_edit || $isDrhOfCourse)) {
  32. api_not_allowed(true);
  33. }
  34. $tool_name = get_lang('StudentPublications');
  35. $group_id = api_get_group_id();
  36. $courseInfo = api_get_course_info();
  37. $courseCode = $courseInfo['code'];
  38. $sessionId = api_get_session_id();
  39. $htmlHeadXtra[] = api_get_jqgrid_js();
  40. $user_id = api_get_user_id();
  41. if (!empty($group_id)) {
  42. $group_properties = GroupManager :: get_group_properties($group_id);
  43. $show_work = false;
  44. if (api_is_allowed_to_edit(false, true)) {
  45. $show_work = true;
  46. } else {
  47. // you are not a teacher
  48. $show_work = GroupManager::user_has_access(
  49. $user_id,
  50. $group_id,
  51. GroupManager::GROUP_TOOL_WORK
  52. );
  53. }
  54. if (!$show_work) {
  55. api_not_allowed();
  56. }
  57. $interbreadcrumb[] = array(
  58. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  59. 'name' => get_lang('Groups')
  60. );
  61. $interbreadcrumb[] = array(
  62. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  63. 'name' => get_lang('GroupSpace').' '.$group_properties['name']
  64. );
  65. }
  66. $interbreadcrumb[] = array(
  67. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  68. 'name' => get_lang('StudentPublications')
  69. );
  70. $interbreadcrumb[] = array(
  71. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
  72. 'name' => $my_folder_data['title']
  73. );
  74. $error_message = null;
  75. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  76. $itemId = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  77. $message = null;
  78. switch ($action) {
  79. case 'delete':
  80. /* Delete document */
  81. if ($itemId) {
  82. $fileDeleted = deleteWorkItem($itemId, $courseInfo);
  83. if (!$fileDeleted) {
  84. $message = Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument'), 'error');
  85. } else {
  86. $message = Display::return_message(get_lang('TheDocumentHasBeenDeleted'), 'confirmation');
  87. }
  88. }
  89. break;
  90. case 'make_visible':
  91. /* Visible */
  92. if ($is_allowed_to_edit) {
  93. if (!empty($itemId)) {
  94. if (isset($itemId) && $itemId == 'all') {
  95. } else {
  96. makeVisible($itemId, $courseInfo);
  97. $message = Display::return_message(get_lang('FileVisible'), 'confirmation');
  98. }
  99. }
  100. }
  101. break;
  102. case 'make_invisible':
  103. /* Invisible */
  104. if (!empty($itemId)) {
  105. if (isset($itemId) && $itemId == 'all') {
  106. } else {
  107. makeInvisible($itemId, $courseInfo);
  108. $message = Display::return_message(get_lang('FileInvisible'), 'confirmation');
  109. }
  110. }
  111. break;
  112. case 'export_pdf':
  113. exportAllStudentWorkFromPublication(
  114. $workId,
  115. $courseInfo,
  116. $sessionId,
  117. 'pdf'
  118. );
  119. break;
  120. }
  121. Display :: display_header(null);
  122. echo $message;
  123. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  124. echo '<div class="actions">';
  125. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  126. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  127. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
  128. /*echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'">';
  129. echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';*/
  130. if (ADD_DOCUMENT_TO_WORK) {
  131. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  132. echo Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
  133. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  134. echo Display::return_icon('user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
  135. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
  136. echo Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  137. }
  138. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  139. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
  140. $count = get_count_work($workId);
  141. if ($count > 0) {
  142. $display_output .= '<a href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  143. Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_MEDIUM).'</a>';
  144. }
  145. echo $display_output;
  146. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  147. echo Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  148. }
  149. echo '</div>';
  150. if (!empty($my_folder_data['title'])) {
  151. echo Display::page_subheader($my_folder_data['title']);
  152. }
  153. $error_message = Session::read('error_message');
  154. if (!empty($error_message)) {
  155. echo $error_message;
  156. Session::erase('error_message');
  157. }
  158. if (!empty($my_folder_data['description'])) {
  159. echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.
  160. Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
  161. }
  162. $check_qualification = intval($my_folder_data['qualification']);
  163. if (!empty($work_data['enable_qualification']) &&
  164. !empty($check_qualification)
  165. ) {
  166. $type = 'simple';
  167. $columns = array(
  168. get_lang('Type'),
  169. get_lang('FirstName'),
  170. get_lang('LastName'),
  171. get_lang('Title'),
  172. get_lang('Score'),
  173. get_lang('Date'),
  174. get_lang('Status'),
  175. get_lang('Actions')
  176. );
  177. if (ALLOW_USER_COMMENTS) {
  178. $columns = array(
  179. get_lang('Type'),
  180. get_lang('FirstName'),
  181. get_lang('LastName'),
  182. get_lang('Title'),
  183. get_lang('Feedback'),
  184. get_lang('Date'),
  185. get_lang('Status'),
  186. get_lang('Actions')
  187. );
  188. }
  189. $column_model = array(
  190. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  191. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  192. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  193. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  194. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  195. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  196. array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'25', 'align'=>'left', 'search' => 'true'),
  197. array('name'=>'actions', 'index'=>'actions', 'width'=>'30', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', )
  198. );
  199. } else {
  200. $type = 'complex';
  201. $columns = array(
  202. get_lang('Type'),
  203. get_lang('FirstName'),
  204. get_lang('LastName'),
  205. get_lang('Title'),
  206. get_lang('Date'),
  207. get_lang('Actions')
  208. );
  209. $column_model = array(
  210. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  211. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  212. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  213. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  214. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'45', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  215. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', 'wrap_cell' => 'true')
  216. );
  217. if (ALLOW_USER_COMMENTS) {
  218. $columns = array(
  219. get_lang('Type'),
  220. get_lang('FirstName'),
  221. get_lang('LastName'),
  222. get_lang('Title'),
  223. get_lang('Feedback'),
  224. get_lang('Date'),
  225. get_lang('Actions')
  226. );
  227. $column_model = array(
  228. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  229. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  230. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  231. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  232. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'25', 'align'=>'left', 'search' => 'true'),
  233. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'45', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  234. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', 'wrap_cell' => 'true')
  235. );
  236. }
  237. }
  238. $extra_params = array(
  239. 'autowidth' => 'true',
  240. 'height' => 'auto',
  241. 'sortname' => 'firstname'
  242. );
  243. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type;
  244. ?>
  245. <script>
  246. $(function() {
  247. <?php
  248. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  249. ?>
  250. });
  251. </script>
  252. <?php
  253. echo $documentsAddedInWork;
  254. echo Display::grid_html('results');
  255. Display :: display_footer();