work_list.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CourseBundle\Entity\CStudentPublication;
  4. require_once __DIR__.'/../inc/global.inc.php';
  5. $current_course_tool = TOOL_STUDENTPUBLICATION;
  6. api_protect_course_script(true);
  7. require_once 'work.lib.php';
  8. $this_section = SECTION_COURSES;
  9. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  10. $courseInfo = api_get_course_info();
  11. if (empty($workId) || empty($courseInfo)) {
  12. api_not_allowed(true);
  13. }
  14. // Student publications are saved with the iid in a LP
  15. $origin = api_get_origin();
  16. if ($origin == 'learnpath') {
  17. $em = Database::getManager();
  18. /** @var CStudentPublication $work */
  19. $work = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->findOneBy(
  20. ['iid' => $workId, 'cId' => $courseInfo['real_id']]
  21. );
  22. if ($work) {
  23. $workId = $work->getId();
  24. }
  25. }
  26. protectWork($courseInfo, $workId);
  27. $my_folder_data = get_work_data_by_id($workId);
  28. $work_data = get_work_assignment_by_id($workId);
  29. $tool_name = get_lang('StudentPublications');
  30. $group_id = api_get_group_id();
  31. $htmlHeadXtra[] = api_get_jqgrid_js();
  32. $url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
  33. if (!empty($group_id)) {
  34. $group_properties = GroupManager :: get_group_properties($group_id);
  35. $interbreadcrumb[] = [
  36. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  37. 'name' => get_lang('Groups'),
  38. ];
  39. $interbreadcrumb[] = [
  40. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  41. 'name' => get_lang('GroupSpace').' '.$group_properties['name'],
  42. ];
  43. }
  44. $interbreadcrumb[] = [
  45. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  46. 'name' => get_lang('StudentPublications'),
  47. ];
  48. $interbreadcrumb[] = [
  49. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId,
  50. 'name' => $my_folder_data['title'],
  51. ];
  52. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  53. $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  54. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  55. $actionsRight = '';
  56. $onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
  57. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) {
  58. $url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId;
  59. $actionsRight = Display::url(
  60. Display::return_icon(
  61. 'upload_file.png',
  62. get_lang('UploadMyAssignment'),
  63. null,
  64. ICON_SIZE_MEDIUM
  65. ).get_lang('UploadMyAssignment'),
  66. $url,
  67. ['class' => 'btn-toolbar']
  68. );
  69. }
  70. if ($onlyOnePublication) {
  71. $count = get_work_count_by_student(
  72. api_get_user_id(),
  73. $my_folder_data['id']
  74. );
  75. if (!empty($count) && $count >= 1) {
  76. $actionsRight = '';
  77. }
  78. }
  79. $tpl = new Template('');
  80. $content = Display::toolbarAction('toolbar-work', [$actionsLeft, $actionsRight]);
  81. if (!empty($my_folder_data['title'])) {
  82. $content .= Display::page_subheader($my_folder_data['title']);
  83. }
  84. if (!empty($my_folder_data['description'])) {
  85. $contentWork = Security::remove_XSS($my_folder_data['description']);
  86. $content .= Display::panel($contentWork, get_lang('Description'));
  87. }
  88. $content .= workGetExtraFieldData($workId);
  89. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  90. $item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  91. switch ($action) {
  92. case 'delete':
  93. $fileDeleted = deleteWorkItem($item_id, $courseInfo);
  94. if (!$fileDeleted) {
  95. Display::addFlash(Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument')));
  96. } else {
  97. Display::addFlash(Display::return_message(get_lang('TheDocumentHasBeenDeleted')));
  98. }
  99. break;
  100. }
  101. $result = getWorkDateValidationStatus($work_data);
  102. $content .= $result['message'];
  103. $check_qualification = intval($my_folder_data['qualification']);
  104. if (!api_is_invitee()) {
  105. if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
  106. $type = 'simple';
  107. $columns = [
  108. get_lang('Type'),
  109. get_lang('Title'),
  110. get_lang('Qualification'),
  111. get_lang('Date'),
  112. get_lang('Status'),
  113. get_lang('Actions'),
  114. ];
  115. $columnModel = [
  116. [
  117. 'name' => 'type',
  118. 'index' => 'file',
  119. 'width' => '5',
  120. 'align' => 'left',
  121. 'search' => 'false',
  122. 'sortable' => 'false',
  123. ],
  124. [
  125. 'name' => 'title',
  126. 'index' => 'title',
  127. 'width' => '40',
  128. 'align' => 'left',
  129. 'search' => 'false',
  130. 'wrap_cell' => 'true',
  131. ],
  132. [
  133. 'name' => 'qualification',
  134. 'index' => 'qualification',
  135. 'width' => '30',
  136. 'align' => 'center',
  137. 'search' => 'true',
  138. ],
  139. [
  140. 'name' => 'sent_date',
  141. 'index' => 'sent_date',
  142. 'width' => '30',
  143. 'align' => 'left',
  144. 'search' => 'true',
  145. 'wrap_cell' => 'true',
  146. ],
  147. [
  148. 'name' => 'qualificator_id',
  149. 'index' => 'qualificator_id',
  150. 'width' => '20',
  151. 'align' => 'left',
  152. 'search' => 'true',
  153. ],
  154. [
  155. 'name' => 'actions',
  156. 'index' => 'actions',
  157. 'width' => '20',
  158. 'align' => 'left',
  159. 'search' => 'false',
  160. 'sortable' => 'false',
  161. ],
  162. ];
  163. } else {
  164. $type = 'complex';
  165. $columns = [
  166. get_lang('Type'),
  167. get_lang('Title'),
  168. get_lang('Feedback'),
  169. get_lang('Date'),
  170. get_lang('Actions'),
  171. ];
  172. $columnModel = [
  173. [
  174. 'name' => 'type',
  175. 'index' => 'file',
  176. 'width' => '5',
  177. 'align' => 'left',
  178. 'search' => 'false',
  179. 'sortable' => 'false',
  180. ],
  181. [
  182. 'name' => 'title',
  183. 'index' => 'title',
  184. 'width' => '60',
  185. 'align' => 'left',
  186. 'search' => 'false',
  187. 'wrap_cell' => "true",
  188. ],
  189. [
  190. 'name' => 'qualification',
  191. 'index' => 'qualification',
  192. 'width' => '30',
  193. 'align' => 'center',
  194. 'search' => 'true',
  195. ],
  196. [
  197. 'name' => 'sent_date',
  198. 'index' => 'sent_date',
  199. 'width' => '30',
  200. 'align' => 'left',
  201. 'search' => 'true',
  202. 'wrap_cell' => 'true',
  203. 'sortable' => 'false',
  204. ],
  205. [
  206. 'name' => 'actions',
  207. 'index' => 'actions',
  208. 'width' => '20',
  209. 'align' => 'left',
  210. 'search' => 'false',
  211. 'sortable' => 'false',
  212. ],
  213. ];
  214. }
  215. $extraParams = [
  216. 'autowidth' => 'true',
  217. 'height' => 'auto',
  218. 'sortname' => 'sent_date',
  219. 'sortorder' => 'desc',
  220. ];
  221. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
  222. $content .= '
  223. <script>
  224. $(function() {
  225. '.Display::grid_js('results', $url, $columns, $columnModel, $extraParams).'
  226. });
  227. </script>
  228. ';
  229. $content .= getAllDocumentsFromWorkToString($workId, $courseInfo);
  230. $tableWork = Display::grid_html('results');
  231. $content .= Display::panel($tableWork);
  232. }
  233. $tpl->assign('content', $content);
  234. $tpl->display_one_col_template();