student_work.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. api_protect_course_script(true);
  8. require_once 'work.lib.php';
  9. $this_section = SECTION_COURSES;
  10. $studentId = isset($_GET['studentId']) ? intval($_GET['studentId']) : null;
  11. if (empty($studentId)) {
  12. api_not_allowed(true);
  13. }
  14. $tool_name = get_lang('StudentPublications');
  15. $group_id = api_get_group_id();
  16. $userInfo = api_get_user_info($studentId);
  17. $courseInfo = api_get_course_info();
  18. if (empty($userInfo) || empty($courseInfo)) {
  19. api_not_allowed(true);
  20. }
  21. // Only a teachers page.
  22. if (!empty($group_id)) {
  23. $group_properties = GroupManager :: get_group_properties($group_id);
  24. $show_work = false;
  25. if (api_is_allowed_to_edit(false, true)) {
  26. $show_work = true;
  27. } else {
  28. // you are not a teacher
  29. $show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
  30. }
  31. if (!$show_work) {
  32. api_not_allowed();
  33. }
  34. $interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
  35. $interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  36. } else {
  37. if (!api_is_allowed_to_edit(false, true)) {
  38. api_not_allowed(true);
  39. }
  40. }
  41. $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
  42. $interbreadcrumb[] = array ('url' => '#', 'name' => $userInfo['complete_name']);
  43. Display :: display_header(null);
  44. echo '<div class="actions">';
  45. 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>';
  46. echo '</div>';
  47. $workPerUser = getWorkPerUser($studentId);
  48. $table = new HTML_Table(array('class' => 'data_table'));
  49. $column = 0;
  50. $row = 0;
  51. $headers = array(get_lang('Title'), get_lang('HandedOutDate'), get_lang('HandOutDateLimit'), get_lang('Score'), get_lang('Actions'));
  52. foreach ($headers as $header) {
  53. $table->setHeaderContents($row, $column, $header);
  54. $column++;
  55. }
  56. $row++;
  57. $column = 0;
  58. foreach ($workPerUser as $work) {
  59. $work = $work['work'];
  60. $scoreWeight = intval($work->qualification) == 0 ? null : $work->qualification;
  61. $workId = $work->id;
  62. $workExtraData = get_work_assignment_by_id($workId);
  63. foreach ($work->user_results as $userResult) {
  64. $table->setCellContents($row, $column, $work->title.' ['.strip_tags($userResult['title']).']');
  65. $table->setCellAttributes($row, $column, array('width' => '300px'));
  66. $column++;
  67. $table->setCellContents($row, $column, $userResult['sent_date']);
  68. $column++;
  69. $dateQualification = !empty($workExtraData['expires_on']) && $workExtraData['expires_on'] != '0000-00-00 00:00:00' ? api_get_local_time($workExtraData['expires_on']) : '-';
  70. $table->setCellContents($row, $column, $dateQualification);
  71. $column++;
  72. $score = '-';
  73. if (!empty($scoreWeight)) {
  74. $score = strip_tags($userResult['qualification'])."/".$scoreWeight;
  75. }
  76. $table->setCellContents($row, $column, $score);
  77. $column++;
  78. // Actions
  79. $links = null;
  80. // is a text
  81. $url = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$userResult['id'];
  82. $links .= Display::url(Display::return_icon('default.png'), $url);
  83. if (!empty($userResult['url'])) {
  84. $url = api_get_path(WEB_CODE_PATH).'work/download.php?'.api_get_cidreq().'&id='.$userResult['id'];
  85. $links .= Display::url(Display::return_icon('save.png', get_lang('Download')), $url);
  86. }
  87. $url = api_get_path(WEB_CODE_PATH).'work/edit.php?'.api_get_cidreq().'&item_id='.$userResult['id'].'&id='.$workId.'&parent_id='.$workId;
  88. $links .= Display::url(Display::return_icon('edit.png', get_lang('Comment')), $url);
  89. $table->setCellContents($row, $column, $links);
  90. $row++;
  91. $column = 0;
  92. }
  93. }
  94. echo $table->toHtml();
  95. Display :: display_footer();