Fix work list for students when a document is added see #2237

pull/2487/head
jmontoyaa 9 years ago
parent 951b90423f
commit 0322bfcfdd
  1. 5
      main/work/add_document.php
  2. 2
      main/work/upload_from_template.php
  3. 80
      main/work/work.lib.php
  4. 2
      main/work/work_list.php
  5. 2
      main/work/work_list_all.php

@ -42,6 +42,7 @@ switch ($action) {
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;
}
@ -49,7 +50,7 @@ switch ($action) {
}
if (empty($docId)) {
Display :: display_header(null);
Display::display_header(null);
$documents = getAllDocumentToWork($workId, api_get_course_int_id());
if (!empty($documents)) {
@ -60,7 +61,7 @@ if (empty($docId)) {
$docData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
if ($docData) {
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?action=delete&id='.$workId.'&document_id='.$documentId.'&'.api_get_cidreq();
$link = Display::url(get_lang('Delete'), $url);
$link = Display::url(get_lang('Remove'), $url, ['class' => 'btn btn-danger']);
echo $docData['title'].' '.$link.'<br />';
}
}

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;

@ -1764,8 +1764,32 @@ function get_work_user_list_from_documents(
$select1 = " SELECT count(u.user_id) as count ";
$select2 = " SELECT count(u.user_id) as count ";
} else {
$select1 = " SELECT DISTINCT u.firstname, u.lastname, u.user_id, w.title, w.parent_id, w.document_id document_id, w.id, qualification, qualificator_id";
$select2 = " SELECT DISTINCT u.firstname, u.lastname, u.user_id, d.title, w.parent_id, d.id document_id, 0, 0, 0";
$select1 = " SELECT DISTINCT
u.firstname,
u.lastname,
u.user_id,
w.title,
w.parent_id,
w.document_id document_id,
w.id, qualification,
qualificator_id,
w.sent_date,
w.contains_file,
w.url
";
$select2 = " SELECT DISTINCT
u.firstname, u.lastname,
u.user_id,
d.title,
w.parent_id,
d.id document_id,
0,
0,
0,
w.sent_date,
w.contains_file,
w.url
";
}
$documentTable = Database::get_course_table(TABLE_DOCUMENT);
@ -1850,12 +1874,19 @@ function get_work_user_list_from_documents(
$urlEdit = api_get_path(WEB_CODE_PATH).'work/edit.php?'.api_get_cidreq();
$urlDelete = api_get_path(WEB_CODE_PATH).'work/work_list.php?action=delete&'.api_get_cidreq();
$urlView = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq();
$urlDownload = api_get_path(WEB_CODE_PATH).'work/download.php?'.api_get_cidreq();
$editIcon = Display::return_icon('edit.png', get_lang('Edit'));
$addIcon = Display::return_icon('add.png', get_lang('Add'));
$deleteIcon = Display::return_icon('delete.png', get_lang('Delete'));
$viewIcon = Display::return_icon('rate_work.png', get_lang('CorrectAndRate'));
$allowEdition = api_get_course_setting('student_delete_own_publication');
$viewIcon = Display::return_icon('default.png', get_lang('View'));
$saveIcon = Display::return_icon(
'save.png',
get_lang('Save'),
[],
ICON_SIZE_SMALL
);
$allowEdition = api_get_course_setting('student_delete_own_publication') == 1;
$workList = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -1867,7 +1898,7 @@ function get_work_user_list_from_documents(
if (empty($documentId)) {
$url = $urlEdit.'&item_id='.$row['id'].'&id='.$workId;
$editLink = Display::url($editIcon, $url);
if ($allowEdition == false) {
if ($allowEdition != 1) {
$editLink = null;
}
} else {
@ -1884,23 +1915,28 @@ function get_work_user_list_from_documents(
$url = $urlEdit.'&item_id='.$newWorkId.'&id='.$workId;
$editLink = Display::url($editIcon, $url);
if ($allowEdition == false) {
$editLink = null;
if ($allowEdition != 1) {
$editLink = '';
}
}
}
if ($allowEdition && !empty($itemId)) {
$deleteLink = Display::url($deleteIcon, $urlDelete.'&item_id='.$itemId.'&id='.$workId);
} else {
$deleteLink = null;
$downloadLink = '';
// If URL is present then there's a file to download keep BC.
if ($row['contains_file'] || !empty($row['url'])) {
$downloadLink = Display::url($saveIcon, $urlDownload.'&id='.$row['id']).'&nbsp;';
}
$viewLink = null;
$viewLink = '';
if (!empty($itemId)) {
$viewLink = Display::url($viewIcon, $urlView.'&id='.$itemId);
}
$deleteLink = '';
if ($allowEdition == 1 && !empty($itemId)) {
$deleteLink = Display::url($deleteIcon, $urlDelete.'&item_id='.$itemId.'&id='.$workId);
}
$row['type'] = null;
if ($qualificationExists) {
@ -1917,11 +1953,11 @@ function get_work_user_list_from_documents(
}
if (!empty($row['sent_date'])) {
$row['sent_date'] = api_get_local_time($row['sent_date']);
$row['sent_date'] = Display::dateToStringAgoAndLongDate($row['sent_date']);
}
if ($userId == $currentUserId) {
$row['actions'] = $viewLink.$editLink.$deleteLink;
$row['actions'] = $downloadLink.$viewLink.$editLink.$deleteLink;
}
if ($addLinkShowed) {
@ -1931,7 +1967,6 @@ function get_work_user_list_from_documents(
$workList[] = $row;
}
return $workList;
}
@ -3648,12 +3683,17 @@ function getWorkDateValidationStatus($homework)
*/
function setWorkUploadForm($form, $uploadFormType = 0)
{
$form->addElement('header', get_lang('UploadADocument'));
$form->addElement('hidden', 'contains_file', 0, array('id'=>'contains_file_id'));
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
$form->addHeader(get_lang('UploadADocument'));
$form->addHidden('contains_file', 0, array('id'=>'contains_file_id'));
$form->addHidden('active', 1);
$form->addHidden('accepted', 1);
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'file_upload'));
$form->addElement('text', 'extension', get_lang('FileExtension'), array('id' => 'file_extension', 'readonly' => 'readonly'));
$form->addElement(
'text',
'extension',
get_lang('FileExtension'),
array('id' => 'file_extension', 'readonly' => 'readonly')
);
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
switch ($uploadFormType) {

@ -169,6 +169,8 @@ if (!api_is_invitee()) {
</script>
';
$content .= getAllDocumentsFromWorkToString($workId, $courseInfo);
$tableWork = Display::grid_html('results');
$content .= Display::panel($tableWork);
}

@ -161,7 +161,7 @@ switch ($action) {
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-upload'));
Display :: display_header(null);
Display::display_header(null);
$documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);

Loading…
Cancel
Save