work_list_all.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. $language_file = array(
  5. 'exercice',
  6. 'work',
  7. 'document',
  8. 'admin',
  9. 'gradebook',
  10. 'tracking'
  11. );
  12. require_once '../inc/global.inc.php';
  13. $current_course_tool = TOOL_STUDENTPUBLICATION;
  14. api_protect_course_script(true);
  15. // Including necessary files
  16. require_once 'work.lib.php';
  17. $this_section = SECTION_COURSES;
  18. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  19. $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
  20. if (empty($workId)) {
  21. api_not_allowed(true);
  22. }
  23. $my_folder_data = get_work_data_by_id($workId);
  24. if (empty($my_folder_data)) {
  25. api_not_allowed(true);
  26. }
  27. $work_data = get_work_assignment_by_id($workId);
  28. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  29. api_get_user_id(),
  30. api_get_course_info()
  31. );
  32. if (!($is_allowed_to_edit || $isDrhOfCourse)) {
  33. api_not_allowed(true);
  34. }
  35. $tool_name = get_lang('StudentPublications');
  36. $group_id = api_get_group_id();
  37. $courseInfo = api_get_course_info();
  38. $courseCode = $courseInfo['code'];
  39. $sessionId = api_get_session_id();
  40. $htmlHeadXtra[] = api_get_jqgrid_js();
  41. $user_id = api_get_user_id();
  42. if (!empty($group_id)) {
  43. $group_properties = GroupManager :: get_group_properties($group_id);
  44. $show_work = false;
  45. if (api_is_allowed_to_edit(false, true)) {
  46. $show_work = true;
  47. } else {
  48. // you are not a teacher
  49. $show_work = GroupManager::user_has_access(
  50. $user_id,
  51. $group_id,
  52. GroupManager::GROUP_TOOL_WORK
  53. );
  54. }
  55. if (!$show_work) {
  56. api_not_allowed();
  57. }
  58. $interbreadcrumb[] = array(
  59. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  60. 'name' => get_lang('Groups')
  61. );
  62. $interbreadcrumb[] = array(
  63. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  64. 'name' => get_lang('GroupSpace').' '.$group_properties['name']
  65. );
  66. }
  67. $interbreadcrumb[] = array(
  68. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  69. 'name' => get_lang('StudentPublications')
  70. );
  71. $interbreadcrumb[] = array(
  72. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
  73. 'name' => $my_folder_data['title']
  74. );
  75. $error_message = null;
  76. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  77. $itemId = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
  78. $message = null;
  79. switch ($action) {
  80. case 'delete':
  81. /* Delete document */
  82. if ($itemId) {
  83. $fileDeleted = deleteWorkItem($itemId, $courseInfo);
  84. if (!$fileDeleted) {
  85. $message = Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument'), 'error');
  86. } else {
  87. $message = Display::return_message(get_lang('TheDocumentHasBeenDeleted'), 'confirmation');
  88. }
  89. }
  90. break;
  91. case 'make_visible':
  92. /* Visible */
  93. if ($is_allowed_to_edit) {
  94. if (!empty($itemId)) {
  95. if (isset($itemId) && $itemId == 'all') {
  96. } else {
  97. makeVisible($itemId, $courseInfo);
  98. $message = Display::return_message(get_lang('FileVisible'), 'confirmation');
  99. }
  100. }
  101. }
  102. break;
  103. case 'make_invisible':
  104. /* Invisible */
  105. if (!empty($itemId)) {
  106. if (isset($itemId) && $itemId == 'all') {
  107. } else {
  108. makeInvisible($itemId, $courseInfo);
  109. $message = Display::return_message(get_lang('FileInvisible'), 'confirmation');
  110. }
  111. }
  112. break;
  113. case 'export_pdf':
  114. exportAllStudentWorkFromPublication(
  115. $workId,
  116. $courseInfo,
  117. $sessionId,
  118. 'pdf'
  119. );
  120. break;
  121. }
  122. Display :: display_header(null);
  123. echo $message;
  124. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  125. echo '<div class="actions">';
  126. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  127. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  128. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
  129. /*echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'">';
  130. echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';*/
  131. if (ADD_DOCUMENT_TO_WORK) {
  132. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  133. echo Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
  134. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  135. echo Display::return_icon('user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
  136. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
  137. echo Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  138. }
  139. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  140. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
  141. $count = get_count_work($workId);
  142. if ($count > 0) {
  143. $display_output .= '<a href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  144. Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_MEDIUM).'</a>';
  145. }
  146. echo $display_output;
  147. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  148. echo Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  149. }
  150. echo '</div>';
  151. if (!empty($my_folder_data['title'])) {
  152. echo Display::page_subheader($my_folder_data['title']);
  153. }
  154. $error_message = Session::read('error_message');
  155. if (!empty($error_message)) {
  156. echo $error_message;
  157. Session::erase('error_message');
  158. }
  159. if (!empty($my_folder_data['description'])) {
  160. echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.
  161. Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
  162. }
  163. $check_qualification = intval($my_folder_data['qualification']);
  164. if (!empty($work_data['enable_qualification']) &&
  165. !empty($check_qualification)
  166. ) {
  167. $type = 'simple';
  168. $columns = array(
  169. get_lang('Type'),
  170. get_lang('FirstName'),
  171. get_lang('LastName'),
  172. get_lang('Title'),
  173. get_lang('Score'),
  174. get_lang('Date'),
  175. get_lang('Status'),
  176. get_lang('Actions')
  177. );
  178. if (ALLOW_USER_COMMENTS) {
  179. $columns = array(
  180. get_lang('Type'),
  181. get_lang('FirstName'),
  182. get_lang('LastName'),
  183. get_lang('Title'),
  184. get_lang('Feedback'),
  185. get_lang('Date'),
  186. get_lang('Status'),
  187. get_lang('Actions')
  188. );
  189. }
  190. $column_model = array(
  191. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  192. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  193. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  194. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  195. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  196. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  197. array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'25', 'align'=>'left', 'search' => 'true'),
  198. array('name'=>'actions', 'index'=>'actions', 'width'=>'30', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', )
  199. );
  200. } else {
  201. $type = 'complex';
  202. $columns = array(
  203. get_lang('Type'),
  204. get_lang('FirstName'),
  205. get_lang('LastName'),
  206. get_lang('Title'),
  207. get_lang('Date'),
  208. get_lang('Actions')
  209. );
  210. $column_model = array(
  211. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  212. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  213. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  214. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  215. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'45', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  216. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', 'wrap_cell' => 'true')
  217. );
  218. if (ALLOW_USER_COMMENTS) {
  219. $columns = array(
  220. get_lang('Type'),
  221. get_lang('FirstName'),
  222. get_lang('LastName'),
  223. get_lang('Title'),
  224. get_lang('Feedback'),
  225. get_lang('Date'),
  226. get_lang('Actions')
  227. );
  228. $column_model = array(
  229. array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
  230. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  231. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  232. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  233. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'25', 'align'=>'left', 'search' => 'true'),
  234. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'45', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  235. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', 'wrap_cell' => 'true')
  236. );
  237. }
  238. }
  239. $extra_params = array(
  240. 'autowidth' => 'true',
  241. 'height' => 'auto',
  242. 'sortname' => 'firstname'
  243. );
  244. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type;
  245. ?>
  246. <script>
  247. $(function() {
  248. <?php
  249. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  250. ?>
  251. });
  252. </script>
  253. <?php
  254. echo $documentsAddedInWork;
  255. echo Display::grid_html('results');
  256. Display :: display_footer();