work_list_all.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  68. $itemId = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  69. switch ($action) {
  70. case 'export_to_doc':
  71. if ($is_allowed_to_edit) {
  72. if (!empty($itemId)) {
  73. $work = get_work_data_by_id($itemId);
  74. if (!empty($work)) {
  75. Export::htmlToOdt($work['description'], $work['title']);
  76. }
  77. }
  78. }
  79. break;
  80. case 'delete':
  81. /* Delete document */
  82. if ($itemId) {
  83. $fileDeleted = deleteWorkItem($itemId, $courseInfo);
  84. if (!$fileDeleted) {
  85. Display::addFlash(
  86. Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument'), 'error')
  87. );
  88. } else {
  89. Display::addFlash(
  90. Display::return_message(get_lang('TheDocumentHasBeenDeleted'), 'confirmation')
  91. );
  92. }
  93. }
  94. break;
  95. case 'delete_correction':
  96. $result = get_work_user_list(null, null, null, null, $workId);
  97. if ($result) {
  98. foreach ($result as $item) {
  99. $workToDelete = get_work_data_by_id($item['id']);
  100. deleteCorrection($courseInfo, $workToDelete);
  101. }
  102. Display::addFlash(
  103. Display::return_message(get_lang('Deleted'), 'confirmation')
  104. );
  105. }
  106. header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
  107. exit;
  108. break;
  109. case 'make_visible':
  110. /* Visible */
  111. if ($is_allowed_to_edit) {
  112. if (!empty($itemId)) {
  113. if (isset($itemId) && $itemId == 'all') {
  114. } else {
  115. makeVisible($itemId, $courseInfo);
  116. Display::addFlash(
  117. Display::return_message(get_lang('FileVisible'), 'confirmation')
  118. );
  119. }
  120. }
  121. }
  122. break;
  123. case 'make_invisible':
  124. /* Invisible */
  125. if (!empty($itemId)) {
  126. if (isset($itemId) && $itemId == 'all') {
  127. } else {
  128. makeInvisible($itemId, $courseInfo);
  129. Display::addFlash(
  130. Display::return_message(get_lang('FileInvisible'), 'confirmation')
  131. );
  132. }
  133. }
  134. break;
  135. case 'export_pdf':
  136. exportAllStudentWorkFromPublication(
  137. $workId,
  138. $courseInfo,
  139. $sessionId,
  140. 'pdf'
  141. );
  142. break;
  143. }
  144. $htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-upload'));
  145. Display :: display_header(null);
  146. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  147. $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  148. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  149. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
  150. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  151. $actionsLeft .= Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
  152. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  153. $actionsLeft .= Display::return_icon('addworkuser.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
  154. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
  155. $actionsLeft .= Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  156. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  157. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
  158. $count = get_count_work($workId);
  159. if ($count > 0) {
  160. $display_output .= '<a href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  161. Display::return_icon('save_pack.png', get_lang('Save'), null, ICON_SIZE_MEDIUM).'</a>';
  162. }
  163. $actionsLeft .= $display_output;
  164. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  165. $actionsLeft .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  166. $url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
  167. $actionsLeft .= Display::toolbarButton(get_lang('UploadCorrections'), $url, 'upload', 'success');
  168. $url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=delete_correction';
  169. $actionsLeft .= Display::toolbarButton(get_lang('DeleteCorrections'), $url, 'remove', 'danger');
  170. }
  171. echo Display::toolbarAction('toolbar-worklist', array($actionsLeft), 1);
  172. if (!empty($my_folder_data['title'])) {
  173. echo Display::page_subheader($my_folder_data['title']);
  174. }
  175. if (!empty($my_folder_data['description'])) {
  176. $contentWork = Security::remove_XSS($my_folder_data['description']);
  177. $html = '';
  178. $html .= Display::panel($contentWork, get_lang('Description'));
  179. echo $html;
  180. }
  181. $check_qualification = intval($my_folder_data['qualification']);
  182. if (!empty($work_data['enable_qualification']) &&
  183. !empty($check_qualification)
  184. ) {
  185. $type = 'simple';
  186. $columns = array(
  187. //get_lang('Type'),
  188. get_lang('FirstName'),
  189. get_lang('LastName'),
  190. get_lang('Title'),
  191. get_lang('Feedback'),
  192. get_lang('Date'),
  193. get_lang('Status'),
  194. get_lang('UploadCorrection'),
  195. get_lang('Actions')
  196. );
  197. $column_model = array(
  198. /*array(
  199. 'name' => 'type',
  200. 'index' => 'file',
  201. 'width' => '8',
  202. 'align' => 'left',
  203. 'search' => 'false',
  204. 'sortable' => 'false',
  205. ),*/
  206. array(
  207. 'name' => 'firstname',
  208. 'index' => 'firstname',
  209. 'width' => '35',
  210. 'align' => 'left',
  211. 'search' => 'true',
  212. ),
  213. array(
  214. 'name' => 'lastname',
  215. 'index' => 'lastname',
  216. 'width' => '35',
  217. 'align' => 'left',
  218. 'search' => 'true',
  219. ),
  220. array(
  221. 'name' => 'title',
  222. 'index' => 'title',
  223. 'width' => '40',
  224. 'align' => 'left',
  225. 'search' => 'false',
  226. 'wrap_cell' => 'true',
  227. ),
  228. array(
  229. 'name' => 'qualification',
  230. 'index' => 'qualification',
  231. 'width' => '20',
  232. 'align' => 'left',
  233. 'search' => 'true',
  234. ),
  235. array(
  236. 'name' => 'sent_date',
  237. 'index' => 'sent_date',
  238. 'width' => '40',
  239. 'align' => 'left',
  240. 'search' => 'true',
  241. 'wrap_cell' => 'true',
  242. ),
  243. array(
  244. 'name' => 'qualificator_id',
  245. 'index' => 'qualificator_id',
  246. 'width' => '25',
  247. 'align' => 'left',
  248. 'search' => 'true',
  249. ),
  250. array(
  251. 'name' => 'correction',
  252. 'index' => 'correction',
  253. 'width' => '30',
  254. 'align' => 'left',
  255. 'search' => 'false',
  256. 'sortable' => 'false',
  257. 'title' => 'false'
  258. ),
  259. array(
  260. 'name' => 'actions',
  261. 'index' => 'actions',
  262. 'width' => '30',
  263. 'align' => 'left',
  264. 'search' => 'false',
  265. 'sortable' => 'false',
  266. ),
  267. );
  268. } else {
  269. $type = 'complex';
  270. $columns = array(
  271. //get_lang('Type'),
  272. get_lang('FirstName'),
  273. get_lang('LastName'),
  274. get_lang('Title'),
  275. get_lang('Feedback'),
  276. get_lang('Date'),
  277. get_lang('UploadCorrection'),
  278. get_lang('Actions')
  279. );
  280. $column_model = array(
  281. /*array(
  282. 'name' => 'type',
  283. 'index' => 'file',
  284. 'width' => '8',
  285. 'align' => 'left',
  286. 'search' => 'false',
  287. 'sortable' => 'false',
  288. ),*/
  289. array(
  290. 'name' => 'firstname',
  291. 'index' => 'firstname',
  292. 'width' => '35',
  293. 'align' => 'left',
  294. 'search' => 'true',
  295. ),
  296. array(
  297. 'name' => 'lastname',
  298. 'index' => 'lastname',
  299. 'width' => '35',
  300. 'align' => 'left',
  301. 'search' => 'true',
  302. ),
  303. array(
  304. 'name' => 'title',
  305. 'index' => 'title',
  306. 'width' => '40',
  307. 'align' => 'left',
  308. 'search' => 'false',
  309. 'wrap_cell' => "true",
  310. ),
  311. array(
  312. 'name' => 'qualification',
  313. 'index' => 'qualification',
  314. 'width' => '25',
  315. 'align' => 'left',
  316. 'search' => 'true',
  317. ),
  318. array(
  319. 'name' => 'sent_date',
  320. 'index' => 'sent_date',
  321. 'width' => '30',
  322. 'align' => 'left',
  323. 'search' => 'true',
  324. 'wrap_cell' => 'true',
  325. ),
  326. array(
  327. 'name' => 'correction',
  328. 'index' => 'correction',
  329. 'width' => '30',
  330. 'align' => 'left',
  331. 'search' => 'false',
  332. 'sortable' => 'false',
  333. 'title' => 'false',
  334. ),
  335. array(
  336. 'name' => 'actions',
  337. 'index' => 'actions',
  338. 'width' => '40',
  339. 'align' => 'left',
  340. 'search' => 'false',
  341. 'sortable' => 'false'
  342. //'wrap_cell' => 'true',
  343. )
  344. );
  345. }
  346. $extra_params = array(
  347. 'autowidth' => 'true',
  348. 'height' => 'auto',
  349. 'sortname' => 'firstname',
  350. 'sortable' => 'false'
  351. );
  352. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
  353. ?>
  354. <script>
  355. $(function() {
  356. <?php
  357. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  358. ?>
  359. });
  360. </script>
  361. <?php
  362. echo $documentsAddedInWork;
  363. $tableWork = Display::grid_html('results');
  364. echo Display::panel($tableWork);
  365. echo '<div class="list-work-results">';
  366. echo '<div class="panel panel-default">';
  367. echo '<div class="panel-body">';
  368. echo '<table style="display:none; width:100%" class="files data_table">
  369. <tr>
  370. <th>'.get_lang('FileName').'</th>
  371. <th>'.get_lang('Size').'</th>
  372. <th>'.get_lang('Status').'</th>
  373. </tr>
  374. </table>';
  375. echo '</div></div></div>';
  376. Display :: display_footer();