work_list_all.php 12 KB

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