work_list.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. $language_file = array('exercice', 'work', 'document', 'admin', 'gradebook');
  5. require_once '../inc/global.inc.php';
  6. $current_course_tool = TOOL_STUDENTPUBLICATION;
  7. /* Configuration settings */
  8. api_protect_course_script(true);
  9. // Including necessary files
  10. require_once 'work.lib.php';
  11. $this_section = SECTION_COURSES;
  12. $workId = isset($_GET['id']) ? intval($_GET['id']) : null;
  13. if (empty($workId)) {
  14. api_not_allowed(true);
  15. }
  16. $my_folder_data = get_work_data_by_id($workId);
  17. if (empty($my_folder_data)) {
  18. api_not_allowed(true);
  19. }
  20. $work_data = get_work_assignment_by_id($workId);
  21. $tool_name = get_lang('StudentPublications');
  22. $group_id = api_get_group_id();
  23. $courseInfo = api_get_course_info();
  24. $htmlHeadXtra[] = api_get_jqgrid_js();
  25. $url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
  26. allowOnlySubscribedUser(api_get_user_id(), $workId, $courseInfo['real_id']);
  27. if (!empty($group_id)) {
  28. $group_properties = GroupManager :: get_group_properties($group_id);
  29. $show_work = false;
  30. if (api_is_allowed_to_edit(false, true)) {
  31. $show_work = true;
  32. } else {
  33. // you are not a teacher
  34. $show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
  35. }
  36. if (!$show_work) {
  37. api_not_allowed();
  38. }
  39. $interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
  40. $interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  41. }
  42. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  43. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']);
  44. Display :: display_header(null);
  45. echo '<div class="actions">';
  46. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
  47. if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
  48. echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin.'&gradebook='.$gradebook.'">';
  49. echo Display::return_icon('upload_file.png', get_lang('UploadADocument'),'',ICON_SIZE_MEDIUM).'</a>';
  50. }
  51. echo '</div>';
  52. $error_message = isset($_GET['error_message']) ? Security::remove_XSS($_GET['error_message']) : null;
  53. if (!empty($error_message)) {
  54. echo $error_message;
  55. }
  56. if (!empty($my_folder_data['description'])) {
  57. echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
  58. }
  59. $documents = getAllDocumentToWork($workId, $courseInfo['real_id']);
  60. if (!empty($documents)) {
  61. $docContent = '<ul class="nav nav-list well">';
  62. $docContent .= '<li class="nav-header">'.get_lang('Documents').'</li>';
  63. foreach ($documents as $doc) {
  64. $docData = DocumentManager::get_document_data_by_id($doc['document_id'], $courseInfo['code']);
  65. if ($docData) {
  66. $docContent .= '<li><a target="_blank" href="'.$docData['url'].'">'.$docData['title'].'</a></li>';
  67. }
  68. }
  69. $docContent .= '</ul><br />';
  70. echo $docContent;
  71. }
  72. $check_qualification = intval($my_folder_data['qualification']);
  73. if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
  74. $type = 'simple';
  75. //$columns = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), get_lang('Title'), get_lang('Qualification'), get_lang('Date'), get_lang('Status'), get_lang('Actions'));
  76. $columns = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('Title'), get_lang('Qualification'), get_lang('Date'), get_lang('Status'), get_lang('Actions'));
  77. $column_model = array (
  78. array('name'=>'type', 'index'=>'file', 'width'=>'12', 'align'=>'left', 'search' => 'false'),
  79. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  80. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  81. //array('name'=>'username', 'index'=>'username', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  82. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
  83. // array('name'=>'file', 'index'=>'file', 'width'=>'20', 'align'=>'left', 'search' => 'false'),
  84. array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  85. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  86. array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  87. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  88. );
  89. } else {
  90. $type = 'complex';
  91. //$columns = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), get_lang('Title'), get_lang('Date'), get_lang('Actions'));
  92. $columns = array(get_lang('Type'), get_lang('FirstName'), get_lang('LastName'), get_lang('Title'), get_lang('Date'), get_lang('Actions'));
  93. $column_model = array (
  94. array('name'=>'type', 'index'=>'file', 'width'=>'12', 'align'=>'left', 'search' => 'false'),
  95. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  96. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
  97. //array('name'=>'username', 'index'=>'username', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  98. array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
  99. // array('name'=>'file', 'index'=>'file', 'width'=>'20', 'align'=>'left', 'search' => 'false'),
  100. //array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
  101. array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'50', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
  102. //array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  103. array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
  104. );
  105. }
  106. $extra_params = array();
  107. //Autowidth
  108. $extra_params['autowidth'] = 'true';
  109. //height auto
  110. $extra_params['height'] = 'auto';
  111. $extra_params['sortname'] = 'firstname';
  112. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type;
  113. ?>
  114. <script>
  115. $(function() {
  116. <?php
  117. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  118. ?>
  119. });
  120. </script>
  121. <?php
  122. echo Display::grid_html('results');
  123. Display :: display_footer();