api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('Group area').' '.$group->getTitle(),
];
} else {
if (!(api_is_allowed_to_edit() || api_is_coach())) {
api_not_allowed(true);
}
}
$action = $_GET['action'] ?? null;
switch ($action) {
case 'export_to_pdf':
exportAllWork($user, $course, 'pdf');
exit;
break;
case 'download':
if (api_is_allowed_to_edit()) {
downloadAllFilesPerUser($studentId, $courseInfo);
}
break;
case 'delete_all':
if (api_is_allowed_to_edit()) {
$deletedItems = deleteAllWorkPerUser($user, $course);
if (!empty($deletedItems)) {
$message = get_lang('File deleted').'
';
foreach ($deletedItems as $item) {
$message .= $item['title'].'
';
}
$message = Display::return_message($message, 'info', false);
Display::addFlash($message);
}
header('Location: '.api_get_self().'?studentId='.$studentId.'&'.api_get_cidreq());
exit;
}
break;
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('Assignments'),
];
$interbreadcrumb[] = [
'url' => '#',
'name' => $completeName,
];
Display::display_header(null);
$actions = ''.
Display::getMdiIcon(ActionIcon::BACK, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Back to Assignments list')).
'';
if (api_is_allowed_to_edit()) {
$actions .= ''.
Display::getMdiIcon(ActionIcon::EXPORT_PDF, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Export to PDF')).
'';
$actions .= ''.
Display::getMdiIcon(ActionIcon::SAVE_FORM, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Download')).
'';
$actions .= ''.
Display::getMdiIcon(ActionIcon::DELETE, 'ch-tool-icon', null, ICON_SIZE_MEDIUM, get_lang('Delete all papers')).
'';
}
echo Display::toolbarAction('toolbar', [$actions]);
$table = new HTML_Table(['class' => 'data_table']);
$column = 0;
$row = 0;
$headers = [
get_lang('Title'),
get_lang('Time of reception'),
get_lang('Deadline'),
get_lang('Feedback'),
get_lang('Detail'),
];
foreach ($headers as $header) {
$table->setHeaderContents($row, $column, $header);
$column++;
}
$row++;
$column = 0;
$url = api_get_path(WEB_CODE_PATH).'work/';
$repo = Container::getStudentPublicationRepository();
$works = $repo->getStudentPublicationByUser($user, $course, $session);
//$userWorks = getWorkPerUser($studentId, $courseId, $sessionId);
foreach ($works as $workData) {
/** @var CStudentPublication $work */
$work = $workData['work'];
/** @var CStudentPublication[] $results */
$results = $workData['results'];
$scoreWeight = 0 == (int) $work->getQualification() ? null : $work->getQualification();
$workId = $work->getIid();
foreach ($results as $userResult) {
$itemId = $userResult->getIid();
$table->setCellContents($row, $column, $work->getTitle().' ['.trim(strip_tags($userResult->getTitle())).']');
$table->setCellAttributes($row, $column, ['width' => '300px']);
$column++;
$table->setCellContents($row, $column, api_get_local_time($userResult->getSentDate()));
$column++;
$assignment = $work->getAssignment();
$dateQualification = !empty($assignment->getExpiresOn()) ? api_get_local_time($assignment->getExpiresOn()) : '-';
$table->setCellContents($row, $column, $dateQualification);
$column++;
$score = $userResult->getQualification();
$table->setCellContents($row, $column, $score);
$column++;
// Detail
$links = null;
// is a text
$url = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$itemId;
$links .= Display::url(Display::getMdiIcon(ObjectIcon::DEFAULT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('View')), $url);
if ($userResult->getResourceNode()->hasResourceFile()) {
$url = $repo->getResourceFileDownloadUrl($userResult).'?'.api_get_cidreq();
$links .= Display::url(Display::getMdiIcon(ActionIcon::SAVE_FORM, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Download')), $url);
}
if (api_is_allowed_to_edit()) {
$url = api_get_path(WEB_CODE_PATH).
'work/edit.php?'.api_get_cidreq().'&item_id='.$itemId.'&id='.$workId.'&parent_id='.$workId;
$links .= Display::url(
Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Comment')),
$url
);
}
$table->setCellContents($row, $column, $links);
$row++;
$column = 0;
}
}
echo Display::page_subheader($completeName);
echo $table->toHtml();
Display::display_footer();