work_list_all.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../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_properties['iid'],
  43. GroupManager::GROUP_TOOL_WORK
  44. );
  45. }
  46. if (!$show_work) {
  47. api_not_allowed();
  48. }
  49. $interbreadcrumb[] = [
  50. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  51. 'name' => get_lang('Groups'),
  52. ];
  53. $interbreadcrumb[] = [
  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[] = [
  59. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  60. 'name' => get_lang('StudentPublications'),
  61. ];
  62. $interbreadcrumb[] = [
  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 'delete_correction':
  95. $result = get_work_user_list(null, null, null, null, $workId);
  96. if ($result) {
  97. foreach ($result as $item) {
  98. $workToDelete = get_work_data_by_id($item['id']);
  99. deleteCorrection($courseInfo, $workToDelete);
  100. }
  101. Display::addFlash(
  102. Display::return_message(get_lang('Deleted'), 'confirmation')
  103. );
  104. }
  105. header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
  106. exit;
  107. break;
  108. case 'make_visible':
  109. /* Visible */
  110. if ($is_allowed_to_edit) {
  111. if (!empty($itemId)) {
  112. if (isset($itemId) && $itemId == 'all') {
  113. } else {
  114. makeVisible($itemId, $courseInfo);
  115. Display::addFlash(
  116. Display::return_message(get_lang('FileVisible'), 'confirmation')
  117. );
  118. }
  119. }
  120. }
  121. break;
  122. case 'make_invisible':
  123. /* Invisible */
  124. if (!empty($itemId)) {
  125. if (isset($itemId) && $itemId == 'all') {
  126. } else {
  127. makeInvisible($itemId, $courseInfo);
  128. Display::addFlash(
  129. Display::return_message(get_lang('FileInvisible'), 'confirmation')
  130. );
  131. }
  132. }
  133. break;
  134. case 'export_pdf':
  135. exportAllStudentWorkFromPublication(
  136. $workId,
  137. $courseInfo,
  138. $sessionId,
  139. 'pdf'
  140. );
  141. break;
  142. }
  143. $htmlHeadXtra[] = api_get_jquery_libraries_js(['jquery-upload']);
  144. Display::display_header(null);
  145. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  146. $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  147. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  148. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
  149. $blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
  150. if (!$blockAddDocuments) {
  151. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  152. $actionsLeft .= Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
  153. }
  154. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  155. $actionsLeft .= Display::return_icon('addworkuser.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
  156. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
  157. $actionsLeft .= Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  158. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  159. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
  160. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  161. $actionsLeft .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  162. $count = get_count_work($workId);
  163. if ($count > 0) {
  164. $display_output .= '<a class="btn-toolbar" href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  165. Display::return_icon('save_pack.png', get_lang('DownloadTasksPackage'), null, ICON_SIZE_MEDIUM).' '.get_lang('DownloadTasksPackage').'</a>';
  166. }
  167. $actionsLeft .= $display_output;
  168. $url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
  169. $actionsLeft .= '<a class="btn-toolbar" href="'.$url.'">'.
  170. Display::return_icon('upload_package.png', get_lang('UploadCorrectionsPackage'), '', ICON_SIZE_MEDIUM).' '.get_lang('UploadCorrectionsPackage').'</a>';
  171. $url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=delete_correction';
  172. $actionsLeft .= Display::toolbarButton(get_lang('DeleteCorrections'), $url, 'remove', 'danger');
  173. }
  174. echo Display::toolbarAction('toolbar-worklist', [$actionsLeft]);
  175. if (!empty($my_folder_data['title'])) {
  176. echo Display::page_subheader($my_folder_data['title']);
  177. }
  178. if (!empty($my_folder_data['description'])) {
  179. $contentWork = Security::remove_XSS($my_folder_data['description']);
  180. $html = '';
  181. $html .= Display::panel($contentWork, get_lang('Description'));
  182. echo $html;
  183. }
  184. $check_qualification = intval($my_folder_data['qualification']);
  185. $orderName = api_is_western_name_order() ? 'firstname' : 'lastname';
  186. if (!empty($work_data['enable_qualification']) &&
  187. !empty($check_qualification)
  188. ) {
  189. $type = 'simple';
  190. $columns = [
  191. get_lang('FullUserName'),
  192. get_lang('Title'),
  193. get_lang('Score'),
  194. get_lang('Date'),
  195. get_lang('Status'),
  196. get_lang('UploadCorrection'),
  197. get_lang('Actions'),
  198. ];
  199. $column_model = [
  200. [
  201. 'name' => 'fullname',
  202. 'index' => $orderName,
  203. 'width' => '30',
  204. 'align' => 'left',
  205. 'search' => 'true',
  206. ],
  207. [
  208. 'name' => 'title',
  209. 'index' => 'title',
  210. 'width' => '25',
  211. 'align' => 'left',
  212. 'search' => 'false',
  213. 'wrap_cell' => 'true',
  214. ],
  215. [
  216. 'name' => 'qualification',
  217. 'index' => 'qualification',
  218. 'width' => '15',
  219. 'align' => 'center',
  220. 'search' => 'true',
  221. ],
  222. [
  223. 'name' => 'sent_date',
  224. 'index' => 'sent_date',
  225. 'width' => '25',
  226. 'align' => 'left',
  227. 'search' => 'true',
  228. 'wrap_cell' => 'true',
  229. ],
  230. [
  231. 'name' => 'qualificator_id',
  232. 'index' => 'qualificator_id',
  233. 'width' => '20',
  234. 'align' => 'left',
  235. 'search' => 'true',
  236. ],
  237. [
  238. 'name' => 'correction',
  239. 'index' => 'correction',
  240. 'width' => '30',
  241. 'align' => 'left',
  242. 'search' => 'false',
  243. 'sortable' => 'false',
  244. 'title' => 'false',
  245. ],
  246. [
  247. 'name' => 'actions',
  248. 'index' => 'actions',
  249. 'width' => '25',
  250. 'align' => 'left',
  251. 'search' => 'false',
  252. 'sortable' => 'false',
  253. ],
  254. ];
  255. } else {
  256. $type = 'complex';
  257. $columns = [
  258. get_lang('FullUserName'),
  259. get_lang('Title'),
  260. get_lang('Feedback'),
  261. get_lang('Date'),
  262. get_lang('UploadCorrection'),
  263. get_lang('Actions'),
  264. ];
  265. $column_model = [
  266. [
  267. 'name' => 'fullname',
  268. 'index' => $orderName,
  269. 'width' => '35',
  270. 'align' => 'left',
  271. 'search' => 'true',
  272. ],
  273. [
  274. 'name' => 'title',
  275. 'index' => 'title',
  276. 'width' => '30',
  277. 'align' => 'left',
  278. 'search' => 'false',
  279. 'wrap_cell' => "true",
  280. ],
  281. [
  282. 'name' => 'qualification',
  283. 'index' => 'qualification',
  284. 'width' => '20',
  285. 'align' => 'center',
  286. 'search' => 'true',
  287. ],
  288. [
  289. 'name' => 'sent_date',
  290. 'index' => 'sent_date',
  291. 'width' => '30',
  292. 'align' => 'left',
  293. 'search' => 'true',
  294. 'wrap_cell' => 'true',
  295. ],
  296. [
  297. 'name' => 'correction',
  298. 'index' => 'correction',
  299. 'width' => '40',
  300. 'align' => 'left',
  301. 'search' => 'false',
  302. 'sortable' => 'false',
  303. 'title' => 'false',
  304. ],
  305. [
  306. 'name' => 'actions',
  307. 'index' => 'actions',
  308. 'width' => '30',
  309. 'align' => 'left',
  310. 'search' => 'false',
  311. 'sortable' => 'false',
  312. //'wrap_cell' => 'true',
  313. ],
  314. ];
  315. }
  316. $extra_params = [
  317. 'autowidth' => 'true',
  318. 'height' => 'auto',
  319. 'sortname' => $orderName,
  320. 'sortable' => 'false',
  321. ];
  322. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
  323. ?>
  324. <script>
  325. $(function() {
  326. <?php
  327. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  328. ?>
  329. });
  330. </script>
  331. <?php
  332. echo $documentsAddedInWork;
  333. $tableWork = Display::grid_html('results');
  334. echo workGetExtraFieldData($workId);
  335. echo Display::panel($tableWork);
  336. echo '<div class="list-work-results">';
  337. echo '<div class="panel panel-default">';
  338. echo '<div class="panel-body">';
  339. echo '<table style="display:none; width:100%" class="files data_table">
  340. <tr>
  341. <th>'.get_lang('FileName').'</th>
  342. <th>'.get_lang('Size').'</th>
  343. <th>'.get_lang('Status').'</th>
  344. </tr>
  345. </table>';
  346. echo '</div></div></div>';
  347. Display :: display_footer();