work_list_all.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. require_once '../inc/global.inc.php';
  5. $current_course_tool = TOOL_STUDENTPUBLICATION;
  6. api_protect_course_script(true);
  7. // Including necessary files
  8. require_once 'work.lib.php';
  9. $this_section = SECTION_COURSES;
  10. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  11. $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
  12. if (empty($workId)) {
  13. api_not_allowed(true);
  14. }
  15. $my_folder_data = get_work_data_by_id($workId);
  16. if (empty($my_folder_data)) {
  17. api_not_allowed(true);
  18. }
  19. $work_data = get_work_assignment_by_id($workId);
  20. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  21. api_get_user_id(),
  22. api_get_course_info()
  23. );
  24. if (!($is_allowed_to_edit || $isDrhOfCourse)) {
  25. api_not_allowed(true);
  26. }
  27. $tool_name = get_lang('StudentPublications');
  28. $group_id = api_get_group_id();
  29. $courseInfo = api_get_course_info();
  30. $courseCode = $courseInfo['code'];
  31. $sessionId = api_get_session_id();
  32. $htmlHeadXtra[] = api_get_jqgrid_js();
  33. $user_id = api_get_user_id();
  34. if (!empty($group_id)) {
  35. $group_properties = GroupManager :: get_group_properties($group_id);
  36. $show_work = false;
  37. if (api_is_allowed_to_edit(false, true)) {
  38. $show_work = true;
  39. } else {
  40. // you are not a teacher
  41. $show_work = GroupManager::user_has_access(
  42. $user_id,
  43. $group_id,
  44. GroupManager::GROUP_TOOL_WORK
  45. );
  46. }
  47. if (!$show_work) {
  48. api_not_allowed();
  49. }
  50. $interbreadcrumb[] = array(
  51. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  52. 'name' => get_lang('Groups')
  53. );
  54. $interbreadcrumb[] = array(
  55. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  56. 'name' => get_lang('GroupSpace').' '.$group_properties['name']
  57. );
  58. }
  59. $interbreadcrumb[] = array(
  60. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  61. 'name' => get_lang('StudentPublications')
  62. );
  63. $interbreadcrumb[] = array(
  64. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
  65. 'name' => $my_folder_data['title']
  66. );
  67. $error_message = null;
  68. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  69. $itemId = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  70. $message = null;
  71. switch ($action) {
  72. case 'export_to_doc':
  73. if ($is_allowed_to_edit) {
  74. if (!empty($itemId)) {
  75. $work = get_work_data_by_id($itemId);
  76. if (!empty($work)) {
  77. Export::htmlToOdt($work['description'], $work['title']);
  78. }
  79. }
  80. }
  81. break;
  82. case 'delete':
  83. /* Delete document */
  84. if ($itemId) {
  85. $fileDeleted = deleteWorkItem($itemId, $courseInfo);
  86. if (!$fileDeleted) {
  87. $message = Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument'), 'error');
  88. } else {
  89. $message = Display::return_message(get_lang('TheDocumentHasBeenDeleted'), 'confirmation');
  90. }
  91. }
  92. break;
  93. case 'make_visible':
  94. /* Visible */
  95. if ($is_allowed_to_edit) {
  96. if (!empty($itemId)) {
  97. if (isset($itemId) && $itemId == 'all') {
  98. } else {
  99. makeVisible($itemId, $courseInfo);
  100. $message = Display::return_message(get_lang('FileVisible'), 'confirmation');
  101. }
  102. }
  103. }
  104. break;
  105. case 'make_invisible':
  106. /* Invisible */
  107. if (!empty($itemId)) {
  108. if (isset($itemId) && $itemId == 'all') {
  109. } else {
  110. makeInvisible($itemId, $courseInfo);
  111. $message = Display::return_message(get_lang('FileInvisible'), 'confirmation');
  112. }
  113. }
  114. break;
  115. case 'export_pdf':
  116. exportAllStudentWorkFromPublication(
  117. $workId,
  118. $courseInfo,
  119. $sessionId,
  120. 'pdf'
  121. );
  122. break;
  123. }
  124. $htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-upload'));
  125. Display :: display_header(null);
  126. echo $message;
  127. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  128. echo '<div class="actions">';
  129. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  130. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  131. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
  132. /*echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'">';
  133. echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';*/
  134. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId.'">';
  135. echo Display::return_icon('upload_file.png', get_lang('UploadCorrections'), '', ICON_SIZE_MEDIUM).'</a>';
  136. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  137. echo Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
  138. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  139. echo Display::return_icon('user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
  140. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
  141. echo Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  142. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  143. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
  144. $count = get_count_work($workId);
  145. if ($count > 0) {
  146. $display_output .= '<a href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  147. Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_MEDIUM).'</a>';
  148. }
  149. echo $display_output;
  150. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  151. echo Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  152. }
  153. echo '</div>';
  154. if (!empty($my_folder_data['title'])) {
  155. echo Display::page_subheader($my_folder_data['title']);
  156. }
  157. $error_message = Session::read('error_message');
  158. if (!empty($error_message)) {
  159. echo $error_message;
  160. Session::erase('error_message');
  161. }
  162. if (!empty($my_folder_data['description'])) {
  163. echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.
  164. Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
  165. }
  166. $check_qualification = intval($my_folder_data['qualification']);
  167. if (!empty($work_data['enable_qualification']) &&
  168. !empty($check_qualification)
  169. ) {
  170. $type = 'simple';
  171. $columns = array(
  172. //get_lang('Type'),
  173. get_lang('FirstName'),
  174. get_lang('LastName'),
  175. get_lang('Title'),
  176. get_lang('Feedback'),
  177. get_lang('Date'),
  178. get_lang('Status'),
  179. get_lang('UploadCorrection'),
  180. get_lang('Actions')
  181. );
  182. $column_model = array(
  183. /*array(
  184. 'name' => 'type',
  185. 'index' => 'file',
  186. 'width' => '8',
  187. 'align' => 'left',
  188. 'search' => 'false',
  189. 'sortable' => 'false',
  190. ),*/
  191. array(
  192. 'name' => 'firstname',
  193. 'index' => 'firstname',
  194. 'width' => '35',
  195. 'align' => 'left',
  196. 'search' => 'true',
  197. ),
  198. array(
  199. 'name' => 'lastname',
  200. 'index' => 'lastname',
  201. 'width' => '35',
  202. 'align' => 'left',
  203. 'search' => 'true',
  204. ),
  205. array(
  206. 'name' => 'title',
  207. 'index' => 'title',
  208. 'width' => '40',
  209. 'align' => 'left',
  210. 'search' => 'false',
  211. 'wrap_cell' => 'true',
  212. ),
  213. array(
  214. 'name' => 'qualification',
  215. 'index' => 'qualification',
  216. 'width' => '20',
  217. 'align' => 'left',
  218. 'search' => 'true',
  219. ),
  220. array(
  221. 'name' => 'sent_date',
  222. 'index' => 'sent_date',
  223. 'width' => '40',
  224. 'align' => 'left',
  225. 'search' => 'true',
  226. 'wrap_cell' => 'true',
  227. ),
  228. array(
  229. 'name' => 'qualificator_id',
  230. 'index' => 'qualificator_id',
  231. 'width' => '25',
  232. 'align' => 'left',
  233. 'search' => 'true',
  234. ),
  235. array(
  236. 'name' => 'correction',
  237. 'index' => 'correction',
  238. 'width' => '30',
  239. 'align' => 'left',
  240. 'search' => 'false',
  241. 'sortable' => 'false',
  242. ),
  243. array(
  244. 'name' => 'actions',
  245. 'index' => 'actions',
  246. 'width' => '30',
  247. 'align' => 'left',
  248. 'search' => 'false',
  249. 'sortable' => 'false',
  250. ),
  251. );
  252. } else {
  253. $type = 'complex';
  254. $columns = array(
  255. //get_lang('Type'),
  256. get_lang('FirstName'),
  257. get_lang('LastName'),
  258. get_lang('Title'),
  259. get_lang('Feedback'),
  260. get_lang('Date'),
  261. get_lang('UploadCorrection'),
  262. get_lang('Actions')
  263. );
  264. $column_model = array(
  265. /*array(
  266. 'name' => 'type',
  267. 'index' => 'file',
  268. 'width' => '8',
  269. 'align' => 'left',
  270. 'search' => 'false',
  271. 'sortable' => 'false',
  272. ),*/
  273. array(
  274. 'name' => 'firstname',
  275. 'index' => 'firstname',
  276. 'width' => '35',
  277. 'align' => 'left',
  278. 'search' => 'true',
  279. ),
  280. array(
  281. 'name' => 'lastname',
  282. 'index' => 'lastname',
  283. 'width' => '35',
  284. 'align' => 'left',
  285. 'search' => 'true',
  286. ),
  287. array(
  288. 'name' => 'title',
  289. 'index' => 'title',
  290. 'width' => '40',
  291. 'align' => 'left',
  292. 'search' => 'false',
  293. 'wrap_cell' => "true",
  294. ),
  295. array(
  296. 'name' => 'qualification',
  297. 'index' => 'qualification',
  298. 'width' => '25',
  299. 'align' => 'left',
  300. 'search' => 'true',
  301. ),
  302. array(
  303. 'name' => 'sent_date',
  304. 'index' => 'sent_date',
  305. 'width' => '30',
  306. 'align' => 'left',
  307. 'search' => 'true',
  308. 'wrap_cell' => 'true',
  309. ),
  310. array(
  311. 'name' => 'correction',
  312. 'index' => 'correction',
  313. 'width' => '30',
  314. 'align' => 'left',
  315. 'search' => 'false',
  316. 'sortable' => 'false',
  317. ),
  318. array(
  319. 'name' => 'actions',
  320. 'index' => 'actions',
  321. 'width' => '40',
  322. 'align' => 'left',
  323. 'search' => 'false',
  324. 'sortable' => 'false'
  325. //'wrap_cell' => 'true',
  326. )
  327. );
  328. }
  329. $extra_params = array(
  330. 'autowidth' => 'true',
  331. 'height' => 'auto',
  332. 'sortname' => 'firstname',
  333. 'sortable' => 'false'
  334. );
  335. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type;
  336. ?>
  337. <script>
  338. $(function() {
  339. <?php
  340. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  341. ?>
  342. });
  343. </script>
  344. <?php
  345. echo $documentsAddedInWork;
  346. echo Display::grid_html('results');
  347. echo '<table style="display:none; width:50%" class="files data_table">
  348. <tr>
  349. <th>'.get_lang('FileName').'</th>
  350. <th>'.get_lang('Size').'</th>
  351. <th>'.get_lang('Status').'</th>
  352. </tr>
  353. </table>';
  354. Display :: display_footer();