work_list_all.php 12 KB

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