Add work drag and drop form see BT#10893

1.10.x
jmontoya 9 years ago
parent 3d311507cd
commit 0002631322
  1. 1
      main/document/upload.php
  2. 5
      main/inc/ajax/document.ajax.php
  3. 62
      main/inc/ajax/work.ajax.php
  4. 73
      main/inc/lib/document.lib.php
  5. 148
      main/work/upload.php
  6. 187
      main/work/work.lib.php
  7. 5
      main/work/work_list_all.php

@ -42,7 +42,6 @@ require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
// Variables
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$_course = api_get_course_info();
$groupId = api_get_group_id();

@ -19,10 +19,7 @@ switch ($action) {
} else {
exit;
}
} elseif (
$is_allowed_to_edit ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())
) {
} elseif ($is_allowed_to_edit || DocumentManager::is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())) {
// ??
} else {
// No course admin and no group member...

@ -11,6 +11,68 @@ $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$isAllowedToEdit = api_is_allowed_to_edit();
switch ($action) {
case 'upload_file':
api_protect_course_script(true);
$workId = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
$workInfo = get_work_data_by_id($workId);
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$userId = api_get_user_id();
if (!empty($_FILES)) {
$files = $_FILES['files'];
$fileList = [];
foreach ($files as $name => $array) {
$counter = 0;
foreach ($array as $data) {
$fileList[$counter][$name] = $data;
$counter++;
}
}
$resultList = [];
foreach ($fileList as $file) {
$globalFile = [];
$globalFile['files'] = $file;
$values = [
'contains_file' => 1,
'title' => $file['name'],
'description' => ''
];
$result = processWorkForm($workInfo, $values, $courseInfo, $sessionId, 0, $userId, $file);
$json = array();
$json['name'] = Display::url(
api_htmlentities($result['title']),
api_htmlentities($result['view_url']),
array('target' => '_blank')
);
$json['url'] = $result['view_url'];
//$json['size'] = format_file_size($result['filesize']);
$json['size'] = '';
$json['type'] = api_htmlentities($result['filetype']);
if (!empty($result) && is_array($result) && empty($result['error'])) {
$json['result'] = Display::return_icon(
'accept.png',
get_lang('Uploaded')
);
} else {
$json['result'] = Display::return_icon(
'exclamation.png',
get_lang('Error')
);
}
$resultList[] = $json;
}
echo json_encode(['files' => $resultList]);
}
break;
case 'delete_work':
if ($isAllowedToEdit) {
if (empty($_REQUEST['id'])) {

@ -328,13 +328,14 @@ class DocumentManager
$len = filesize($full_file_name);
// Fixing error when file name contains a ","
$filename = str_replace(',', '', $filename);
global $_configuration;
$sendFileHeaders = api_get_configuration_value('enable_x_sendfile_headers');
if ($forced) {
// Force the browser to save the file instead of opening it
if (isset($_configuration['enable_x_sendfile_headers']) &&
!empty($_configuration['enable_x_sendfile_headers'])) {
if (isset($sendFileHeaders) &&
!empty($sendFileHeaders)) {
header("X-Sendfile: $filename");
}
@ -361,6 +362,7 @@ class DocumentManager
//no forced download, just let the browser decide what to do according to the mimetype
$content_type = self::file_get_mime_type($filename);
$lpFixedEncoding = api_get_configuration_value('lp_fixed_encoding');
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
@ -369,7 +371,7 @@ class DocumentManager
//header('Pragma: no-cache');
switch ($content_type) {
case 'text/html':
if (isset($_configuration['lp_fixed_encoding']) && $_configuration['lp_fixed_encoding'] === 'true') {
if (isset($lpFixedEncoding) && $lpFixedEncoding === 'true') {
$content_type .= '; charset=UTF-8';
} else {
$encoding = @api_detect_encoding_html(file_get_contents($full_file_name));
@ -379,7 +381,7 @@ class DocumentManager
}
break;
case 'text/plain':
if (isset($_configuration['lp_fixed_encoding']) && $_configuration['lp_fixed_encoding'] === 'true') {
if (isset($lpFixedEncoding) && $lpFixedEncoding === 'true') {
$content_type .= '; charset=UTF-8';
} else {
$encoding = @api_detect_encoding(strip_tags(file_get_contents($full_file_name)));
@ -1586,7 +1588,7 @@ class DocumentManager
if (Database::num_rows($result) > 0) {
$row = Database::fetch_array($result, 'ASSOC');
if ($row['visibility'] == 1) {
$is_visible = $_SESSION['is_allowed_in_course'] || api_is_platform_admin();
$is_visible = api_is_allowed_in_course() || api_is_platform_admin();
}
}
@ -2797,7 +2799,8 @@ class DocumentManager
$unzip = 0,
$if_exists = null,
$index_document = false,
$show_output = false
$show_output = false,
$fileKey = 'file'
) {
$course_info = api_get_course_info();
$sessionId = api_get_session_id();
@ -2805,14 +2808,14 @@ class DocumentManager
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path . $course_dir;
if (isset($files['file'])) {
$upload_ok = process_uploaded_file($files['file'], $show_output);
if (isset($files[$fileKey])) {
$upload_ok = process_uploaded_file($files[$fileKey], $show_output);
if ($upload_ok) {
// File got on the server without problems, now process it
$new_path = handle_uploaded_document(
$course_info,
$files['file'],
$files[$fileKey],
$base_work_dir,
$path,
api_get_user_id(),
@ -2898,11 +2901,13 @@ class DocumentManager
false,
$sessionId
);
return $documentData;
}
}
}
}
return false;
}
@ -3106,8 +3111,8 @@ class DocumentManager
* on the base of a maximum directory size allowed
*
* @author Bert Vanderkimpen
* @param int file_size size of the file in byte
* @param int max_dir_space maximum size
* @param int $file_size size of the file in byte
* @param int $max_dir_space maximum size
* @return boolean true if there is enough space, false otherwise
*
* @see enough_space() uses documents_total_space() function
@ -3123,31 +3128,33 @@ class DocumentManager
}
/**
* @param array parameters: count, url, extension
* @param array $params count, url, extension
* @return string
*/
static function generate_jplayer_jquery($params = array())
{
$js_path = api_get_path(WEB_LIBRARY_PATH) . 'javascript/';
$js = ' $("#jquery_jplayer_' . $params['count'] . '").jPlayer({
ready: function() {
$(this).jPlayer("setMedia", {
' . $params['extension'] . ' : "' . $params['url'] . '"
});
},
play: function() { // To avoid both jPlayers playing together.
$(this).jPlayer("pauseOthers");
},
//errorAlerts: true,
//warningAlerts: true,
swfPath: "' . $js_path . 'jquery-jplayer/jplayer/",
//supplied: "m4a, oga, mp3, ogg, wav",
supplied: "' . $params['extension'] . '",
wmode: "window",
solution: "flash, html", // Do not change this setting
cssSelectorAncestor: "#jp_container_' . $params['count'] . '",
}); ' . "\n\n";
$js = '
$("#jquery_jplayer_' . $params['count'] . '").jPlayer({
ready: function() {
$(this).jPlayer("setMedia", {
' . $params['extension'] . ' : "' . $params['url'] . '"
});
},
play: function() { // To avoid both jPlayers playing together.
$(this).jPlayer("pauseOthers");
},
//errorAlerts: true,
//warningAlerts: true,
swfPath: "' . $js_path . 'jquery-jplayer/jplayer/",
//supplied: "m4a, oga, mp3, ogg, wav",
supplied: "' . $params['extension'] . '",
wmode: "window",
solution: "flash, html", // Do not change this setting
cssSelectorAncestor: "#jp_container_' . $params['count'] . '",
}); ' . "\n\n";
return $js;
}
@ -5315,8 +5322,8 @@ class DocumentManager
'style' => 'float: left;'
]
)
. $force_download_html . $send_to . $copy_to_myfiles
. $open_in_new_window_link . $pdf_icon;
. $force_download_html . $send_to . $copy_to_myfiles
. $open_in_new_window_link . $pdf_icon;
} else {
// For PDF Download the file.
$pdfPreview = null;

@ -32,7 +32,11 @@ 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 = 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()) {
@ -80,7 +84,9 @@ $form = new FormValidator(
'',
array('enctype' => "multipart/form-data")
);
setWorkUploadForm($form, $workInfo['allow_text_assignment']);
$form->addElement('hidden', 'id', $work_id);
$form->addElement('hidden', 'sec_token', $token);
@ -92,7 +98,7 @@ if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
$values = $form->getSubmitValues();
// Process work
$error_message = processWorkForm(
processWorkForm(
$workInfo,
$values,
$course_info,
@ -104,9 +110,6 @@ if ($form->validate()) {
if ($is_allowed_to_edit) {
$script = 'work_list_all.php';
}
if (!empty($error_message)) {
Session::write('error_message', $error_message);
}
header('Location: '.api_get_path(WEB_CODE_PATH).'work/'.$script.'?'.api_get_cidreq().'&id='.$work_id);
exit;
} else {
@ -115,19 +118,150 @@ if ($form->validate()) {
}
}
$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(array('jquery-ui', 'jquery-upload'));
$htmlHeadXtra[] = to_javascript_work();
$htmlHeadXtra[] = "
<script>
$(function () {
'use strict';
var url = '".$url."';
var uploadButton = $('<button/>')
.addClass('btn btn-primary')
.prop('disabled', true)
.text('".get_lang('Loading')."')
.on('click', function () {
var \$this = $(this),
data = \$this.data();
\$this
.off('click')
.text('".get_lang('Cancel')."')
.on('click', function () {
\$this.remove();
data.abort();
});
data.submit().always(function () {
\$this.remove();
});
});
$('#file_upload').fileupload({
url: url,
dataType: 'json',
autoUpload: false,
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true
}).on('fileuploadadd', function (e, data) {
data.context = $('<div/>').appendTo('#files');
$.each(data.files, function (index, file) {
var node = $('<p/>').append($('<span/>').text(file.name));
if (!index) {
node
.append('<br>')
.append(uploadButton.clone(true).data(data));
}
node.appendTo(data.context);
});
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
if (file.preview) {
node
.prepend('<br>')
.prepend(file.preview);
}
if (file.error) {
node
.append('<br>')
.append($('<span class=\"text-danger\"/>').text(file.error));
}
if (index + 1 === data.files.length) {
data.context.find('button')
.text('Upload')
.prop('disabled', !!data.files.error);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css(
'width',
progress + '%'
);
}).on('fileuploaddone', function (e, data) {
$.each(data.result.files, function (index, file) {
if (file.url) {
var link = $('<a>')
.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index]).wrap(link);
} else if (file.error) {
var error = $('<span class=\"text-danger\"/>').text(file.error);
$(data.context.children()[index])
.append('<br>')
.append(error);
}
});
}).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index) {
var error = $('<span class=\"text-danger\"/>').text('File upload failed.');
$(data.context.children()[index])
.append('<br>')
.append(error);
});
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>";
Display :: display_header(null);
$headers = array(
get_lang('Upload'),
get_lang('Upload').' ('.get_lang('Simple').')',
);
$multiple_form = '<div class="description-upload">'.get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField').'</div>';
$multiple_form .= '
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>'.get_lang('AddFiles').'</span>
<!-- The file input field used as target for the file upload widget -->
<input id="file_upload" type="file" name="files[]" multiple>
</span>
<br />
<br />
<!-- The global progress bar -->
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<div id="files" class="files"></div>
';
$tabs = Display::tabs($headers, array($multiple_form, $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::display_warning_message(get_lang('ResourceLockedByGradebook'));
} else {
$form->display();
echo $tabs;
}
} elseif ($student_can_edit_in_session && $validationStatus['has_ended'] == false) {
$form->display();
echo $tabs;
} else {
Display::display_error_message(get_lang('ActionNotAllowed'));
}

@ -240,6 +240,7 @@ function get_work_data_by_id($id, $courseId = null, $sessionId = null)
$work['download_url'] = api_get_path(WEB_CODE_PATH).'work/download.php?id='.$work['id'].'&'.api_get_cidreq();
$work['view_url'] = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
$work['show_url'] = api_get_path(WEB_CODE_PATH).'work/show_file.php?id='.$work['id'].'&'.api_get_cidreq();
$work['show_content'] = '';
if ($work['contains_file']) {
$fileInfo = pathinfo($work['title']);
if (is_array($fileInfo) &&
@ -279,7 +280,7 @@ function get_work_count_by_student($user_id, $work_id)
$result = Database::query($sql);
$return = 0;
if (Database::num_rows($result)) {
$return = Database::fetch_row($result,'ASSOC');
$return = Database::fetch_row($result, 'ASSOC');
$return = intval($return[0]);
}
@ -535,7 +536,6 @@ function getUniqueStudentAttempts(
function showStudentWorkGrid()
{
$courseInfo = api_get_course_info();
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_student&'.api_get_cidreq();
$columns = array(
@ -1078,96 +1078,94 @@ function count_dir($path_dir, $recurse)
*/
function to_javascript_work()
{
$origin = isset($_REQUEST['origin']) && !empty($_REQUEST['origin']) ? api_get_tools_lists($_REQUEST['origin']) : '';
$js = '<script>
function updateDocumentTitle(value) {
var temp = value.indexOf("/");
//linux path
if(temp!=-1){
var temp=value.split("/");
} else {
var temp=value.split("\\\");
}
document.getElementById("file_upload").value=temp[temp.length-1];
$("#contains_file_id").attr("value", 1);
function updateDocumentTitle(value) {
var temp = value.indexOf("/");
//linux path
if(temp!=-1){
var temp=value.split("/");
} else {
var temp=value.split("\\\");
}
document.getElementById("file_upload").value=temp[temp.length-1];
$("#contains_file_id").attr("value", 1);
}
function checkDate(month, day, year) {
var monthLength =
new Array(31,28,31,30,31,30,31,31,30,31,30,31);
function checkDate(month, day, year) {
var monthLength =
new Array(31,28,31,30,31,30,31,31,30,31,30,31);
if (!day || !month || !year)
return false;
if (!day || !month || !year)
return false;
// check for bisestile year
if (year/4 == parseInt(year/4))
monthLength[1] = 29;
// check for bisestile year
if (year/4 == parseInt(year/4))
monthLength[1] = 29;
if (month < 1 || month > 12)
return false;
if (month < 1 || month > 12)
return false;
if (day > monthLength[month-1])
return false;
if (day > monthLength[month-1])
return false;
return true;
}
return true;
}
function mktime() {
function mktime() {
var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length;
d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972);
var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length;
d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972);
var dateManip = {
0: function(tt){ return d.setHours(tt); },
1: function(tt){ return d.setMinutes(tt); },
2: function(tt){ set = d.setSeconds(tt); mb = d.getDate() - 1; return set; },
3: function(tt){ set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; },
4: function(tt){ return d.setDate(tt+mb); },
5: function(tt){ return d.setYear(tt+ma); }
};
var dateManip = {
0: function(tt){ return d.setHours(tt); },
1: function(tt){ return d.setMinutes(tt); },
2: function(tt){ set = d.setSeconds(tt); mb = d.getDate() - 1; return set; },
3: function(tt){ set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; },
4: function(tt){ return d.setDate(tt+mb); },
5: function(tt){ return d.setYear(tt+ma); }
};
for( i = 0; i < argc; i++ ){
no = parseInt(argv[i]*1);
if (isNaN(no)) {
for( i = 0; i < argc; i++ ){
no = parseInt(argv[i]*1);
if (isNaN(no)) {
return false;
} else {
// arg is number, lets manipulate date object
if(!dateManip[i](no)){
// failed
return false;
} else {
// arg is number, lets manipulate date object
if(!dateManip[i](no)){
// failed
return false;
}
}
}
return Math.floor(d.getTime()/1000);
}
return Math.floor(d.getTime()/1000);
}
function setFocus() {
$("#work_title").focus();
}
function setFocus() {
$("#work_title").focus();
}
$(document).ready(function() {
setFocus();
$(document).ready(function() {
setFocus();
var checked = $("#expiry_date").attr("checked");
if (checked) {
$("#option2").show();
$("#option3").show();
$("#end_date").attr("checked", true);
} else {
$("#option2").hide();
$("#option3").hide();
$("#end_date").attr("checked", false);
}
var checked = $("#expiry_date").attr("checked");
if (checked) {
$("#option2").show();
$("#option3").show();
$("#end_date").attr("checked", true);
} else {
$("#option2").hide();
$("#option3").hide();
$("#end_date").attr("checked", false);
}
$("#expiry_date").click(function() {
$("#option2").toggle();
});
$("#expiry_date").click(function() {
$("#option2").toggle();
});
$("#end_date").click(function() {
$("#option3").toggle();
});
$("#end_date").click(function() {
$("#option3").toggle();
});
});
</script>';
return $js;
@ -2099,7 +2097,7 @@ function get_work_user_list(
$correction .= "
<script>
$(document).ready(function() {
$('#file_upload_".$item_id."').fileUploadUI({
$('#file_upload_".$item_id."').fileupload({
uploadTable: $('.files'),
downloadTable: $('.files'),
buildUploadRow: function (files, index) {
@ -3313,8 +3311,8 @@ function addWorkComment($courseInfo, $userId, $parentWork, $work, $data)
if (!empty($workParent)) {
$uploadDir = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work'.$workParent['url'];
$newFileName = 'comment_'.$commentId.'_'.php2phps(
api_replace_dangerous_char($fileData['name'])
);
api_replace_dangerous_char($fileData['name'])
);
$newFilePath = $uploadDir.'/'.$newFileName;
$result = move_uploaded_file($fileData['tmp_name'], $newFilePath);
if ($result) {
@ -3453,25 +3451,30 @@ function setWorkUploadForm($form, $uploadFormType = 0)
* @param array $_course
* @param bool $isCorrection
* @param array $workInfo
* @param array $file
*
* @return array
*/
function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo = [])
function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo = [], $file = [])
{
if (empty($_FILES['file']['size'])) {
if (isset($_FILES['file']) && !empty($_FILES['file'])) {
$file = $_FILES['file'];
}
if (empty($file['size'])) {
return array('error' => Display :: return_message(get_lang('UplUploadFailedSizeIsZero'), 'error'));
}
$updir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work/'; //directory path to upload
// Try to add an extension to the file if it has'nt one
$filename = add_ext_on_mime(stripslashes($_FILES['file']['name']), $_FILES['file']['type']);
$filename = add_ext_on_mime(stripslashes($file['name']), $file['type']);
// Replace dangerous characters
$filename = api_replace_dangerous_char($filename);
// Transform any .php file in .phps fo security
$filename = php2phps($filename);
$filesize = filesize($_FILES['file']['tmp_name']);
$filesize = filesize($file['tmp_name']);
if (empty($filesize)) {
return array(
@ -3515,7 +3518,7 @@ function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo
// If we come from the group tools the groupid will be saved in $work_table
if (is_dir($updir.$curdirpath) || empty($curdirpath)) {
$result = move_uploaded_file(
$_FILES['file']['tmp_name'],
$file['tmp_name'],
$updir.$curdirpath.'/'.$new_file_name
);
} else {
@ -3535,6 +3538,7 @@ function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo
return array(
'url' => $url,
'filename' => $filename,
'filesize' => $filesize,
'error' => null
);
}
@ -3640,9 +3644,11 @@ function sendAlertToUsers($workId, $courseInfo, $session_id)
* @param int $sessionId
* @param int $groupId
* @param int $userId
* @param array $file
*
* @return null|string
*/
function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId, $userId)
function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId, $userId, $file = [])
{
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
@ -3659,9 +3665,10 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId,
$message = null;
$filename = null;
$url = null;
$filesize = null;
if ($values['contains_file']) {
$result = uploadWork($workInfo, $courseInfo);
$result = uploadWork($workInfo, $courseInfo, false, [], $file);
if (isset($result['error'])) {
$message = $result['error'];
$saveWork = false;
@ -3670,6 +3677,8 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId,
if (empty($title)) {
$title = isset($result['title']) && !empty($result['title']) ? $result['title'] : get_lang('Untitled');
}
$filesize = isset($result['filesize']) ? $result['filesize'] : null;
$url = $result['url'];
}
@ -3677,6 +3686,8 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId,
$title = get_lang('Untitled');
}
$workData = [];
if ($saveWork) {
$active = '1';
$params = [
@ -3693,6 +3704,7 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId,
'parent_id' => $workInfo['id'],
'session_id' => $sessionId,
'user_id' => $userId,
//'filesize' => $filesize
];
$workId = Database::insert($work_table, $params);
@ -3725,15 +3737,14 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId,
);
sendAlertToUsers($workId, $courseInfo, $sessionId);
Event::event_upload($workId);
$message = Display::return_message(get_lang('DocAdd'));
$workData = get_work_data_by_id($workId);
Display::addFlash(Display::return_message(get_lang('DocAdd')));
}
} else {
if (empty($message)) {
$message = Display::return_message(get_lang('IsNotPosibleSaveTheDocument'), 'error');
}
Display::addFlash(Display::return_message(get_lang('IsNotPosibleSaveTheDocument'), 'error'));
}
return $message;
return $workData;
}
/**
@ -4875,9 +4886,9 @@ function exportAllStudentWorkFromPublication(
$content .= '<h4>'.get_lang('Feedback').': </h4>';
foreach ($comments as $comment) {
$feedback .= get_lang('User').': '.api_get_person_name(
$comment['firstname'],
$comment['lastname']
).'<br />';
$comment['firstname'],
$comment['lastname']
).'<br />';
$feedback .= $comment['comment'].'<br />';
}
}

@ -179,11 +179,10 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
$url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
$url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
$actionsLeft .= Display::toolbarButton(get_lang('UploadCorrections'), $url, 'upload', 'success');
}
echo Display::toolbarAction('toolbar-worklist', array( 0 => $actionsLeft), 1);
if (!empty($my_folder_data['title'])) {
@ -200,7 +199,7 @@ if (!empty($my_folder_data['description'])) {
$contentWork = Security::remove_XSS($my_folder_data['description']);
$html = '';
$html .= Display::panel($contentWork, get_lang('Description'));
echo $html;
echo $html;
}
$check_qualification = intval($my_folder_data['qualification']);

Loading…
Cancel
Save