Actualización

This commit is contained in:
Xes
2025-04-10 12:49:05 +02:00
parent 4aff98e77b
commit 1cdd00920f
9151 changed files with 1800913 additions and 0 deletions

122
main/work/add_document.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$workId = isset($_GET['id']) ? (int) $_GET['id'] : null;
$docId = isset($_GET['document_id']) ? (int) $_GET['document_id'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
if (empty($workId)) {
api_not_allowed(true);
}
$blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
if ($blockAddDocuments) {
api_not_allowed(true);
}
$my_folder_data = get_work_data_by_id($workId);
if (empty($my_folder_data)) {
api_not_allowed(true);
}
$work_data = get_work_assignment_by_id($workId);
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AddDocument')];
switch ($action) {
case 'delete':
if (!empty($workId) && !empty($docId)) {
deleteDocumentToWork($docId, $workId, api_get_course_int_id());
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('Deleted'), 'success'));
header('Location: '.$url);
exit;
}
break;
}
if (empty($docId)) {
Display::display_header(null);
$documents = getAllDocumentToWork($workId, api_get_course_int_id());
if (!empty($documents)) {
echo Display::page_subheader(get_lang('DocumentsAdded'));
echo '<div class="well">';
$urlDocument = api_get_path(WEB_CODE_PATH).'work/add_document.php';
foreach ($documents as $doc) {
$documentId = $doc['document_id'];
$docData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
if ($docData) {
$url = $urlDocument.'?action=delete&id='.$workId.'&document_id='.$documentId.'&'.api_get_cidreq();
$link = Display::url(get_lang('Remove'), $url, ['class' => 'btn btn-danger']);
echo $docData['title'].' '.$link.'<br />';
}
}
echo '</div>';
}
$documentTree = DocumentManager::get_document_preview(
$courseInfo,
false,
null,
api_get_session_id(),
false,
'/',
api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq(),
false,
true,
false,
false
);
echo Display::page_subheader(get_lang('Documents'));
echo $documentTree;
echo '<hr /><div class="clear"></div>';
} else {
$documentInfo = DocumentManager::get_document_data_by_id($docId, $courseInfo['code']);
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&document_id='.$docId.'&'.api_get_cidreq();
$form = new FormValidator('add_doc', 'post', $url);
$form->addElement('header', get_lang('AddDocument'));
$form->addElement('hidden', 'add_doc', '1');
$form->addElement('hidden', 'id', $workId);
$form->addElement('hidden', 'document_id', $docId);
$form->addElement('label', get_lang('File'), $documentInfo['title']);
$form->addButtonCreate(get_lang('Add'));
if ($form->validate()) {
$values = $form->exportValues();
$workId = $values['id'];
$docId = $values['document_id'];
$data = getDocumentToWork($docId, $workId, api_get_course_int_id());
if (empty($data)) {
addDocumentToWork($docId, $workId, api_get_course_int_id());
Display::addFlash(Display::return_message(get_lang('Added'), 'success'));
} else {
Display::addFlash(Display::return_message(get_lang('DocumentAlreadyAdded'), 'warning'));
}
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq();
header('Location: '.$url);
exit;
}
Display::display_header(null);
$form->display();
}

126
main/work/add_user.php Normal file
View File

@@ -0,0 +1,126 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
// Including necessary files
require_once 'work.lib.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$workId = isset($_GET['id']) ? (int) $_GET['id'] : null;
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
$sessionId = api_get_session_id();
if (empty($workId)) {
api_not_allowed(true);
}
$my_folder_data = get_work_data_by_id($workId);
if (empty($my_folder_data)) {
api_not_allowed(true);
}
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AddUsers')];
switch ($action) {
case 'add':
$data = getUserToWork($userId, $workId, api_get_course_int_id());
if (empty($data)) {
addUserToWork($userId, $workId, api_get_course_int_id());
}
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId.'&'.api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('Added')));
header('Location: '.$url);
exit;
break;
case 'delete':
if (!empty($workId) && !empty($userId)) {
deleteUserToWork($userId, $workId, api_get_course_int_id());
Display::addFlash(Display::return_message(get_lang('Deleted')));
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId.'&'.api_get_cidreq();
header('Location: '.$url);
exit;
}
break;
}
Display::display_header(null);
$items = getAllUserToWork($workId, api_get_course_int_id());
$usersAdded = [];
if (!empty($items)) {
echo Display::page_subheader(get_lang('UsersAdded'));
echo '<ul class="list-group">';
foreach ($items as $data) {
$myUserId = $data['user_id'];
$usersAdded[] = $myUserId;
$userInfo = api_get_user_info($myUserId);
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=delete&id='.$workId.'&user_id='.$myUserId;
$link = Display::url(
'<em class="fa fa-trash"></em> '.get_lang('Delete'),
$url,
['class' => 'btn btn-danger btn-sm']
);
echo '<li class="list-group-item">'.
$userInfo['complete_name_with_username'].'<div class="pull-right">'.$link.'</div></li>';
}
echo '</ul>';
}
$status = 0;
if (empty($sessionId)) {
$status = STUDENT;
}
$userList = CourseManager::get_user_list_from_course_code(
$courseInfo['code'],
$sessionId,
null,
null,
$status
);
$userToAddList = [];
foreach ($userList as $user) {
if (!in_array($user['user_id'], $usersAdded)) {
$userToAddList[] = $user;
}
}
if (!empty($userToAddList)) {
echo Display::page_subheader(get_lang('UsersToAdd'));
echo '<ul class="list-group">';
foreach ($userToAddList as $user) {
$userName = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') ';
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=add&id='.$workId.'&user_id='.$user['user_id'];
$link = Display::url(
'<em class="fa fa-plus"></em> '.get_lang('Add'),
$url,
['class' => 'btn btn-primary btn-sm']
);
echo '<li class="list-group-item">'.$userName.'<div class="pull-right"> '.$link.'</div></li>';
}
echo '</ul>';
} else {
echo Display::return_message(get_lang('NoUsersToAdd'), 'warning');
}
echo '<hr /><div class="clear"></div>';
Display::display_footer();

34
main/work/download.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package chamilo.work
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$this_section = SECTION_COURSES;
// Course protection
api_protect_course_script(true);
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$courseInfo = api_get_course_info();
if (empty($courseInfo) || empty($id)) {
api_not_allowed(true);
}
$correction = isset($_REQUEST['correction']) ? true : false;
$result = downloadFile($id, $courseInfo, $correction);
if ($result === false) {
api_not_allowed(true);
}
exit;

View File

@@ -0,0 +1,67 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
api_protect_course_script(true);
$commentId = isset($_GET['comment_id']) ? (int) $_GET['comment_id'] : null;
if (empty($commentId)) {
api_not_allowed(true);
}
$workData = getWorkComment($commentId);
$courseInfo = api_get_course_info();
if (empty($workData)) {
api_not_allowed(true);
}
if (empty($workData['file_path']) ||
(isset($workData['file_path']) && !file_exists($workData['file_path']))
) {
api_not_allowed(true);
}
$work = get_work_data_by_id($workData['work_id']);
protectWork($courseInfo, $work['parent_id']);
$userHasAccess = api_is_coach() ||
api_is_allowed_to_edit(false, false, true) ||
user_is_author($workData['work_id']);
$allowBaseCourseTeacher = api_get_configuration_value('assignment_base_course_teacher_access_to_all_session');
if (false === $userHasAccess && $allowBaseCourseTeacher) {
// Check if user is base course teacher.
if (CourseManager::is_course_teacher(api_get_user_id(), $courseInfo['code'])) {
$userHasAccess = true;
}
}
if ($userHasAccess ||
$courseInfo['show_score'] == 0 &&
$work['active'] == 1 &&
$work['accepted'] == 1
) {
if (Security::check_abs_path(
$workData['file_path'],
api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'
)
) {
DocumentManager::file_send_for_download(
$workData['file_path'],
true,
$workData['file_name_to_show']
);
}
} else {
api_not_allowed(true);
}

View File

@@ -0,0 +1,239 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Functions and main code for the download folder feature.
*
* @todo use ids instead of the path like the document tool
*
* @package chamilo.work
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
$workId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$current_course_tool = TOOL_STUDENTPUBLICATION;
$_course = api_get_course_info();
if (empty($_course)) {
api_not_allowed();
}
require_once 'work.lib.php';
$work_data = get_work_data_by_id($workId);
$groupId = api_get_group_id();
if (empty($work_data)) {
api_not_allowed();
}
// Prevent some stuff.
if (empty($path)) {
$path = '/';
}
if (empty($_course) || empty($_course['path'])) {
api_not_allowed();
}
$sys_course_path = api_get_path(SYS_COURSE_PATH);
// Creating a ZIP file
$temp_zip_file = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().'.zip';
$zip_folder = new PclZip($temp_zip_file);
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$prop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
// Put the files in the zip
// 2 possibilities: admins get all files and folders in the selected folder (except for the deleted ones)
// normal users get only visible files that are in visible folders
//admins are allowed to download invisible files
$files = [];
$course_id = api_get_course_int_id();
$sessionId = api_get_session_id();
$sessionCondition = api_get_session_condition($sessionId, true, false, 'props.session_id');
$filenameCondition = null;
if (array_key_exists('filename', $work_data)) {
$filenameCondition = ", filename";
}
$groupIid = 0;
if ($groupId) {
$groupInfo = GroupManager::get_group_properties($groupId);
$groupIid = $groupInfo['iid'];
}
if (api_is_allowed_to_edit() || api_is_coach()) {
//Search for all files that are not deleted => visibility != 2
$sql = "SELECT DISTINCT
url,
title,
description,
insert_user_id,
sent_date,
contains_file
$filenameCondition
FROM $tbl_student_publication AS work
INNER JOIN $prop_table AS props
ON (work.id = props.ref AND props.c_id = work.c_id)
INNER JOIN $tableUser as u
ON (
work.user_id = u.user_id
)
WHERE
props.tool = 'work' AND
props.c_id = $course_id AND
work.c_id = $course_id AND
work.parent_id = $workId AND
work.filetype = 'file' AND
props.visibility <> '2' AND
work.active IN (0, 1) AND
work.post_group_id = $groupIid
$sessionCondition
";
} else {
$courseInfo = api_get_course_info();
protectWork($courseInfo, $workId);
$userCondition = '';
// All users
if ($courseInfo['show_score'] == 0) {
// Do another filter
} else {
// Only teachers
$userCondition = " AND props.insert_user_id = ".api_get_user_id();
}
//for other users, we need to create a zipfile with only visible files and folders
$sql = "SELECT DISTINCT
url,
title,
description,
insert_user_id,
sent_date,
contains_file
$filenameCondition
FROM $tbl_student_publication AS work
INNER JOIN $prop_table AS props
ON (
props.c_id = work.c_id AND
work.id = props.ref
)
WHERE
props.c_id = $course_id AND
work.c_id = $course_id AND
props.tool = 'work' AND
work.accepted = 1 AND
work.active = 1 AND
work.parent_id = $workId AND
work.filetype = 'file' AND
props.visibility = '1' AND
work.post_group_id = $groupIid
$userCondition
";
}
$query = Database::query($sql);
//add tem to the zip file
while ($not_deleted_file = Database::fetch_assoc($query)) {
$userInfo = api_get_user_info($not_deleted_file['insert_user_id']);
$insert_date = api_get_local_time($not_deleted_file['sent_date']);
$insert_date = str_replace([':', '-', ' '], '_', $insert_date);
$title = basename($not_deleted_file['title']);
if (!empty($filenameCondition)) {
if (isset($not_deleted_file['filename']) && !empty($not_deleted_file['filename'])) {
$title = $not_deleted_file['filename'];
}
}
$filename = $insert_date.'_'.$userInfo['username'].'_'.$title;
$filename = api_replace_dangerous_char($filename);
// File exists
if (file_exists($sys_course_path.$_course['path'].'/'.$not_deleted_file['url']) &&
!empty($not_deleted_file['url'])
) {
$files[basename($not_deleted_file['url'])] = $filename;
$addStatus = $zip_folder->add(
$sys_course_path.$_course['path'].'/'.$not_deleted_file['url'],
PCLZIP_OPT_REMOVE_PATH,
$sys_course_path.$_course['path'].'/work',
PCLZIP_CB_PRE_ADD,
'my_pre_add_callback'
);
} else {
// Convert texts in html files
$filename = trim($filename).".html";
$work_temp = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().'_'.$filename;
file_put_contents($work_temp, $not_deleted_file['description']);
$files[basename($work_temp)] = $filename;
$addStatus = $zip_folder->add(
$work_temp,
PCLZIP_OPT_REMOVE_PATH,
api_get_path(SYS_ARCHIVE_PATH),
PCLZIP_CB_PRE_ADD,
'my_pre_add_callback'
);
@unlink($work_temp);
}
}
if (!empty($files)) {
$fileName = api_replace_dangerous_char($work_data['title']);
// Logging
Event::event_download($fileName.'.zip (folder)');
//start download of created file
$name = $fileName.'.zip';
if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
DocumentManager::file_send_for_download($temp_zip_file, true, $name);
@unlink($temp_zip_file);
exit;
}
} else {
exit;
}
/* Extra function (only used here) */
function my_pre_add_callback($p_event, &$p_header)
{
global $files;
if (isset($files[basename($p_header['stored_filename'])])) {
$p_header['stored_filename'] = $files[basename($p_header['stored_filename'])];
return 1;
}
return 0;
}
/**
* Return the difference between two arrays, as an array of those key/values
* Use this as array_diff doesn't give the.
*
* @param array $arr1 first array
* @param array $arr2 second array
*
* @return array difference between the two arrays
*/
function diff($arr1, $arr2)
{
$res = [];
$r = 0;
foreach ($arr1 as $av) {
if (!in_array($av, $arr2)) {
$res[$r] = $av;
$r++;
}
}
return $res;
}

325
main/work/edit.php Normal file
View File

@@ -0,0 +1,325 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
api_not_allowed(true);
}
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$work_id = isset($_REQUEST['id']) ? (int) ($_REQUEST['id']) : null;
$item_id = isset($_REQUEST['item_id']) ? (int) ($_REQUEST['item_id']) : null;
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$session_id = api_get_session_id();
$courseInfo = api_get_course_info();
if (empty($work_id) || empty($item_id)) {
api_not_allowed(true);
}
$parent_data = $my_folder_data = get_work_data_by_id($work_id);
if (empty($parent_data)) {
api_not_allowed(true);
}
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$user_id,
$course_id,
$session_id
);
$is_course_member = $is_course_member || api_is_platform_admin();
$allowBaseCourseTeacher = api_get_configuration_value('assignment_base_course_teacher_access_to_all_session');
$isCourseTeacher = false;
$redirectToSelf = false;
if (false === $is_course_member && $allowBaseCourseTeacher) {
// Check if user is base course teacher.
if (CourseManager::is_course_teacher(api_get_user_id(), $courseInfo['code'])) {
$is_course_member = true;
$isCourseTeacher = true;
$redirectToSelf = true;
}
}
if (false == $is_course_member) {
api_not_allowed(true);
}
$is_allowed_to_edit = api_is_allowed_to_edit() || $isCourseTeacher;
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true) || $isCourseTeacher;
$check = Security::check_token('post');
$token = Security::get_token();
$has_ended = false;
$work_item = get_work_data_by_id($item_id);
// Get the author ID for that document from the item_property table
$is_author = user_is_author($item_id) || $isCourseTeacher;
if (!$is_author) {
api_not_allowed(true);
}
// Student's can't edit work only if he can delete his docs.
if (!api_is_allowed_to_edit() && false === $isCourseTeacher) {
if (api_get_course_setting('student_delete_own_publication') != 1) {
api_not_allowed(true);
}
}
if (!empty($my_folder_data)) {
$homework = get_work_assignment_by_id($my_folder_data['id']);
if (!empty($homework['expires_on']) || !empty($homework['ends_on'])) {
$time_now = time();
if (!empty($homework['expires_on'])) {
$time_expires = api_strtotime($homework['expires_on'], 'UTC');
$difference = $time_expires - $time_now;
if ($difference < 0) {
$has_expired = true;
}
}
if (empty($homework['expires_on'])) {
$has_expired = false;
}
if (!empty($homework['ends_on'])) {
$time_ends = api_strtotime($homework['ends_on'], 'UTC');
$difference2 = $time_ends - $time_now;
if ($difference2 < 0) {
$has_ended = true;
}
}
$ends_on = api_convert_and_format_date($homework['ends_on']);
$expires_on = api_convert_and_format_date($homework['expires_on']);
}
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
if (api_is_allowed_to_edit()) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$work_id,
'name' => $parent_data['title'],
];
} else {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$work_id,
'name' => $parent_data['title'],
];
}
$form_title = get_lang('Edit');
$interbreadcrumb[] = ['url' => '#', 'name' => $form_title];
$form = new FormValidator(
'form',
'POST',
api_get_self().'?'.api_get_cidreq().'&id='.$work_id,
'',
['enctype' => 'multipart/form-data']
);
$form->addElement('header', $form_title);
$show_progress_bar = false;
$form->addElement('hidden', 'id', $work_id);
$form->addElement('hidden', 'item_id', $item_id);
$form->addText('title', get_lang('Title'), true, ['id' => 'file_upload']);
if ($is_allowed_to_edit && !empty($item_id)) {
$sql = "SELECT contains_file, url
FROM $work_table
WHERE c_id = $course_id AND id ='$item_id' ";
$result = Database::query($sql);
if ($result !== false && Database::num_rows($result) > 0) {
$row = Database::fetch_array($result);
if ($row['contains_file'] || !empty($row['url'])) {
$form->addLabel(
get_lang('Download'),
'<a href="'.api_get_path(WEB_CODE_PATH).'work/download.php?id='.$item_id.'&'.api_get_cidreq().'">'.
Display::return_icon('save.png', get_lang('Save'), [], ICON_SIZE_MEDIUM).'
</a>'
);
}
}
}
$form->addHtmlEditor(
'description',
get_lang('Description'),
false,
false,
getWorkDescriptionToolbar()
);
$defaults['title'] = $work_item['title'];
$defaults["description"] = $work_item['description'];
$defaults['qualification'] = $work_item['qualification'];
if ($is_allowed_to_edit && !empty($item_id)) {
// Get qualification from parent_id that will allow the validation qualification over
/*$sql = "SELECT qualification FROM $work_table
WHERE c_id = $course_id AND id ='$work_id' ";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$qualification_over = $row['qualification'];
if (!empty($qualification_over) && intval($qualification_over) > 0) {
$form->addText('qualification', array(get_lang('Qualification'), " / ".$qualification_over), false, 'size="10"');
$form->addElement('hidden', 'qualification_over', $qualification_over);
}*/
$form->addCheckBox(
'send_email',
null,
get_lang('SendMailToStudent')
);
// Check if user to qualify has some DRHs
$drhList = UserManager::getDrhListFromUser($work_item['user_id']);
if (!empty($drhList)) {
$form->addCheckBox(
'send_to_drh_users',
null,
get_lang('SendMailToHR')
);
}
}
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
$form->addElement('hidden', 'item_to_edit', $item_id);
$form->addElement('hidden', 'sec_token', $token);
$text = get_lang('UpdateWork');
$class = 'save';
// fix the Ok button when we see the tool in the learn path
$form->addButtonUpdate($text);
$form->setDefaults($defaults);
$_course = api_get_course_info();
$currentCourseRepositorySys = api_get_path(SYS_COURSE_PATH).$_course['path'].'/';
$succeed = false;
if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
/*
* SPECIAL CASE ! For a work edited
*/
//Get the author ID for that document from the item_property table
$item_to_edit_id = (int) ($_POST['item_to_edit']);
$is_author = user_is_author($item_to_edit_id) || $isCourseTeacher;
if ($is_author) {
$work_data = get_work_data_by_id($item_to_edit_id);
if (!empty($_POST['title'])) {
$title = isset($_POST['title']) ? $_POST['title'] : $work_data['title'];
}
$description = isset($_POST['description']) ? $_POST['description'] : $work_data['description'];
$add_to_update = null;
if ($is_allowed_to_edit && ($_POST['qualification'] != '')) {
if (isset($_POST['send_email'])) {
$url = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$item_to_edit_id;
$subject = sprintf(get_lang('ThereIsANewWorkFeedback'), $work_item['title']);
$message = sprintf(get_lang('ThereIsANewWorkFeedbackInWorkXHere'), $work_item['title'], $url);
MessageManager::send_message_simple(
$work_item['user_id'],
$subject,
$message,
api_get_user_id(),
isset($_POST['send_to_drh_users'])
);
}
}
if ($_POST['qualification'] > $_POST['qualification_over']) {
Display::addFlash(Display::return_message(
get_lang('QualificationMustNotBeMoreThanQualificationOver'),
'error'
));
} else {
$sql = "UPDATE ".$work_table."
SET title = '".Database::escape_string($title)."',
description = '".Database::escape_string($description)."'
".$add_to_update."
WHERE c_id = $course_id AND id = $item_to_edit_id";
Database::query($sql);
}
api_item_property_update(
$_course,
'work',
$item_to_edit_id,
'DocumentUpdated',
$user_id
);
$succeed = true;
Display::addFlash(Display::return_message(get_lang('ItemUpdated')));
}
Security::clear_token();
} else {
// Bad token or can't add works
Display::addFlash(Display::return_message(get_lang('ImpossibleToSaveTheDocument'), 'error'));
}
$script = 'work_list.php';
if ($is_allowed_to_edit) {
$script = 'work_list_all.php';
}
if ($redirectToSelf) {
api_location(
api_get_path(WEB_CODE_PATH).'work/edit.php?'.api_get_cidreq().'&id='.$work_id.'&item_id='.$item_id
);
}
api_location(api_get_path(WEB_CODE_PATH).'work/'.$script.'?'.api_get_cidreq().'&id='.$work_id);
}
$htmlHeadXtra[] = to_javascript_work();
$tpl = new Template();
$content = null;
if (!empty($work_id)) {
if ($is_allowed_to_edit) {
if (api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION)) {
echo Display::return_message(get_lang('ResourceLockedByGradebook'), 'warning');
} else {
$content .= $form->returnForm();
}
} elseif ($is_author) {
if (empty($work_item['qualificator_id']) || $work_item['qualificator_id'] == 0) {
$content .= $form->returnForm();
} else {
$content .= Display::return_message(get_lang('ActionNotAllowed'), 'error');
}
} elseif ($student_can_edit_in_session && $has_ended == false) {
$content .= $form->returnForm();
} else {
$content .= Display::return_message(get_lang('ActionNotAllowed'), 'error');
}
} else {
$content .= Display::return_message(get_lang('ActionNotAllowed'), 'error');
}
$tpl->assign('content', $content);
$tpl->display_one_col_template();

145
main/work/edit_work.php Normal file
View File

@@ -0,0 +1,145 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
$lib_path = api_get_path(LIBRARY_PATH);
/* Libraries */
require_once 'work.lib.php';
// Section (for the tabs)
$this_section = SECTION_COURSES;
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$workId = isset($_GET['id']) ? (int) ($_GET['id']) : null;
$workData = get_work_data_by_id($workId);
$homework = get_work_assignment_by_id($workId);
$locked = api_resource_is_locked_by_gradebook($workId, LINK_STUDENTPUBLICATION);
if (false == api_is_platform_admin() && true == $locked) {
api_not_allowed(true);
}
$htmlHeadXtra[] = to_javascript_work();
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')];
$form = new FormValidator(
'edit_dir',
'post',
api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq()
);
$form->addElement('header', get_lang('Edit'));
$title = !empty($workData['title']) ? $workData['title'] : basename($workData['url']);
$defaults = $workData;
$defaults['new_dir'] = Security::remove_XSS($title);
$there_is_a_end_date = false;
if (Gradebook::is_active()) {
$link_info = GradebookUtils::isResourceInCourseGradebook(
api_get_course_id(),
LINK_STUDENTPUBLICATION,
$workId
);
if (!empty($link_info)) {
$defaults['weight'] = $link_info['weight'];
$defaults['category_id'] = $link_info['category_id'];
$defaults['make_calification'] = 1;
}
} else {
$defaults['category_id'] = '';
}
if (!empty($homework['expires_on'])) {
$homework['expires_on'] = api_get_local_time($homework['expires_on']);
$defaults['enableExpiryDate'] = true;
$defaults['expires_on'] = $homework['expires_on'];
} else {
$homework['expires_on'] = null;
}
if (!empty($homework['ends_on'])) {
$homework['ends_on'] = api_get_local_time($homework['ends_on']);
$defaults['ends_on'] = $homework['ends_on'];
$defaults['enableEndDate'] = true;
} else {
$homework['ends_on'] = null;
$defaults['enableEndDate'] = false;
$defaults['ends_on'] = null;
}
$defaults['add_to_calendar'] = isset($homework['add_to_calendar']) ? $homework['add_to_calendar'] : null;
$form = getFormWork($form, $defaults, $workId);
$form->addElement('hidden', 'work_id', $workId);
$form->addButtonUpdate(get_lang('ModifyDirectory'));
$currentUrl = api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq();
if ($form->validate()) {
$params = $form->getSubmitValues();
$params['enableEndDate'] = isset($params['enableEndDate']) ? true : false;
$params['enableExpiryDate'] = isset($params['enableExpiryDate']) ? true : false;
if ($params['enableExpiryDate'] &&
$params['enableEndDate']
) {
if ($params['expires_on'] > $params['ends_on']) {
Display::addFlash(
Display::return_message(
get_lang('DateExpiredNotBeLessDeadLine'),
'warning'
)
);
header('Location: '.$currentUrl);
exit;
}
}
$workId = $params['work_id'];
$editCheck = false;
$workData = get_work_data_by_id($workId);
if (!empty($workData)) {
$editCheck = true;
} else {
$editCheck = true;
}
if ($editCheck) {
updateWork($workData['iid'], $params, $courseInfo, $sessionId);
updatePublicationAssignment($workId, $params, $courseInfo, $groupId);
updateDirName($workData, $params['new_dir']);
Skill::saveSkills($form, ITEM_TYPE_STUDENT_PUBLICATION, $workData['iid']);
Display::addFlash(Display::return_message(get_lang('Updated'), 'success'));
header('Location: '.$currentUrl);
exit;
} else {
Display::addFlash(Display::return_message(get_lang('FileExists'), 'warning'));
}
}
Display::display_header();
$form->display();
Display::display_footer();

7
main/work/index.html Normal file
View File

@@ -0,0 +1,7 @@
<html>
<head>
<meta http-equiv="refresh" content="0; url=work.php">
</head>
<body>
</body>
</html>

312
main/work/pending.php Normal file
View File

@@ -0,0 +1,312 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
// Only teachers.
if (false === api_is_teacher()) {
api_not_allowed(true);
}
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
$group_id = api_get_group_id();
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$htmlHeadXtra[] = api_get_jqgrid_js();
$userId = api_get_user_id();
/*$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];*/
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$itemId = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null;
$exportXls = isset($_REQUEST['export_xls']) && !empty($_REQUEST['export_xls']) ? (int) $_REQUEST['export_xls'] : 0;
$htmlHeadXtra[] = api_get_jquery_libraries_js(['jquery-upload']);
$plagiarismListJqgridColumn = [];
$plagiarismListJqgridLine = [];
/*$allowAntiPlagiarism = api_get_configuration_value('allow_compilatio_tool');
if ($allowAntiPlagiarism) {
$plagiarismListJqgridColumn = ['Compilatio'];
$plagiarismListJqgridLine = [
[
'name' => 'compilatio',
'index' => 'compilatio',
'width' => '40',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
];
}*/
$orderName = api_is_western_name_order() ? 'firstname' : 'lastname';
$type = 'simple';
$columns = [
get_lang('Course'),
get_lang('WorkName'),
get_lang('FullUserName'),
get_lang('Title'),
get_lang('Score'),
get_lang('Date'),
get_lang('Status'),
get_lang('Corrector'),
get_lang('CorrectionDate'),
get_lang('UploadCorrection'),
];
$columns = array_merge($columns, $plagiarismListJqgridColumn);
$columns[] = get_lang('Actions');
$column_model = [
[
'name' => 'course',
'index' => 'course',
'width' => '30',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
[
'name' => 'work_name',
'index' => 'work_name',
'width' => '30',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
[
'name' => 'fullname',
'index' => $orderName,
'width' => '30',
'align' => 'left',
'search' => 'true',
'sortable' => 'true',
],
[
'name' => 'title',
'index' => 'title',
'width' => '25',
'align' => 'left',
'search' => 'false',
'wrap_cell' => 'true',
'sortable' => 'false',
],
[
'name' => 'qualification',
'index' => 'qualification',
'width' => '15',
'align' => 'center',
'search' => 'true',
],
[
'name' => 'sent_date',
'index' => 'sent_date',
'width' => '25',
'align' => 'left',
'search' => 'true',
'wrap_cell' => 'true',
],
[
'name' => 'qualificator_id',
'index' => 'qualificator_id',
'width' => '20',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'qualificator_fullname',
'index' => 'qualificator_fullname',
'width' => '20',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'date_of_qualification',
'index' => 'date_of_qualification',
'width' => '20',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'correction',
'index' => 'correction',
'width' => '30',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
'title' => 'false',
],
];
$column_model = array_merge($column_model, $plagiarismListJqgridLine);
$column_model[] = [
'name' => 'actions',
'index' => 'actions',
'width' => '25',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
];
$extra_params = [
'autowidth' => 'true',
'height' => 'auto',
'sortname' => 'sent_date',
'sortorder' => 'desc',
'sortable' => 'false',
'multiselect' => 'false',
];
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_pending_list&type='.$type;
$deleteUrl = null;
/*$workUrl = api_get_path(WEB_AJAX_PATH).'work.ajax.php?';
$deleteUrl = $workUrl.'&a=delete_student_work';
$showUrl = $workUrl.'&a=show_student_work';
$hideUrl = $workUrl.'&a=hide_student_work';*/
/*if ($allowAntiPlagiarism) {
$extra_params['gridComplete'] = 'compilatioInit()';
}*/
$courses = CourseManager::get_courses_list_by_user_id($userId, false, false, false);
$content = '';
if (!empty($courses)) {
$form = new FormValidator('pending', 'POST');
$courses = array_column($courses, 'title', 'real_id');
$selectCourse = $form->addSelect('course', get_lang('Course'), $courses, ['placeholder' => get_lang('All')]);
$courseId = 0;
if (isset($_REQUEST['course'])) {
$courseId = (int) $_REQUEST['course'];
$selectCourse->setSelected($courseId);
}
$status = [
1 => get_lang('All'),
2 => get_lang('NotRevised'),
3 => get_lang('Revised'),
];
$form->addSelect('status', get_lang('Status'), $status);
$allWork = getAllWork(
null,
null,
null,
null,
'',
false,
$courseId,
0,
true,
false
);
$selectWork = $form->addSelect(
'work_parent_ids',
get_lang('Works'),
[],
['placeholder' => get_lang('SelectAnOption'), 'id' => 'search-works', 'multiple' => true]
);
if (count($allWork) > 0) {
foreach ($allWork as $work) {
$selectWork->addOption(
$work['title'],
$work['id']
);
}
}
$form->addButtonSearch(get_lang('Search'), 'pendingSubmit');
$content .= $form->returnForm();
$tableWork = Display::grid_html('results');
$content .= Display::panel($tableWork);
if ($form->validate()) {
$values = $form->getSubmitValues();
$courseId = $values['course'] ?? 0;
if (!empty($courseId)) {
$url .= '&course='.(int) $courseId;
}
$status = $values['status'] ?? 0;
if (!empty($status)) {
$url .= '&status='.(int) $status;
}
if (!empty($values['work_parent_ids'])) {
$url .= '&work_parent_ids='.Security::remove_XSS(implode(',', $values['work_parent_ids']));
}
if ($exportXls) {
exportPendingWorksToExcel($values);
}
}
} else {
$content .= Display::return_message(get_lang('NoCoursesForThisUser'), 'warning');
}
$htmlHeadXtra[] = '<script>
$(function() {
$("#export-xls").bind("click", function(e) {
e.preventDefault();
var input = $("<input>", {
type: "hidden",
name: "export_xls",
value: "1"
});
$("#pending").append(input);
$("#pending").submit();
});
$("#pending_pendingSubmit").bind("click", function(e) {
e.preventDefault();
if ($("input[name=\"export_xls\"]").length > 0) {
$("input[name=\"export_xls\"]").remove();
}
$("#pending").submit();
});
});
</script>';
Display::display_header(get_lang('StudentPublications'));
?>
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
$("#results").jqGrid(
"navGrid",
"#results_pager",
{ edit: false, add: false, search: false, del: false },
{ height:280, reloadAfterSubmit:false }, // edit options
{ height:280, reloadAfterSubmit:false }, // add options
{ reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
{ width:500 } // search options
);
$("select[name=\'course\']").bind('change', function () {
$("#search-works").val(0);
$("#pending_pendingSubmit").trigger("click");
$("#pending_pendingSubmit").attr("disabled", true);
});
});
</script>
<?php
$actions = '';
$actions .= Display::url(
Display::return_icon('excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
'#',
['id' => 'export-xls']
);
echo Display::div($actions, ['class' => 'actions']);
echo Display::page_header(get_lang('StudentPublicationToCorrect'));
echo Display::return_message(get_lang('StudentPublicationCorrectionWarning'), 'warning');
echo $content;
Display::display_footer();

View File

@@ -0,0 +1,25 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
if (false === api_get_configuration_value('allow_my_student_publication_page')) {
api_not_allowed(true);
}
api_block_anonymous_users();
$htmlHeadXtra[] = api_get_jqgrid_js();
$tpl = new Template(get_lang('StudentPublications'));
$tpl->assign('intro_title', get_lang('MyStudentPublicationsTitle'));
$tpl->assign('intro_content', Display::return_message(get_lang('MyStudentPublicationsExplanation')));
$tpl->assign('table', showStudentAllWorkGrid(0));
$tpl->assign('table_with_results', showStudentAllWorkGrid(1));
$tpl->display($tpl->get_template('work/publications.tpl'));

30
main/work/show_file.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$this_section = SECTION_COURSES;
// Course protection
api_protect_course_script(true);
$id = (int) ($_GET['id']);
$course_info = api_get_course_info();
if (empty($course_info)) {
api_not_allowed(true);
}
$result = getFile($id, $course_info, false);
if (false == $result) {
api_not_allowed();
}

177
main/work/student_work.php Normal file
View File

@@ -0,0 +1,177 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
api_protect_course_group(GroupManager::GROUP_TOOL_WORK);
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$studentId = isset($_GET['studentId']) ? (int) ($_GET['studentId']) : null;
if (empty($studentId)) {
api_not_allowed(true);
}
$tool_name = get_lang('StudentPublications');
$group_id = api_get_group_id();
$userInfo = api_get_user_info($studentId);
$courseInfo = api_get_course_info();
if (empty($userInfo) || empty($courseInfo)) {
api_not_allowed(true);
}
// Only a teachers page.
if (!empty($group_id)) {
$group_properties = GroupManager::get_group_properties($group_id);
$interbreadcrumb[] = [
'url' => 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('GroupSpace').' '.$group_properties['name'],
];
} else {
if (!(api_is_allowed_to_edit() || api_is_coach())) {
api_not_allowed(true);
}
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
case 'export_to_pdf':
exportAllWork($studentId, $courseInfo, '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($studentId, $courseInfo);
if (!empty($deletedItems)) {
$message = get_lang('DocDel').'<br >';
foreach ($deletedItems as $item) {
$message .= $item['title'].'<br />';
}
$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('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => '#',
'name' => $userInfo['complete_name'],
];
Display::display_header(null);
$workPerUser = getWorkPerUser($studentId);
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_edit()) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/student_work.php?action=export_to_pdf&studentId='.$studentId.'&'.api_get_cidreq().'">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/student_work.php?action=download&studentId='.$studentId.'&'.api_get_cidreq().'">'.
Display::return_icon('save.png', get_lang('Download'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a
onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;"
href="'.api_get_path(WEB_CODE_PATH).'work/student_work.php?action=delete_all&studentId='.$studentId.'&'.api_get_cidreq().'">'.
Display::return_icon('delete.png', get_lang('DeleteAllFiles'), '', ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
$column = 0;
$row = 0;
$headers = [
get_lang('Title'),
get_lang('HandedOutDate'),
get_lang('HandOutDateLimit'),
get_lang('Feedback'),
get_lang('Actions'),
];
foreach ($headers as $header) {
$table->setHeaderContents($row, $column, $header);
$column++;
}
$row++;
$column = 0;
$url = api_get_path(WEB_CODE_PATH).'work/';
foreach ($workPerUser as $work) {
$work = $work['work'];
$scoreWeight = intval($work->qualification) == 0 ? null : $work->qualification;
$workId = $work->id;
$workExtraData = get_work_assignment_by_id($workId);
foreach ($work->user_results as $userResult) {
$itemId = $userResult['id'];
$table->setCellContents($row, $column, $work->title.' ['.trim(strip_tags($userResult['title'])).']');
$table->setCellAttributes($row, $column, ['width' => '300px']);
$column++;
$table->setCellContents($row, $column, $userResult['sent_date']);
$column++;
$dateQualification = !empty($workExtraData['expires_on']) ? api_get_local_time($workExtraData['expires_on']) : '-';
$table->setCellContents($row, $column, $dateQualification);
$column++;
$score = null;
$score = $userResult['qualification'];
$table->setCellContents($row, $column, $score);
$column++;
// Actions
$links = null;
// is a text
$url = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$itemId;
$links .= Display::url(Display::return_icon('default.png', get_lang('View')), $url);
if (!empty($userResult['url'])) {
$url = api_get_path(WEB_CODE_PATH).'work/download.php?'.api_get_cidreq().'&id='.$itemId;
$links .= Display::url(Display::return_icon('save.png', 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::return_icon('edit.png', get_lang('Comment')),
$url
);
}
$table->setCellContents($row, $column, $links);
$row++;
$column = 0;
}
}
echo Display::page_subheader($userInfo['complete_name']);
echo $table->toHtml();
Display::display_footer();

166
main/work/upload.php Normal file
View File

@@ -0,0 +1,166 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
// Including necessary files
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$work_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
$is_allowed_to_edit = api_is_allowed_to_edit();
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$userInfo = api_get_user_info();
$session_id = api_get_session_id();
$course_info = api_get_course_info();
$course_code = $course_info['code'];
$group_id = api_get_group_id();
if (empty($work_id)) {
api_not_allowed(true);
}
protectWork($course_info, $work_id);
$workInfo = get_work_data_by_id($work_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$user_id,
$course_id,
$session_id
);
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false || api_is_invitee()) {
api_not_allowed(true);
}
$check = Security::check_token('post');
$token = Security::get_token();
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
if ($onlyOnePublication) {
$count = get_work_count_by_student($user_id, $work_id);
if ($count >= 1) {
api_not_allowed(true);
}
}
$homework = get_work_assignment_by_id($workInfo['id']);
$validationStatus = getWorkDateValidationStatus($homework);
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$work_id,
'name' => $workInfo['title'],
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UploadADocument')];
$form = new FormValidator(
'form-work',
'POST',
api_get_self().'?'.api_get_cidreq().'&id='.$work_id,
'',
['enctype' => 'multipart/form-data']
);
setWorkUploadForm($form, $workInfo['allow_text_assignment']);
$form->addHidden('id', $work_id);
$form->addHidden('sec_token', $token);
$allowRedirect = api_get_configuration_value('allow_redirect_to_main_page_after_work_upload');
$urlToRedirect = '';
if ($allowRedirect) {
$urlToRedirect = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
}
$succeed = false;
if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
$values = $form->getSubmitValues();
// Process work
$result = processWorkForm(
$workInfo,
$values,
$course_info,
$session_id,
$group_id,
$user_id,
$_FILES['file'],
api_get_configuration_value('assignment_prevent_duplicate_upload')
);
if ($allowRedirect) {
header('Location: '.$urlToRedirect);
exit;
}
$script = 'work_list.php';
if ($is_allowed_to_edit) {
$script = 'work_list_all.php';
}
header('Location: '.api_get_path(WEB_CODE_PATH).'work/'.$script.'?'.api_get_cidreq().'&id='.$work_id);
exit;
} else {
// Bad token or can't add works
Display::addFlash(
Display::return_message(get_lang('ImpossibleToSaveTheDocument'), 'error')
);
}
}
$url = api_get_path(WEB_AJAX_PATH).'work.ajax.php?'.api_get_cidreq().'&a=upload_file&id='.$work_id;
$htmlHeadXtra[] = api_get_jquery_libraries_js(['jquery-ui', 'jquery-upload']);
$htmlHeadXtra[] = to_javascript_work();
Display::display_header(null);
// Only text
if (1 == $workInfo['allow_text_assignment']) {
$tabs = $form->returnForm();
} else {
$headers = [
get_lang('Upload'),
get_lang('Upload').' ('.get_lang('Simple').')',
];
$multipleForm = new FormValidator('post');
$multipleForm->addMultipleUpload($url, $urlToRedirect);
$tabs = Display::tabs(
$headers,
[$multipleForm->returnForm(), $form->returnForm()],
'tabs'
);
}
if (!empty($work_id)) {
echo $validationStatus['message'];
if ($is_allowed_to_edit) {
if (api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION)) {
echo Display::return_message(get_lang('ResourceLockedByGradebook'), 'warning');
} else {
echo $tabs;
}
} elseif ($student_can_edit_in_session && $validationStatus['has_ended'] == false) {
echo $tabs;
} else {
Display::addFlash(Display::return_message(get_lang('ActionNotAllowed'), 'error'));
}
} else {
Display::addFlash(Display::return_message(get_lang('ActionNotAllowed'), 'error'));
}
Display::display_footer();

View File

@@ -0,0 +1,214 @@
<?php
/* For licensing terms, see /license.txt */
use Symfony\Component\Finder\Finder;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
// Including necessary files
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$workId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$is_allowed_to_edit = api_is_allowed_to_edit();
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$userInfo = api_get_user_info();
$session_id = api_get_session_id();
$courseInfo = api_get_course_info();
$course_code = $courseInfo['code'];
$group_id = api_get_group_id();
if (empty($workId)) {
api_not_allowed(true);
}
protectWork($courseInfo, $workId);
$workInfo = get_work_data_by_id($workId);
if (empty($workInfo)) {
api_not_allowed(true);
}
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
$homework = get_work_assignment_by_id($workInfo['id']);
$validationStatus = getWorkDateValidationStatus($homework);
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId,
'name' => $workInfo['title'],
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UploadCorrections')];
$downloadLink = api_get_path(WEB_CODE_PATH).'work/downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq();
$form = new FormValidator(
'form',
'POST',
api_get_self()."?".api_get_cidreq()."&id=".$workId,
'',
['enctype' => "multipart/form-data"]
);
$form->addElement('header', get_lang('UploadCorrections'));
$form->addHtml(Display::return_message(
sprintf(
get_lang('UploadCorrectionsExplanationWithDownloadLinkX'),
$downloadLink
),
'normal',
false
));
$form->addElement('file', 'file', get_lang('UploadADocument'));
$form->addProgress();
$form->addRule('file', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('hidden', 'id', $workId);
$form->addButtonUpload(get_lang('Upload'));
$succeed = false;
if ($form->validate()) {
$values = $form->getSubmitValues();
$upload = process_uploaded_file($_FILES['file'], false);
if ($upload) {
$zip = new PclZip($_FILES['file']['tmp_name']);
// Check the zip content (real size and file extension)
$zipFileList = (array) $zip->listContent();
$realSize = 0;
foreach ($zipFileList as &$this_content) {
$realSize += $this_content['size'];
}
$maxSpace = DocumentManager::get_course_quota();
if (!DocumentManager::enough_space($realSize, $maxSpace)) {
Display::addFlash(
Display::return_message(
get_lang('UplNotEnoughSpace'),
'warning'
)
);
}
$folder = api_get_unique_id();
$destinationDir = api_get_path(SYS_ARCHIVE_PATH).$folder;
mkdir($destinationDir, api_get_permissions_for_new_directories(), true);
// Uncompress zip file
// We extract using a callback function that "cleans" the path
$zip->extract(
PCLZIP_OPT_PATH,
$destinationDir,
PCLZIP_CB_PRE_EXTRACT,
'clean_up_files_in_zip',
PCLZIP_OPT_REPLACE_NEWER
);
$result = get_work_user_list(null, null, null, null, $workId);
if (empty($result)) {
Display::addFlash(
Display::return_message(
get_lang('NoDataAvailable'),
'warning'
)
);
}
$finalResult = [];
foreach ($result as $item) {
$title = $item['title_clean'];
$insert_date = str_replace([':', '-', ' '], '_', api_get_local_time($item['sent_date_from_db']));
$title = api_replace_dangerous_char($insert_date.'_'.$item['username'].'_'.$title);
$finalResult[$title] = $item['id'];
}
$coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/';
$workDir = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work/';
$workDir .= basename($workInfo['url']).'/';
$finder = new Finder();
$finder->files()->in($destinationDir);
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
/** @var SplFileInfo $file */
foreach ($finder as $file) {
$fileName = $file->getBasename();
if (isset($finalResult[$fileName])) {
$workStudentId = $finalResult[$fileName];
$workStudent = get_work_data_by_id($workStudentId);
if ($workStudent) {
if (!empty($workStudent['url_correction'])) {
$correctionFilePath = $coursePath.$workStudent['url_correction'];
$correctionTitle = $workStudent['title_correction'];
} else {
if (!empty($workStudent['url'])) {
$correctionFilePath = $coursePath.$workStudent['url'].'_correction';
$correctionTitle = $fileName;
}
}
if (!empty($correctionFilePath)) {
$result = copy(
$file->getRealPath(),
$correctionFilePath
);
$correctionTitle = Database::escape_string(
$correctionTitle
);
$correctionFilePath = Database::escape_string(
'work/'.basename($workInfo['url']).'/'.basename($correctionFilePath)
);
if ($result) {
$sql = "UPDATE $table SET
url_correction = '".$correctionFilePath."',
title_correction = '".$correctionTitle."'
WHERE iid = $workStudentId";
Database::query($sql);
}
}
}
}
}
Display::addFlash(
Display::return_message(
get_lang('Uploaded')
)
);
}
header('Location: '.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId);
exit;
}
$htmlHeadXtra[] = to_javascript_work();
Display::display_header(null);
if (!empty($workId)) {
echo $validationStatus['message'];
if ($is_allowed_to_edit) {
$form->display();
} else {
api_not_allowed();
}
} else {
api_not_allowed();
}
Display::display_footer();

View File

@@ -0,0 +1,136 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
// Including necessary files
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$work_id = isset($_REQUEST['id']) ? (int) ($_REQUEST['id']) : null;
$documentId = isset($_REQUEST['document_id']) ? (int) ($_REQUEST['document_id']) : null;
$is_allowed_to_edit = api_is_allowed_to_edit();
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$userInfo = api_get_user_info();
$session_id = api_get_session_id();
$course_info = api_get_course_info();
$course_code = $course_info['code'];
$group_id = api_get_group_id();
$sessionId = api_get_session_id();
if (empty($work_id)) {
api_not_allowed(true);
}
protectWork($course_info, $work_id);
$workInfo = get_work_data_by_id($work_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$user_id,
$course_id,
$session_id
);
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false) {
api_not_allowed(true);
}
$check = Security::check_token('post');
$token = Security::get_token();
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
$homework = get_work_assignment_by_id($workInfo['id']);
$validationStatus = getWorkDateValidationStatus($homework);
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$work_id,
'name' => $workInfo['title'],
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UploadFromTemplate')];
$form = new FormValidator(
'form',
'POST',
api_get_self()."?".api_get_cidreq()."&id=".$work_id,
'',
['enctype' => "multipart/form-data"]
);
setWorkUploadForm($form, $workInfo['allow_text_assignment']);
$form->addElement('hidden', 'document_id', $documentId);
$form->addElement('hidden', 'id', $work_id);
$form->addElement('hidden', 'sec_token', $token);
$documentTemplateData = getDocumentTemplateFromWork($work_id, $course_info, $documentId);
$defaults = [];
if (!empty($documentTemplateData)) {
$defaults['title'] = $userInfo['complete_name'].'_'.$documentTemplateData['title'].'_'.substr(api_get_utc_datetime(), 0, 10);
$defaults['description'] = $documentTemplateData['file_content'];
}
$form->setDefaults($defaults);
$succeed = false;
if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
$values = $form->getSubmitValues();
// Process work
$error_message = processWorkForm(
$workInfo,
$values,
$course_info,
$sessionId,
$group_id,
$user_id,
[],
api_get_configuration_value('assignment_prevent_duplicate_upload')
);
$script = 'work_list.php';
if ($is_allowed_to_edit) {
$script = 'work_list_all.php';
}
Display::addFlash($error_message);
header('Location: '.api_get_path(WEB_CODE_PATH).'work/'.$script.'?'.api_get_cidreq().'&id='.$work_id);
exit;
} else {
// Bad token or can't add works
Display::addFlash(Display::return_message(get_lang('ImpossibleToSaveTheDocument'), 'error'));
}
}
$htmlHeadXtra[] = to_javascript_work();
Display::display_header(null);
if (!empty($work_id)) {
echo $validationStatus['message'];
if ($is_allowed_to_edit) {
if (api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION)) {
echo Display::return_message(get_lang('ResourceLockedByGradebook'), 'warning');
} else {
$form->display();
}
} elseif ($student_can_edit_in_session && $validationStatus['has_ended'] == false) {
$form->display();
} else {
api_not_allowed();
}
} else {
api_not_allowed();
}
Display::display_footer();

254
main/work/view.php Normal file
View File

@@ -0,0 +1,254 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
require_once 'work.lib.php';
$id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$work = get_work_data_by_id($id);
if (empty($work)) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
protectWork($courseInfo, $work['parent_id']);
$action = $_REQUEST['action'] ?? null;
$page = $_REQUEST['page'] ?? null;
$work['title'] = isset($work['title']) ? Security::remove_XSS($work['title']) : '';
$work['description'] = isset($work['description']) ? Security::remove_XSS($work['description']) : '';
$htmlHeadXtra[] = '<script>'.ExerciseLib::getJsCode().'</script>';
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
if (api_get_configuration_value('allow_skill_rel_items') == true) {
$htmlContentExtraClass[] = 'feature-item-user-skill-on';
}
$folderData = get_work_data_by_id($work['parent_id']);
$currentUserId = api_get_user_id();
$isCourseManager = api_is_platform_admin() || api_is_coach() || api_is_allowed_to_edit(false, false, true);
$allowBaseCourseTeacher = api_get_configuration_value('assignment_base_course_teacher_access_to_all_session');
if (false === $isCourseManager && $allowBaseCourseTeacher) {
// Check if user is base course teacher.
if (CourseManager::is_course_teacher($currentUserId, $courseInfo['code'])) {
$isCourseManager = true;
}
}
$allowEdition = false;
if ($isCourseManager) {
$allowEdition = true;
if (!empty($work['qualification']) && api_get_configuration_value('block_student_publication_score_edition')) {
$allowEdition = false;
}
}
if (api_is_platform_admin()) {
$allowEdition = true;
}
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
$currentUserId,
$courseInfo
);
$isDrhOfSession = !empty(SessionManager::getSessionFollowedByDrh($currentUserId, $work['session_id']));
if (($isDrhOfCourse || $allowEdition || $isDrhOfSession || user_is_author($id)) ||
(
0 == $courseInfo['show_score'] &&
1 == $work['active'] &&
1 == $work['accepted']
)
) {
if ((api_is_allowed_to_edit() || api_is_coach()) || api_is_drh()) {
$url_dir = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?id='.$folderData['id'].'&'.api_get_cidreq();
} else {
$url_dir = api_get_path(WEB_CODE_PATH).'work/work_list.php?id='.$folderData['id'].'&'.api_get_cidreq();
}
$userInfo = api_get_user_info($work['user_id']);
$interbreadcrumb[] = ['url' => $url_dir, 'name' => $folderData['title']];
$interbreadcrumb[] = ['url' => '#', 'name' => $userInfo['complete_name']];
$interbreadcrumb[] = ['url' => '#', 'name' => $work['title']];
if ((
0 == $courseInfo['show_score'] &&
1 == $work['active'] &&
1 == $work['accepted']
) ||
$isCourseManager || $isDrhOfCourse || $isDrhOfSession || user_is_author($id)
) {
if ($page === 'edit') {
$url = api_get_path(WEB_CODE_PATH).'work/edit.php?id='.$folderData['id'].'&item_id='.$work['id'].'&'.api_get_cidreq();
} else {
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
$allowRedirect = api_get_configuration_value('allow_redirect_to_main_page_after_work_upload');
$urlToRedirect = '';
if ($allowRedirect) {
$url = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
}
}
switch ($action) {
case 'send_comment':
if (isset($_FILES['attachment'])) {
$_POST['attachment'] = $_FILES['attachment'];
}
addWorkComment(
api_get_course_info(),
api_get_user_id(),
$folderData,
$work,
$_POST
);
if ($allowEdition) {
$qualification = isset($_POST['qualification']) ? api_float_val($_POST['qualification']) : 0;
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "UPDATE $work_table
SET
qualificator_id = '".api_get_user_id()."',
qualification = '$qualification',
date_of_qualification = '".api_get_utc_datetime()."'
WHERE c_id = ".$courseInfo['real_id']." AND id = $id";
Database::query($sql);
Display::addFlash(Display::return_message(get_lang('Updated')));
$resultUpload = uploadWork(
$folderData,
$courseInfo,
true,
$work
);
if ($resultUpload) {
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (!empty($resultUpload['url'])) {
$title = !empty($resultUpload['filename']) ? $resultUpload['filename'] : get_lang('Untitled');
$urlToSave = Database::escape_string($resultUpload['url']);
$title = Database::escape_string($title);
$sql = "UPDATE $work_table SET
url_correction = '".$urlToSave."',
title_correction = '".$title."'
WHERE iid = ".$work['iid'];
Database::query($sql);
Display::addFlash(
Display::return_message(get_lang('FileUploadSucces'))
);
}
}
}
header('Location: '.$url);
exit;
case 'delete_attachment':
deleteCommentFile(
$_REQUEST['comment_id'],
api_get_course_info()
);
Display::addFlash(Display::return_message(get_lang('DocDeleted')));
header('Location: '.$url);
exit;
case 'delete_correction':
if ($allowEdition && !empty($work['url_correction'])) {
deleteCorrection($courseInfo, $work);
Display::addFlash(Display::return_message(get_lang('Deleted')));
}
header('Location: '.$url);
exit;
}
$comments = getWorkComments($work);
$commentForm = getWorkCommentForm($work, $folderData);
$tpl = new Template();
$tpl->assign('work', $work);
$tpl->assign('comments', $comments);
$actions = '';
if (!empty($work['contains_file'])) {
if (!empty($work['download_url'])) {
$actions = Display::url(
Display::return_icon(
'back.png',
get_lang('BackToWorksList'),
null,
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq()
);
// Check if file can be downloaded
$file = getFileContents($work['id'], $courseInfo, api_get_session_id());
if (!empty($file)) {
$actions .= Display::url(
Display::return_icon(
'save.png',
get_lang('Download'),
null,
ICON_SIZE_MEDIUM
),
$work['download_url']
);
}
}
}
if (!empty($work['url_correction']) && !empty($work['download_url'])) {
$actions .= Display::url(
Display::return_icon(
'check-circle.png',
get_lang('Correction'),
null,
ICON_SIZE_MEDIUM
),
$work['download_url'].'&correction=1'
);
if ($allowEdition) {
$actions .= Display::url(
Display::return_icon(
'delete.png',
get_lang('Delete').': '.get_lang('Correction'),
null,
ICON_SIZE_MEDIUM
),
api_get_self().'?action=delete_correction&id='.$id.'&'.api_get_cidreq()
);
}
}
if (!empty($actions)) {
$tpl->assign(
'actions',
Display::toolbarAction('toolbar', [$actions])
);
}
if (api_is_allowed_to_session_edit()) {
$tpl->assign('form', $commentForm);
}
$tpl->assign('is_allowed_to_edit', api_is_allowed_to_edit());
$template = $tpl->get_template('work/view.tpl');
$content = $tpl->fetch($template);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
} else {
api_not_allowed(true);
}
} else {
api_not_allowed(true);
}

6603
main/work/work.lib.php Normal file

File diff suppressed because it is too large Load Diff

356
main/work/work.php Normal file
View File

@@ -0,0 +1,356 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
require_once 'work.lib.php';
$courseInfo = api_get_course_info();
$user_id = api_get_user_id();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
// Section (for the tabs)
$this_section = SECTION_COURSES;
$work_id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$my_folder_data = get_work_data_by_id($work_id);
$curdirpath = '';
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = to_javascript_work();
$tool_name = get_lang('StudentPublications');
$item_id = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null;
$origin = api_get_origin();
$course_dir = api_get_path(SYS_COURSE_PATH).$courseInfo['path'];
$base_work_dir = $course_dir.'/work';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
// Download folder
if ($action === 'downloadfolder') {
require 'downloadfolder.inc.php';
}
$display_upload_form = false;
if ($action === 'upload_form') {
$display_upload_form = true;
}
if (api_is_in_gradebook()) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(),
'name' => get_lang('ToolGradebook'),
];
}
if (!empty($groupId)) {
api_protect_course_group(GroupManager::GROUP_TOOL_WORK);
$group_properties = GroupManager::get_group_properties($groupId);
$interbreadcrumb[] = [
'url' => 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('GroupSpace').' '.$group_properties['name'],
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?&id='.$work_id.'&'.api_get_cidreq();
if (!empty($my_folder_data)) {
$interbreadcrumb[] = ['url' => $url_dir, 'name' => $my_folder_data['title']];
}
if ($action === 'upload_form') {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('UploadADocument'),
];
}
if ($action === 'create_dir') {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('CreateAssignment'),
];
}
} else {
if ($origin !== 'learnpath') {
if (isset($_GET['id']) &&
!empty($_GET['id']) || $display_upload_form || $action === 'create_dir'
) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
} else {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('StudentPublications')];
}
if (!empty($my_folder_data)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?id='.$work_id.'&'.api_get_cidreq(),
'name' => $my_folder_data['title'],
];
}
if ($action === 'upload_form') {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UploadADocument')];
}
if ($action === 'create_dir') {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('CreateAssignment')];
}
}
}
Event::event_access_tool(TOOL_STUDENTPUBLICATION);
$logInfo = [
'tool' => TOOL_STUDENTPUBLICATION,
'action' => $action,
];
Event::registerLog($logInfo);
$groupId = api_get_group_id();
$isTutor = false;
if (!empty($groupId)) {
$groupInfo = GroupManager::get_group_properties($groupId);
$isTutor = GroupManager::is_tutor_of_group(
api_get_user_id(),
$groupInfo
);
}
$is_allowed_to_edit = api_is_allowed_to_edit();
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
/* Display links to upload form and tool options */
if (!in_array($action, ['add', 'create_dir'])) {
$token = Security::get_token();
}
$currentUrl = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
$content = null;
// For teachers
switch ($action) {
case 'add':
case 'create_dir':
if (!($is_allowed_to_edit || $isTutor)) {
api_not_allowed(true);
}
$addUrl = api_get_path(WEB_CODE_PATH).'work/work.php?action=create_dir&'.api_get_cidreq();
$form = new FormValidator(
'form1',
'post',
$addUrl
);
$form->addHeader(get_lang('CreateAssignment'));
$form->addElement('hidden', 'action', 'add');
// Set default values
$defaults = !empty($_POST) ? $_POST : ['allow_text_assignment' => 2];
$form = getFormWork($form, $defaults);
$form->addButtonCreate(get_lang('CreateDirectory'));
if ($form->validate()) {
$values = $form->getSubmitValues();
$result = addDir(
$values,
$user_id,
$courseInfo,
$groupId,
$sessionId
);
if ($result) {
Skill::saveSkills($form, ITEM_TYPE_STUDENT_PUBLICATION, $result);
$message = Display::return_message(get_lang('DirectoryCreated'), 'success');
} else {
$currentUrl = $addUrl;
$message = Display::return_message(get_lang('CannotCreateDir'), 'error');
}
Display::addFlash($message);
header('Location: '.$currentUrl);
exit;
} else {
$content = $form->returnForm();
}
break;
case 'delete_dir':
if ($is_allowed_to_edit) {
$work_to_delete = get_work_data_by_id($_REQUEST['id']);
$result = deleteDirWork($_REQUEST['id']);
if ($result) {
$message = Display::return_message(
get_lang('DirDeleted').': '.$work_to_delete['title'],
'success'
);
Display::addFlash($message);
}
header('Location: '.$currentUrl);
exit;
}
break;
case 'move':
// Move file form request
if ($is_allowed_to_edit) {
if (!empty($item_id)) {
$content = generateMoveForm(
$item_id,
$curdirpath,
$courseInfo,
$groupId,
$sessionId
);
}
}
break;
case 'move_to':
/* Move file command */
if ($is_allowed_to_edit) {
$move_to_path = get_work_path($_REQUEST['move_to_id']);
if ($move_to_path == -1) {
$move_to_path = '/';
} elseif (substr($move_to_path, -1, 1) != '/') {
$move_to_path = $move_to_path.'/';
}
// Security fix: make sure they can't move files that are not in the document table
if ($path = get_work_path($item_id)) {
if (move($course_dir.'/'.$path, $base_work_dir.$move_to_path)) {
// Update db
updateWorkUrl(
$item_id,
'work'.$move_to_path,
$_REQUEST['move_to_id']
);
api_item_property_update(
$courseInfo,
'work',
$_REQUEST['move_to_id'],
'FolderUpdated',
$user_id
);
$message = Display::return_message(get_lang('DirMv'), 'success');
} else {
$message = Display::return_message(get_lang('Impossible'), 'error');
}
} else {
$message = Display::return_message(get_lang('Impossible'), 'error');
}
Display::addFlash($message);
header('Location: '.$currentUrl);
exit;
}
break;
case 'visible':
if (!$is_allowed_to_edit) {
api_not_allowed();
}
api_item_property_update(
$courseInfo,
'work',
$work_id,
'visible',
api_get_user_id(),
null,
null,
null,
null,
$sessionId
);
Display::addFlash(
Display::return_message(
get_lang('VisibilityChanged'),
'confirmation'
)
);
header('Location: '.$currentUrl);
exit;
break;
case 'invisible':
if (!$is_allowed_to_edit) {
api_not_allowed();
}
api_item_property_update(
$courseInfo,
'work',
$work_id,
'invisible',
api_get_user_id(),
null,
null,
null,
null,
$sessionId
);
Display::addFlash(
Display::return_message(
get_lang('VisibilityChanged'),
'confirmation'
)
);
header('Location: '.$currentUrl);
exit;
break;
case 'list':
/* Display list of student publications */
if (!empty($my_folder_data['description'])) {
$content = '<div>'.
get_lang('Description').':'.Security::remove_XSS($my_folder_data['description'], STUDENT).
'</div>';
}
// Work list
if (api_is_allowed_to_edit() || api_is_coach()) {
$content .= '<div class="row">';
$content .= '<div class="col-md-12">';
$content .= '<div class="table-responsive">';
$content .= Display::panel(showTeacherWorkGrid());
$content .= '</div>';
$content .= '</div>';
$content .= '<div id="student-list-work" style="display: none" class="table-responsive">';
$content .= '<div class="toolbar"><a id="closed-view-list" href="#">
<em class="fa fa-times-circle"></em> '.get_lang('Close').'</a></div>';
$content .= showStudentList($work_id);
$content .= '</div>';
} else {
$content .= Display::panel(showStudentWorkGrid());
}
break;
}
Display::display_header(null);
Display::display_introduction_section(TOOL_STUDENTPUBLICATION);
if ('learnpath' === $origin) {
echo '<div style="height:15px">&nbsp;</div>';
}
displayWorkActionLinks($work_id, $action, $isTutor);
echo $content;
Display::display_footer();

293
main/work/work_list.php Normal file
View File

@@ -0,0 +1,293 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CStudentPublication;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$workId = isset($_GET['id']) ? (int) $_GET['id'] : null;
$courseInfo = api_get_course_info();
if (empty($workId) || empty($courseInfo)) {
api_not_allowed(true);
}
// Student publications are saved with the iid in a LP
$origin = api_get_origin();
if ('learnpath' === $origin) {
$em = Database::getManager();
/** @var CStudentPublication $work */
$work = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->findOneBy(
['iid' => $workId, 'cId' => $courseInfo['real_id']]
);
if ($work) {
$workId = $work->getId();
}
}
protectWork($courseInfo, $workId);
$my_folder_data = get_work_data_by_id($workId);
$work_data = get_work_assignment_by_id($workId);
$tool_name = get_lang('StudentPublications');
$group_id = api_get_group_id();
$htmlHeadXtra[] = api_get_jqgrid_js();
$url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
if (!empty($group_id)) {
$group_properties = GroupManager::get_group_properties($group_id);
$interbreadcrumb[] = [
'url' => 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('GroupSpace').' '.$group_properties['name'],
];
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];
$documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
$actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsRight = '';
$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) {
$url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId;
$actionsRight = Display::url(
Display::returnFontAwesomeIcon(
' fa-upload'
).
get_lang('UploadMyAssignment'),
$url,
['class' => 'btn btn-primary', 'id' => 'upload_button']
);
}
if ($onlyOnePublication) {
$count = get_work_count_by_student(
api_get_user_id(),
$my_folder_data['id']
);
if (!empty($count) && $count >= 1) {
$actionsRight = '';
}
}
$tpl = new Template('');
$content = Display::toolbarAction('toolbar-work', [$actionsLeft, $actionsRight]);
if (!empty($my_folder_data['title'])) {
$content .= Display::page_subheader($my_folder_data['title']);
}
if (!empty($my_folder_data['description'])) {
$contentWork = Security::remove_XSS($my_folder_data['description']);
$content .= Display::panel($contentWork, get_lang('Description'));
}
$extraFieldWorkData = workGetExtraFieldData($workId);
if (!empty($extraFieldWorkData)) {
$forceDownload = api_get_configuration_value('force_download_doc_before_upload_work');
if ($forceDownload) {
// Force to download documents first.
$downloadDocumentsFirst = addslashes(get_lang('DownloadDocumentsFirst'));
$content .= "<script>
$(function() {
var clicked = 0;
$('#upload_button').on('click', function(e) {
if (clicked == 0) {
alert('$downloadDocumentsFirst');
e.preventDefault();
}
});
$('.download_extra_field').on('click', function(e){
clicked = 1;
});
});
</script>";
}
}
$content .= $extraFieldWorkData;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$item_id = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null;
switch ($action) {
case 'delete':
$fileDeleted = deleteWorkItem($item_id, $courseInfo);
if (!$fileDeleted) {
Display::addFlash(Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument')));
} else {
Display::addFlash(Display::return_message(get_lang('TheDocumentHasBeenDeleted')));
}
break;
}
$result = getWorkDateValidationStatus($work_data);
$content .= $result['message'];
$check_qualification = (int) $my_folder_data['qualification'];
if (!api_is_invitee()) {
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
$type = 'simple';
$columns = [
get_lang('Type'),
get_lang('Title'),
get_lang('Qualification'),
get_lang('Date'),
get_lang('Status'),
get_lang('Actions'),
];
$columnModel = [
[
'name' => 'type',
'index' => 'file',
'width' => '5',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
[
'name' => 'title',
'index' => 'title',
'width' => '40',
'align' => 'left',
'search' => 'false',
'wrap_cell' => 'true',
],
[
'name' => 'qualification',
'index' => 'qualification',
'width' => '30',
'align' => 'center',
'search' => 'true',
],
[
'name' => 'sent_date',
'index' => 'sent_date',
'width' => '30',
'align' => 'left',
'search' => 'true',
'wrap_cell' => 'true',
],
[
'name' => 'qualificator_id',
'index' => 'qualificator_id',
'width' => '20',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'actions',
'index' => 'actions',
'width' => '20',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
];
} else {
$type = 'complex';
$columns = [
get_lang('Type'),
get_lang('Title'),
get_lang('Feedback'),
get_lang('Date'),
get_lang('Actions'),
];
$columnModel = [
[
'name' => 'type',
'index' => 'file',
'width' => '5',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
[
'name' => 'title',
'index' => 'title',
'width' => '60',
'align' => 'left',
'search' => 'false',
'wrap_cell' => 'true',
],
[
'name' => 'qualification',
'index' => 'qualification',
'width' => '30',
'align' => 'center',
'search' => 'true',
],
[
'name' => 'sent_date',
'index' => 'sent_date',
'width' => '30',
'align' => 'left',
'search' => 'true',
'wrap_cell' => 'true',
'sortable' => 'false',
],
[
'name' => 'actions',
'index' => 'actions',
'width' => '20',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
];
}
$extraParams = [
'autowidth' => 'true',
'height' => 'auto',
'sortname' => 'sent_date',
'sortorder' => 'desc',
];
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
$content .= '
<script>
$(function() {
'.Display::grid_js('results', $url, $columns, $columnModel, $extraParams).'
});
</script>
';
$documents = getAllDocumentsFromWorkToString($workId, $courseInfo);
$content .= $documents;
$tableWork = Display::grid_html('results');
$content .= Display::panel($tableWork);
}
$tpl->assign('content', $content);
$tpl->display_one_col_template();

739
main/work/work_list_all.php Normal file
View File

@@ -0,0 +1,739 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
// Including necessary files
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$workId = isset($_GET['id']) ? (int) $_GET['id'] : null;
$is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
if (empty($workId)) {
api_not_allowed(true);
}
$my_folder_data = get_work_data_by_id($workId);
if (empty($my_folder_data)) {
api_not_allowed(true);
}
$work_data = get_work_assignment_by_id($workId);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
);
if (!($is_allowed_to_edit || $isDrhOfCourse)) {
api_not_allowed(true);
}
$group_id = api_get_group_id();
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$htmlHeadXtra[] = api_get_jqgrid_js();
$user_id = api_get_user_id();
if (!empty($group_id)) {
$group_properties = GroupManager::get_group_properties($group_id);
if (api_is_allowed_to_edit(false, true)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access(
$user_id,
$group_properties['iid'],
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = [
'url' => 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('GroupSpace').' '.$group_properties['name'],
];
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$itemId = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null;
switch ($action) {
case 'export_to_doc':
if ($is_allowed_to_edit) {
if (!empty($itemId)) {
$work = get_work_data_by_id($itemId);
if (!empty($work)) {
Export::htmlToOdt($work['description'], $work['title']);
}
}
}
break;
case 'delete':
/* Delete document */
if ($itemId) {
$fileDeleted = deleteWorkItem($itemId, $courseInfo);
if (!$fileDeleted) {
Display::addFlash(
Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument'), 'error')
);
} else {
Display::addFlash(
Display::return_message(get_lang('TheDocumentHasBeenDeleted'), 'confirmation')
);
}
}
header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
exit;
break;
case 'delete_correction':
$result = get_work_user_list(null, null, null, null, $workId);
if ($result) {
foreach ($result as $item) {
$workToDelete = get_work_data_by_id($item['id']);
deleteCorrection($courseInfo, $workToDelete);
}
Display::addFlash(
Display::return_message(get_lang('Deleted'), 'confirmation')
);
}
header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
exit;
break;
case 'make_visible':
if ($is_allowed_to_edit) {
if (!empty($itemId)) {
if (isset($itemId) && $itemId == 'all') {
} else {
makeVisible($itemId, $courseInfo);
Display::addFlash(
Display::return_message(get_lang('FileVisible'), 'confirmation')
);
}
}
}
header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
exit;
break;
case 'make_invisible':
if (!empty($itemId)) {
if (isset($itemId) && $itemId == 'all') {
} else {
makeInvisible($itemId, $courseInfo);
Display::addFlash(
Display::return_message(get_lang('FileInvisible'), 'confirmation')
);
}
}
header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
exit;
break;
case 'export_pdf':
exportAllStudentWorkFromPublication(
$workId,
$courseInfo,
$sessionId,
'pdf'
);
break;
}
$htmlHeadXtra[] = api_get_jquery_libraries_js(['jquery-upload']);
Display::display_header(null);
$documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
$actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
$blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
if (!$blockAddDocuments) {
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
}
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('addworkuser.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
$actionsLeft .= Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
$display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
$editLink = '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
$editLink .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
$editLink = '';
}
$actionsLeft .= $editLink;
$count = get_count_work($workId);
if ($count > 0) {
$display_output .= '<a class="btn-toolbar" href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
Display::return_icon('save_pack.png', get_lang('DownloadTasksPackage'), null, ICON_SIZE_MEDIUM).' '.get_lang('DownloadTasksPackage').'</a>';
}
$actionsLeft .= $display_output;
$url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
$actionsLeft .= '<a class="btn-toolbar" href="'.$url.'">'.
Display::return_icon('upload_package.png', get_lang('UploadCorrectionsPackage'), '', ICON_SIZE_MEDIUM).' '.get_lang('UploadCorrectionsPackage').'</a>';
$url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=delete_correction';
$actionsLeft .= Display::toolbarButton(get_lang('DeleteCorrections'), $url, 'remove', 'danger');
}
echo Display::toolbarAction('toolbar-worklist', [$actionsLeft]);
$plagiarismListJqgridColumn = [];
$plagiarismListJqgridLine = [];
$allowAntiPlagiarism = api_get_configuration_value('allow_compilatio_tool');
if ($allowAntiPlagiarism) {
$plagiarismListJqgridColumn = ['Compilatio'];
$plagiarismListJqgridLine = [
[
'name' => 'compilatio',
'index' => 'compilatio',
'width' => '40',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
];
}
if (!empty($my_folder_data['title'])) {
echo Display::page_subheader($my_folder_data['title']);
}
if (!empty($my_folder_data['description'])) {
$contentWork = Security::remove_XSS($my_folder_data['description']);
$html = '';
$html .= Display::panel($contentWork, get_lang('Description'));
echo $html;
}
$check_qualification = (int) $my_folder_data['qualification'];
$orderName = api_is_western_name_order() ? 'firstname' : 'lastname';
if (!empty($work_data['enable_qualification']) &&
!empty($check_qualification)
) {
$type = 'simple';
$columns = [
get_lang('FullUserName'),
get_lang('Title'),
get_lang('Score'),
get_lang('Date'),
get_lang('Status'),
get_lang('UploadCorrection'),
];
$columns = array_merge($columns, $plagiarismListJqgridColumn);
$columns[] = get_lang('Actions');
$column_model = [
[
'name' => 'fullname',
'index' => $orderName,
'width' => '30',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'title',
'index' => 'title',
'width' => '25',
'align' => 'left',
'search' => 'false',
'wrap_cell' => 'true',
],
[
'name' => 'qualification',
'index' => 'qualification',
'width' => '15',
'align' => 'center',
'search' => 'true',
],
[
'name' => 'sent_date',
'index' => 'sent_date',
'width' => '25',
'align' => 'left',
'search' => 'true',
'wrap_cell' => 'true',
],
[
'name' => 'qualificator_id',
'index' => 'qualificator_id',
'width' => '20',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'correction',
'index' => 'correction',
'width' => '30',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
'title' => 'false',
],
];
$column_model = array_merge($column_model, $plagiarismListJqgridLine);
$column_model[] = [
'name' => 'actions',
'index' => 'actions',
'width' => '25',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
];
} else {
$type = 'complex';
$columns = [
get_lang('FullUserName'),
get_lang('Title'),
get_lang('Feedback'),
get_lang('Date'),
get_lang('UploadCorrection'),
];
$columns = array_merge($columns, $plagiarismListJqgridColumn);
$columns[] = get_lang('Actions');
$column_model = [
[
'name' => 'fullname',
'index' => $orderName,
'width' => '35',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'title',
'index' => 'title',
'width' => '30',
'align' => 'left',
'search' => 'false',
'wrap_cell' => 'true',
],
[
'name' => 'qualification',
'index' => 'qualification',
'width' => '20',
'align' => 'center',
'search' => 'true',
],
[
'name' => 'sent_date',
'index' => 'sent_date',
'width' => '30',
'align' => 'left',
'search' => 'true',
'wrap_cell' => 'true',
],
[
'name' => 'correction',
'index' => 'correction',
'width' => '40',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
'title' => 'false',
],
];
$column_model = array_merge($column_model, $plagiarismListJqgridLine);
$column_model[] = [
'name' => 'actions',
'index' => 'actions',
'width' => '25',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
];
}
$extra_params = [
'autowidth' => 'true',
'height' => 'auto',
//'sortname' => $orderName,
'sortname' => 'sent_date',
'sortable' => 'false',
'multiselect' => 'true',
];
$url = api_get_path(WEB_AJAX_PATH).
'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
$workUrl = api_get_path(WEB_AJAX_PATH).'work.ajax.php?'.api_get_cidreq();
$deleteUrl = $workUrl.'&a=delete_student_work';
$showUrl = $workUrl.'&a=show_student_work';
$hideUrl = $workUrl.'&a=hide_student_work';
if ($allowAntiPlagiarism) {
$extra_params['gridComplete'] = 'compilatioInit()';
}
?>
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
$("#results").jqGrid(
"navGrid",
"#results_pager",
{ edit: false, add: false, search: false, del: true },
{ height:280, reloadAfterSubmit:false }, // edit options
{ height:280, reloadAfterSubmit:false }, // add options
{ reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
{ width:500 } // search options
).navButtonAdd('#results_pager', {
caption:"<i class=\"fa fa-eye\" ></i>",
buttonicon:"ui-icon-blank",
onClickButton: function(a) {
var userIdList = $("#results").jqGrid('getGridParam', 'selarrrow');
if (userIdList.length) {
$.ajax({
type: "POST",
url: "<?php echo $showUrl; ?>&item_list=" + userIdList,
dataType: "json",
success: function(data) {
$('#results').trigger('reloadGrid');
}
});
} else {
alert("<?php echo addslashes(get_lang('SelectAnOption')); ?>");
}
},
position:"last"
}).navButtonAdd('#results_pager', {
//caption:"<?php //echo addslashes(get_lang('SetVisible'));?>//",
caption:"<i class=\"fa fa-eye-slash\" ></i>",
buttonicon:"ui-icon-blank",
onClickButton: function(a) {
var userIdList = $("#results").jqGrid('getGridParam', 'selarrrow');
if (userIdList.length) {
$.ajax({
type: "POST",
url: "<?php echo $hideUrl; ?>&item_list=" + userIdList,
dataType: "json",
success: function(data) {
$('#results').trigger('reloadGrid');
}
});
} else {
alert("<?php echo addslashes(get_lang('SelectAnOption')); ?>");
}
},
position:"last"
});
});
</script>
<?php
echo $documentsAddedInWork;
$tableWork = Display::grid_html('results');
echo workGetExtraFieldData($workId);
echo Display::panel($tableWork);
if ($allowAntiPlagiarism) {
echo '<div id="compilation-results"></div>';
echo '<div class="list-work-results">';
$table = '<table style="display:none; width:100%" class="files data_table">
<tr>
<th>'.get_lang('FileName').'</th>
<th>'.get_lang('Size').'</th>
<th>'.get_lang('Status').'</th>
</tr>
</table>';
Display::panel($table);
echo '</div>';
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$courseId = $courseInfo['real_id'];
$formAction['analyseCompilatio'] = [
'label' => get_lang('CompilatioStartAnalysis'),
'data-action' => get_lang('CompilatioStartAnalysis'),
'onClick' => "onclick='getMultiCompilatio()'",
];
$html = '<form class="form-search" method="post" name="form_actions">';
$html .= '<input type="hidden" name="action">';
$html .= '<table style="width:100%;">';
$html .= '<tr>';
$html .= '<td>';
$html .= '<div class="btn-toolbar">';
$html .= '<div class="btn-group">';
$html .= '<a class="btn btn-default" href="?'
.'&amp;'."gbox_results".'&amp;'.'selectall=1" onclick="javascript: setCheckbox(true, \''
."gbox_results".'\'); return false;">'
.get_lang('SelectAll')
.'</a>';
$html .= '<a class="btn btn-default" href="?'
.'" onclick="javascript: setCheckbox(false, \''
."gbox_results"
.'\'); return false;">'
.get_lang('UnSelectAll')
.'</a> ';
$html .= '</div>';
$html .= '<div class="btn-group">
<button class="btn btn-default" onclick="javascript:return false;">'
.get_lang('Actions')
.'</button>'
.'<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">'
.'<span class="caret"></span>'
.'</button>';
$html .= '<ul class="dropdown-menu">';
foreach ($formAction as $action) {
$html .= '<li>
<a data-action ="'.$action['data-action'].'" href="#" '.$action['onClick'].'>'
.$action['label'].'</a>
</li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
$html .= '</td></tr></table></form>';
echo $html;
$compTable = Database::get_course_table(TABLE_PLAGIARISM);
$listCompilatioDocId = [];
$compilatioQuery = "SELECT * FROM $compTable WHERE c_id= $courseId";
$compilatioResult = Database::query($compilatioQuery);
while ($compilatioData = Database::fetch_array($compilatioResult)) {
array_push($listCompilatioDocId, $compilatioData['document_id']);
}
$javascriptWorkId = '';
$sql = "SELECT * FROM $workTable WHERE c_id= $courseId AND parent_id= $workId AND active = 1";
$res = Database::query($sql);
while ($data = Database::fetch_array($res)) {
if (in_array($data['id'], $listCompilatioDocId)) {
$javascriptWorkId .= $data['id'].'a';
}
} ?>
<!--
Lets display the javascript AJAX tools for refreshing datas that needed to be refreshed
Only document with state ANALYSE_IN_QUEUE or ANALYSE_PROCESSING need to ask server
for a new state
Hubert Borderiou - Grenoble Universites - avril 2013
-->
<script>
var xhrObject; // the htmlhttprequest object
var analyseComplete = "ANALYSE_COMPLETE";
var analyseProcessing = "ANALYSE_PROCESSING";
var analyseInQueue = "ANALYSE_IN_QUEUE";
var refreshDelaisAfter = 30000;
var allWorkId = "<?php echo $javascriptWorkId; ?>";
var workFolderId = "<?php echo $workId; ?>";
var compilationWebUrl = "<?php echo api_get_path(WEB_CODE_PATH).'plagiarism/compilatio/'; ?>";
var divExisteTimer = null;
var msgWaitJS = '<?php echo Display::return_message(get_lang('PleaseWaitThisCouldTakeAWhile')); ?>';
var div = document.createElement('div');
var referent = document.getElementById('compilation-results');
var Analyse = '<?php echo get_lang('CompilatioAnalysis'); ?>';
var compiReport = '<?php echo get_lang('CompilatioSeeReport'); ?>';
var compiNonToAnalyse = '<?php echo Display::return_message(get_lang('CompilatioNonToAnalyse'), 'error'); ?>';
var clickTrigger = false;
function compilatioInit() {
if (isWorkFolder()) {
searchAdvancement();
setInterval("searchAdvancement()", refreshDelaisAfter);
//if (!clickTrigger) {
//clickTrigger = true;
$('.getSingleCompilatio').on('click', function () {
var parts = $(this).parent().attr('id').split('id_avancement');
getSingleCompilatio(parts[1]);
});
//}
}
}
// true if we are in a work folder
function isWorkFolder() {
var res = false;
if (workFolderId.match(/[0-9]+/)) {
res = true;
}
return res;
}
// check all compilatio docs
function checkAllCompilatio(action) {
$("input").each(function () {
if ($(this).attr("id")) {
objId = $(this).attr("id");
listObjId = objId.match(/jqg_results_(\d+)/)
if (listObjId.length > 1) {
$(this).prop('checked', action);
}
}
});
}
function getSingleCompilatio(itemId) {
if (div.id == "status_message") {
referent.removeChild(div);
}
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
referent.appendChild(div);
$.ajax({
url: compilationWebUrl + "upload.php?<?php echo api_get_cidreq(); ?>&doc=" + itemId,
type: "get",
dataType: "html",
beforeSend: function() {
$('#id_avancement' + itemId + ' a').addClass('disabled');
},
success: function (message) {
allWorkId += itemId + "a";
compilatioInit();
if (message.trim() != "") {
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + message + '</div>';
referent.appendChild(div);
}
}
});
}
function getMultiCompilatio() {
if (div.id == "status_message") {
referent.removeChild(div);
}
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
referent.appendChild(div);
multi_compilatio = "";
$("input:checked").each(function () {
if ($(this).attr("id")) {
objId = $(this).attr("id");
listObjId = objId.match(/jqg_results_(\d+)/)
if (listObjId) {
objClick = document.getElementById('id_avancement' + listObjId[1]);
if (objClick) {
objLink = objClick.getElementsByTagName('a');
if (objLink) {
stringLink = [].map.call(objLink, function (node) {
return node.textContent || node.innerText || "";
}).join("");
if (stringLink.trim() == Analyse.trim()) {
if (listObjId && listObjId.length > 1) {
multi_compilatio += listObjId[1] + "a";
}
}
}
}
}
}
});
if ($("#verif")) {
$("#verif").append(multi_compilatio);
}
// run compilatio
if (multi_compilatio != "") {
$.ajax({
url: compilationWebUrl + "upload.php?<?php echo api_get_cidreq(); ?>",
data: {doc: multi_compilatio, type: "multi"}, // on envoie $_GET['id_region'] *// idz
success: function (message) { // idz
allWorkId = multi_compilatio;//idz
compilatioInit();
if (message.trim() != "") {
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + message + '</div>';
referent.appendChild(div);
}
}
});
} else {
// multi_compilatio is empty
div.id = "status_message";
div.className = 'row';
div.innerHTML = '<div class="col-md-6"> <br>' + compiNonToAnalyse + '</div>';
referent.appendChild(div);
}
}
function searchAdvancement(workId) {
$.ajax({
url: compilationWebUrl + "compilatio_ajax.php?<?php echo api_get_cidreq(); ?>&workid=" + allWorkId,
type: "get",
dataType: "html",
error: function () {
showData("<?php echo get_lang('CompilatioComunicationAjaxImpossible'); ?>");
},
success: function (strData) {
showData(strData);
}
});
}
function deleteIdListeRefresh(id) {
var regexp = eval("/" + id + ":/");
allWorkId = allWorkId.replace(regexp, "");
}
function showData(res) {
var listRes = new Array();
$("#verif").html("");
// parse the answer string
listRes = res.split("|");
for (var i = 0; i < listRes.length; i = i + 3) {
if (listRes[i] != "") {
var workId = listRes[i];
if (i < listRes.length) {
var HTMLcode = listRes[i + 1];
}
if (i < listRes.length + 1) {
var idStatus = listRes[i + 2];
if (idStatus != analyseInQueue && idStatus != analyseProcessing) {
deleteIdListeRefresh(workId);
}
$("#verif").append(workId + ":" + idStatus + "<br/>");
}
$("#" + "id_avancement" + workId).html(HTMLcode);
}
}
}
</script>
<?php
}
Display::display_footer();

View File

@@ -0,0 +1,217 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$workId = isset($_GET['id']) ? (int) ($_GET['id']) : null;
if (empty($workId)) {
api_not_allowed(true);
}
$my_folder_data = get_work_data_by_id($workId);
if (empty($my_folder_data)) {
api_not_allowed(true);
}
$work_data = get_work_assignment_by_id($workId);
$tool_name = get_lang('StudentPublications');
$group_id = api_get_group_id();
$courseInfo = api_get_course_info();
// not all users
if (1 == $courseInfo['show_score']) {
api_not_allowed(true);
}
protectWork($courseInfo, $workId);
$htmlHeadXtra[] = api_get_jqgrid_js();
if (!empty($group_id)) {
$group_properties = GroupManager::get_group_properties($group_id);
$show_work = false;
if (api_is_allowed_to_edit(false, true)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access(
$user_id,
$group_properties['iid'],
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = [
'url' => 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('GroupSpace').' '.$group_properties['name'],
];
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_others.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];
Display::display_header(null);
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'>'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
if (!empty($my_folder_data['description'])) {
echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.
Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
}
$check_qualification = intval($my_folder_data['qualification']);
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
$type = 'simple';
$columns = [
get_lang('Type'),
get_lang('FirstName'),
get_lang('LastName'),
get_lang('Title'),
get_lang('Qualification'),
get_lang('Date'),
get_lang('Status'),
get_lang('Actions'),
];
$column_model = [
[
'name' => 'type',
'index' => 'file',
'width' => '12',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
['name' => 'firstname', 'index' => 'firstname', 'width' => '35', 'align' => 'left', 'search' => 'true'],
['name' => 'lastname', 'index' => 'lastname', 'width' => '35', 'align' => 'left', 'search' => 'true'],
[
'name' => 'title',
'index' => 'title',
'width' => '40',
'align' => 'left',
'search' => 'false',
'wrap_cell' => 'true',
],
[
'name' => 'qualification',
'index' => 'qualification',
'width' => '20',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'sent_date',
'index' => 'sent_date',
'width' => '50',
'align' => 'left',
'search' => 'true',
'wrap_cell' => 'true',
],
[
'name' => 'qualificator_id',
'index' => 'qualificator_id',
'width' => '30',
'align' => 'left',
'search' => 'true',
],
[
'name' => 'actions',
'index' => 'actions',
'width' => '40',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
];
} else {
$type = 'complex';
$columns = [
get_lang('Type'),
get_lang('FirstName'),
get_lang('LastName'),
get_lang('Title'),
get_lang('Date'),
get_lang('Actions'),
];
$column_model = [
[
'name' => 'type',
'index' => 'file',
'width' => '12',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
['name' => 'firstname', 'index' => 'firstname', 'width' => '35', 'align' => 'left', 'search' => 'true'],
['name' => 'lastname', 'index' => 'lastname', 'width' => '35', 'align' => 'left', 'search' => 'true'],
[
'name' => 'title',
'index' => 'title',
'width' => '40',
'align' => 'left',
'search' => 'false',
'wrap_cell' => "true",
],
[
'name' => 'sent_date',
'index' => 'sent_date',
'width' => '50',
'align' => 'left',
'search' => 'true',
'wrap_cell' => 'true',
],
[
'name' => 'actions',
'index' => 'actions',
'width' => '40',
'align' => 'left',
'search' => 'false',
'sortable' => 'false',
],
];
}
$extra_params = [];
$extra_params['autowidth'] = 'true';
$extra_params['height'] = 'auto';
$extra_params['sortname'] = 'firstname';
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list_others&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
?>
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
});
</script>
<?php
echo Display::grid_html('results');
Display::display_footer();

125
main/work/work_missing.php Normal file
View File

@@ -0,0 +1,125 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
// Including necessary files
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$workId = isset($_GET['id']) ? (int) ($_GET['id']) : null;
$group_id = api_get_group_id();
$user_id = api_get_user_id();
if (empty($workId)) {
api_not_allowed(true);
}
$my_folder_data = get_work_data_by_id($workId);
if (empty($my_folder_data)) {
api_not_allowed(true);
}
if (!api_is_allowed_to_edit(null, true)) {
api_not_allowed(true);
}
// User with no works
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
switch ($action) {
case 'send_mail':
$check = Security::check_token('get');
if ($check) {
$mails_sent_to = send_reminder_users_without_publication(
$my_folder_data
);
if (empty($mails_sent_to)) {
Display::addFlash(Display::return_message(get_lang('NoResults'), 'warning'));
} else {
Display::addFlash(Display::return_message(
get_lang('MessageHasBeenSent').' '.implode(', ', $mails_sent_to),
'success'
));
}
Security::clear_token();
}
break;
}
$token = Security::get_token();
if (!empty($group_id)) {
$group_properties = GroupManager::get_group_properties($group_id);
$show_work = false;
if (api_is_allowed_to_edit(false, true)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access(
$user_id,
$group_properties['iid'],
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = [
'url' => 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?gidReq='.$group_id,
'name' => get_lang('GroupSpace').' '.$group_properties['name'],
];
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];
if (isset($_GET['list']) && $_GET['list'] == 'with') {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UsersWithTask')];
} else {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('UsersWithoutTask')];
}
Display::display_header(null);
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?id='.$workId.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
$output = '';
if (!empty($workId)) {
if (empty($_GET['list']) or Security::remove_XSS($_GET['list']) == 'with') {
$output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$workId.'&list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM).
"</a>";
} else {
if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'send_mail')) {
$output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$workId.'&list=without&action=send_mail&sec_token='.$token.'">'.
Display::return_icon('mail_send.png', get_lang('ReminderMessage'), '', ICON_SIZE_MEDIUM).
"</a>";
} else {
$output .= Display::return_icon('mail_send_na.png', get_lang('ReminderMessage'), '', ICON_SIZE_MEDIUM);
}
}
}
echo $output;
echo '</div>';
display_list_users_without_publication($workId);