Updating work from 1.9.x

skala
Julio Montoya 13 years ago
parent 0e59806f28
commit 887b40c337
  1. 35
      main/work/download.php
  2. 6
      main/work/downloadfolder.inc.php
  3. 7
      main/work/edit.php
  4. 31
      main/work/file.php
  5. 31
      main/work/upload.php
  6. 22
      main/work/view.php
  7. 190
      main/work/work.lib.php
  8. 64
      main/work/work.php
  9. 16
      main/work/work_list.php
  10. 12
      main/work/work_list_all.php
  11. 3
      main/work/work_list_others.php

@ -12,6 +12,8 @@
session_cache_limiter('public');
require_once '../inc/global.inc.php';
require_once 'work.lib.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$this_section = SECTION_COURSES;
@ -29,26 +31,29 @@ $id = intval($_GET['id']);
$course_info = api_get_course_info();
if (empty($course_info)) {
api_not_allowed(true);
api_not_allowed(true);
}
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (!empty($course_info['real_id'])) {
if (!empty($course_info['real_id'])) {
$sql = 'SELECT * FROM '.$tbl_student_publication.' WHERE c_id = '.$course_info['real_id'].' AND id = "'.$id.'"';
$result = Database::query($sql);
if ($result && Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
if ($result && Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
$full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
allowOnlySubscribedUser(api_get_user_id(), $row['parent_id'], $course_info['real_id']);
if (empty($item_info)) {
exit;
}
/*
field show_score in table course : 0 => New documents are visible for all users
1 => New documents are only visible for the teacher(s)
1 => New documents are only visible for the teacher(s)
field visibility in table item_property : 0 => eye closed, invisible for all students
1 => eye open
field accepted in table c_student_publication : 0 => eye closed, invisible for all students
@ -56,24 +61,24 @@ if (!empty($course_info['real_id'])) {
(we should have visibility == accepted , otherwise there is an inconsistency in the Database)
field value in table c_course_setting : 0 => Allow learners to delete their own publications = NO
1 => Allow learners to delete their own publications = YES
+------------------+------------------------------+----------------------------+
|Can download work?| doc visible for all = 0 | doc visible for all = 1|
+------------------+------------------------------+----------------------------+
| visibility = 0 | editor only | editor only |
| | | |
+------------------+------------------------------+----------------------------+
+------------------+------------------------------+----------------------------+
| visibility = 1 | editor | editor |
| | + owner of the work | + any student |
+------------------+------------------------------+----------------------------+
+------------------+------------------------------+----------------------------+
(editor = teacher + admin + anybody with right api_is_allowed_to_edit)
*/
$work_is_visible = ($item_info['visibility'] == 1 && $row['accepted'] == 1);
$doc_visible_for_all = ($course_info['show_score'] == 1);
$is_editor = api_is_allowed_to_edit(true,true,true);
$student_is_owner_of_work = ($row['user_id'] == api_get_user_id());
if ($is_editor
|| (!$doc_visible_for_all && $work_is_visible && $student_is_owner_of_work)
|| ($doc_visible_for_all && $work_is_visible)) {
@ -84,7 +89,7 @@ if (!empty($course_info['real_id'])) {
}
} else {
api_not_allowed();
}
}
}
}
exit;
exit;

@ -33,6 +33,9 @@ if (empty($_course) || empty($_course['path'])) {
$sys_course_path = api_get_path(SYS_COURSE_PATH);
//zip library for creation of the zipfile
require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
//Creating a ZIP file
$temp_zip_file = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
@ -68,6 +71,9 @@ if (api_is_allowed_to_edit()) {
} else {
$courseInfo = api_get_course_info();
allowOnlySubscribedUser(api_get_user_id(), $work_id, $courseInfo['real_id']);
$userCondition = null;
// All users

@ -147,7 +147,7 @@ if ($is_allowed_to_edit && !empty($item_id)) {
}
}
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
$form->addElement('hidden', 'item_to_edit', $item_id);
$form->addElement('hidden', 'sec_token', $token);
@ -178,9 +178,10 @@ if ($form->validate()) {
if ($is_author) {
$work_data = get_work_data_by_id($item_to_edit_id);
if (!empty($_POST['title']))
if (!empty($_POST['title'])) {
$title = isset($_POST['title']) ? $_POST['title'] : $work_data['title'];
$description = isset($_POST['description']) ? $_POST['description'] : $work_data['description'];
}
$description = isset($_POST['description']) ? $_POST['description'] : $work_data['description'];
if ($is_allowed_to_edit && ($_POST['qualification'] !='' )) {
$add_to_update = ', qualificator_id ='."'".api_get_user_id()."',";

@ -4,24 +4,25 @@ Use Model\StudentPublication;
Use Model\Course;
/**
* Return either
*
* Return either
*
* - one work item (file)
* - several work items (files) zipped together
*
*
* Used to transfer files to another application through http.
*
*
* Script parameters:
*
* - id id(s) of the work item id=1 or id=1,2,4
*
* - id id(s) of the work item id=1 or id=1,2,4
* - cidReq course code
*
*
* Note this script enables key authentication so access with a key token is possible.
*
*
* @package chamilo.document
* @license see /license.txt
* @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Geneva
*/
require_once __DIR__ . '/../inc/autoload.inc.php';
KeyAuth::enable();
require_once __DIR__ . '/../inc/global.inc.php';
@ -40,7 +41,7 @@ $course = Course::current();
/**
* No files requested. We make sure we return 404 error to tell the client
* that the call failed.
* that the call failed.
*/
if (count($ids) == 0 || empty($course)) {
Response::not_found();
@ -68,7 +69,7 @@ if (count($ids) == 1) {
}
/**
* one folder requested
* one folder requested
*/
$items = array();
$children = $pub->get_children();
@ -92,7 +93,7 @@ if (count($ids) == 1) {
}
/**
* Several files requested. In this case we zip them together.
* Several files requested. In this case we zip them together.
*/
$items = array();
foreach ($ids as $id) {
@ -104,19 +105,19 @@ foreach ($ids as $id) {
$items[] = $pub;
}
/**
* We ignore folders
* We ignore folders
*/
}
/**
* Requested files may not be accessible.
* Requested files may not be accessible.
*/
if (count($items) == 0) {
Response::not_found();
}
/**
* Zip files together.
* Zip files together.
*/
$zip = Chamilo::temp_zip();
foreach ($items as $item) {
@ -126,7 +127,7 @@ foreach ($items as $item) {
}
/**
* Send file for download
* Send file for download
*/
event_download(Uri::here());
DocumentManager::file_send_for_download($zip->get_path(), false, get_lang('StudentPublications') . '.zip');

@ -26,6 +26,7 @@ $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$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_code = api_get_course_id();
$course_info = api_get_course_info();
@ -35,6 +36,8 @@ if (empty($work_id)) {
api_not_allowed(true);
}
allowOnlySubscribedUser($user_id, $work_id, $course_id);
$parent_data = $my_folder_data = get_work_data_by_id($work_id);
if (empty($parent_data)) {
@ -74,11 +77,15 @@ if (!empty($parent_data) && !empty($parent_data['qualification'])) {
}
}*/
$has_expired = false;
$has_ended = false;
$message = null;
if (!empty($my_folder_data)) {
$homework = get_work_assignment_by_id($my_folder_data['id']);
if ($homework['expires_on'] != '0000-00-00 00:00:00' || $homework['ends_on'] != '0000-00-00 00:00:00') {
$time_now = time();
$time_now = time();
if (!empty($homework['expires_on']) && $homework['expires_on'] != '0000-00-00 00:00:00') {
$time_expires = api_strtotime($homework['expires_on'], 'UTC');
@ -103,6 +110,16 @@ if (!empty($my_folder_data)) {
$ends_on = api_convert_and_format_date($homework['ends_on']);
$expires_on = api_convert_and_format_date($homework['expires_on']);
}
if ($has_ended) {
$message = Display::return_message(get_lang('EndDateAlreadyPassed').' '.$ends_on, 'error');
} elseif ($has_expired) {
$message = Display::return_message(get_lang('ExpiryDateAlreadyPassed').' '.$expires_on, 'warning');
} else {
if ($has_expired) {
$message = Display::return_message(get_lang('ExpiryDateToSendWorkIs').' '.$expires_on);
}
}
}
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
@ -119,7 +136,7 @@ $form->addElement('header', $form_title);
$show_progress_bar = false;
if ($submitGroupWorkUrl) {
// For user comming from group space to publish his work
// For user coming from group space to publish his work
$realUrl = str_replace($_configuration['root_sys'], api_get_path(WEB_PATH), str_replace("\\", '/', realpath($submitGroupWorkUrl)));
$form->addElement('hidden', 'newWorkUrl', $submitGroupWorkUrl);
$text_document = $form->addElement('text', 'document', get_lang('Document'));
@ -160,6 +177,12 @@ if ($show_progress_bar) {
$form->add_real_progress_bar('uploadWork', 'file');
}
$documentTemplateData = getDocumentTemplateFromWork($work_id, $course_info);
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);
$error_message = null;
$_course = api_get_course_info();
@ -309,6 +332,9 @@ $htmlHeadXtra[] = to_javascript_work();
Display :: display_header(null);
if (!empty($work_id)) {
echo $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'));
@ -322,6 +348,7 @@ if (!empty($work_id)) {
Display::display_error_message(get_lang('ActionNotAllowed'));
}
} elseif ($student_can_edit_in_session && $has_ended == false) {
$form->display();
} else {
Display::display_error_message(get_lang('ActionNotAllowed'));

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
$language_file = array('exercice', 'work', 'document', 'admin');
require_once '../inc/global.inc.php';
@ -7,30 +9,32 @@ $current_course_tool = TOOL_STUDENTPUBLICATION;
require_once 'work.lib.php';
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$work = get_work_data_by_id($id);
if (empty($id) || empty($work)) {
api_not_allowed();
api_not_allowed();
}
$interbreadcrumb[] = array ('url' => 'work.php', 'name' => get_lang('StudentPublications'));
$my_folder_data = get_work_data_by_id($work['parent_id']);
$course_info = api_get_course_info();
allowOnlySubscribedUser(api_get_user_id(), $work['parent_id'], $course_info['real_id']);
if (user_is_author($id) || $course_info['show_score'] == 0 && $work['active'] == 1 && $work['accepted'] == 1) {
$url_dir = 'work.php?&id=' . $my_folder_data['id'];
$interbreadcrumb[] = array ('url' => $url_dir,'name' => $my_folder_data['title']);
$interbreadcrumb[] = array ('url' => '#','name' => $work['title']);
$interbreadcrumb[] = array ('url' => $url_dir,'name' => $my_folder_data['title']);
$interbreadcrumb[] = array ('url' => '#','name' => $work['title']);
if (($course_info['show_score'] == 0 && $work['active'] == 1 && $work['accepted'] == 1) || api_is_allowed_to_edit() || ($work['user_id'] == api_get_user_id() && $work['active'] == 1 && $work['accepted'] == 1)) {
$tpl = $app['template'];
$tpl = new Template();
$tpl->assign('work', $work);
$template = $tpl->get_template('work/view.tpl');
$template = $tpl->get_template('work/view.tpl');
$content = $tpl->fetch($template);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
$tpl->display_one_col_template();
} else {
api_not_allowed();
api_not_allowed();
}
}
}

@ -17,6 +17,8 @@ require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
define('ADD_DOCUMENT_TO_WORK', false);
/**
* Displays action links (for admins, authorized groups members and authorized students)
* @param string Current dir
@ -491,6 +493,7 @@ function display_student_publications_list($id, $my_folder_data, $work_parents,
$group_id = api_get_group_id();
if (is_array($work_parents)) {
foreach ($work_parents as $work_parent) {
$sql_select_directory = "SELECT
@ -574,7 +577,7 @@ function display_student_publications_list($id, $my_folder_data, $work_parents,
list($d_year, $d_month, $d_day) = explode('-', $parts[0]);
list($d_hour, $d_minute) = explode(':', $parts[1]);
$qualification_input[] = FormValidator :: createElement('text', 'qualification');
$qualification_input[] = $form_folder->createElement('text', 'qualification');
$form_folder -> addGroup($qualification_input, 'qualification', get_lang('QualificationNumeric'));
if (Gradebook::is_active()) {
@ -590,7 +593,7 @@ function display_student_publications_list($id, $my_folder_data, $work_parents,
//Loading gradebook select
load_gradebook_select_in_tool($form_folder);
$weight_input2[] = FormValidator :: createElement('text', 'weight');
$weight_input2[] = $form_folder->createElement('text', 'weight');
$form_folder -> addGroup($weight_input2, 'weight', get_lang('WeightInTheGradebook'), 'size="10"');
$form_folder -> addElement('html', '</div>');
@ -805,36 +808,14 @@ function display_student_publications_list($id, $my_folder_data, $work_parents,
if (api_is_allowed_to_edit()) {
$cant_files = get_count_work($work_data['id']);
/*$sql_document = "SELECT count(*)
FROM $work_table w INNER JOIN $user_table u ON w.user_id = u.user_id
WHERE w.c_id = $course_id AND w.parent_id = ".$work_data['id']." AND w.active IN (0, 1)";*/
} else {
$cant_files = get_count_work($work_data['id'], api_get_user_id());
/*
$user_filter = "user_id = ".api_get_user_id()." AND ";
if ($course_info['show_score'] == 0) {
$user_filter = null;
$isSubscribed = userIsSubscribedToWork(api_get_user_id(), $work_data['id'], $course_id);
if ($isSubscribed == false) {
continue;
}
$sql_document = "SELECT count(*) FROM $work_table s, $iprop_table p
WHERE s.c_id = $course_id AND
p.c_id = $course_id AND
s.id = p.ref AND
p.tool='work' AND
s.accepted='1' AND
$user_filter
parent_id = ".$work_data['id']." AND
active = 1 AND
parent_id = ".$work_parent->id."";*/
$cant_files = get_count_work($work_data['id'], api_get_user_id());
}
//count documents
/*$res_document = Database::query($sql_document);
$count_document = Database::fetch_row($res_document);
$cant_files = $count_document[0];*/
$text_file = get_lang('FilesUpload');
if ($cant_files == 1) {
@ -1793,7 +1774,8 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
if ($work['contains_file']) {
$link_to_download = '<a href="download.php?id='.$item_id.'">'.Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
} else {
$link_to_download = '<a href="view.php?id='.$item_id.'">'.Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a> ';
//api_get_cidreq()
//$link_to_download = '<a href="view.php?id='.$item_id.'">'.Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a> ';
}
$send_to = Portfolio::share('work', $work['id'], array('style' => 'white-space:nowrap;'));
@ -1849,7 +1831,7 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
$action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
}
if (api_get_course_setting('student_delete_own_publication') == 1) {
$action .= '<a href="'.$url.'work.php?'.api_get_cidreq().'&action=delete&amp;item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
$action .= ' <a href="'.$url.'work.php?'.api_get_cidreq().'&action=delete&amp;item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
}
} else {
$action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
@ -2140,3 +2122,151 @@ function display_list_users_without_publication($task_id, $studentId = null)
$column_show[] = 1;
Display::display_sortable_config_table('work', $table_header, $data, $sorting_options, $paging_options, $my_params, $column_show);
}
// Document to work
function addDocumentToWork($documentId, $workId, $courseId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_DOCUMENT);
$params = array(
'document_id' => $documentId,
'work_id' => $workId,
'c_id' => $courseId
);
Database::insert($table, $params);
}
function getDocumentToWork($documentId, $workId, $courseId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_DOCUMENT);
$params = array(
'document_id = ? and work_id = ? and c_id = ?' => array($documentId, $workId, $courseId)
);
return Database::select('*', $table, array('where' => $params));
}
function getAllDocumentToWork($workId, $courseId)
{
if (ADD_DOCUMENT_TO_WORK == false) {
return array();
}
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_DOCUMENT);
$params = array(
'work_id = ? and c_id = ?' => array($workId, $courseId)
);
return Database::select('*', $table, array('where' => $params));
}
function deleteDocumentToWork($documentId, $workId, $courseId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_DOCUMENT);
$params = array(
'document_id = ? and work_id = ? and c_id = ?' => array($documentId, $workId, $courseId)
);
Database::delete($table, $params);
}
// User to work
function addUserToWork($userId, $workId, $courseId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_USER);
$params = array(
'user_id' => $userId,
'work_id' => $workId,
'c_id' => $courseId
);
Database::insert($table, $params);
}
function getUserToWork($userId, $workId, $courseId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_USER);
$params = array(
'user_id = ? and work_id = ? and c_id = ?' => array($userId, $workId, $courseId)
);
return Database::select('*', $table, array('where' => $params));
}
function getAllUserToWork($workId, $courseId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_USER);
$params = array(
'work_id = ? and c_id = ?' => array($workId, $courseId)
);
return Database::select('*', $table, array('where' => $params));
}
function userAddedToWork($userId, $workId, $courseId)
{
/*$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_USER);
$params = array(
'user_id = ? and work_id = ? and c_id = ?' => array($userId, $workId, $courseId)
);
$result = Database::select('count(*)', $table, array('where' => $params));*/
}
function deleteUserToWork($userId, $workId, $courseId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_USER);
$params = array(
'user_id = ? and work_id = ? and c_id = ?' => array($userId, $workId, $courseId)
);
Database::delete($table, $params);
}
function userIsSubscribedToWork($userId, $workId, $courseId)
{
if (ADD_DOCUMENT_TO_WORK == false) {
return true;
}
$subscribedUsers = getAllUserToWork($workId, $courseId);
if (empty($subscribedUsers)) {
return true;
} else {
$subscribedUsersIdList = array();
foreach ($subscribedUsers as $item) {
$subscribedUsersIdList[] = $item['user_id'];
}
if (in_array($userId, $subscribedUsersIdList)) {
return true;
}
}
return false;
}
function allowOnlySubscribedUser($userId, $workId, $courseId)
{
if (ADD_DOCUMENT_TO_WORK == false) {
return true;
}
if (api_is_platform_admin() || api_is_allowed_to_edit()) {
return true;
}
if (userIsSubscribedToWork($userId, $workId, $courseId) == false) {
api_not_allowed(true);
}
}
function getDocumentTemplateFromWork($workId, $courseInfo)
{
$documents = getAllDocumentToWork($workId, $courseInfo['real_id']);
if (!empty($documents)) {
foreach ($documents as $doc) {
$docData = DocumentManager::get_document_data_by_id($doc['document_id'], $courseInfo['code']);
$fileInfo = pathinfo($docData['path']);
if ($fileInfo['extension'] == 'html') {
if (file_exists($docData['absolute_path']) && is_file($docData['absolute_path'])) {
$docData['file_content'] = file_get_contents($docData['absolute_path']);
return $docData;
}
}
}
}
return array();
}

@ -41,7 +41,7 @@ use ChamiloSession as Session;
*
*/
/* INIT SECTION */
/* INIT SECTION */
$language_file = array('exercice', 'work', 'document', 'admin', 'gradebook');
@ -55,6 +55,11 @@ api_protect_course_script(true);
// Including necessary files
require_once 'work.lib.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
$course_id = api_get_course_int_id();
$course_info = api_get_course_info();
$user_id = api_get_user_id();
@ -109,10 +114,6 @@ $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : '';
$uploadvisibledisabled = isset($_REQUEST['uploadvisibledisabled']) ? Database::escape_string($_REQUEST['uploadvisibledisabled']) : $course_info['show_score'];
// get data for publication assignment
$has_expired = false;
$has_ended = false;
//directories management
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$course_dir = $sys_course_path . $_course['path'];
@ -142,10 +143,10 @@ if (isset ($_POST['cancelForm']) && !empty ($_POST['cancelForm'])) {
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !sizeof($_POST)) {
if (strstr($_SERVER['REQUEST_URI'], '?')) {
header('Location: ' . $_SERVER['REQUEST_URI'] . '&submitWork=1');
exit ();
exit();
} else {
header('Location: ' . $_SERVER['REQUEST_URI'] . '?submitWork=1');
exit ();
exit();
}
}
@ -252,59 +253,16 @@ if (!in_array($action, array('add','create_dir'))) {
$token = Security::get_token();
}
if (!empty($my_folder_data)) {
$homework = get_work_assignment_by_id($my_folder_data['id']);
if ($homework['expires_on'] != '0000-00-00 00:00:00' || $homework['ends_on'] != '0000-00-00 00:00:00') {
$time_now = time();
if (!empty($homework['expires_on']) && $homework['expires_on'] != '0000-00-00 00:00:00') {
$time_expires = api_strtotime($homework['expires_on'], 'UTC');
$difference = $time_expires - $time_now;
if ($difference < 0) {
$has_expired = true;
}
}
if (empty($homework['expires_on']) || $homework['expires_on'] == '0000-00-00 00:00:00') {
$has_expired = false;
}
if (!empty($homework['ends_on']) && $homework['ends_on'] != '0000-00-00 00:00:00') {
$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']);
if ($has_ended) {
$message = Display::return_message(get_lang('EndDateAlreadyPassed').' '.$ends_on, 'error');
} elseif ($has_expired) {
$message = Display::return_message(get_lang('ExpiryDateAlreadyPassed').' '.$expires_on, 'warning');
} else {
if ($has_expired) {
$message = Display::return_message(get_lang('ExpiryDateToSendWorkIs').' '.$expires_on);
}
}
}
}
display_action_links($work_id, $curdirpath, $action);
echo $message;
//for teachers
// for teachers
switch ($action) {
case 'settings':
//if posts
if ($is_allowed_to_edit && !empty($_POST['changeProperties'])) {
// Changing the tool setting: default visibility of an uploaded document
// @todo i
// @todo
$query = "UPDATE ".$main_course_table." SET show_score='" . $uploadvisibledisabled . "' WHERE code='" . api_get_course_id() . "'";
$res = Database::query($query);
@ -783,6 +741,8 @@ switch ($action) {
echo $table->toHtml();
echo '</div>';
} else {
display_student_publications_list($work_id, $my_folder_data, $work_parents, $origin, $add_query, null);
}

@ -35,6 +35,7 @@ $courseInfo = api_get_course_info();
$htmlHeadXtra[] = api_get_jqgrid_js();
$url_dir = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq();
allowOnlySubscribedUser(api_get_user_id(), $workId, $courseInfo['real_id']);
if (!empty($group_id)) {
$group_properties = GroupManager :: get_group_properties($group_id);
@ -77,6 +78,21 @@ 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>';
}
$documents = getAllDocumentToWork($workId, $courseInfo['real_id']);
if (!empty($documents)) {
$docContent = '<ul class="nav nav-list well">';
$docContent .= '<li class="nav-header">'.get_lang('Documents').'</li>';
foreach ($documents as $doc) {
$docData = DocumentManager::get_document_data_by_id($doc['document_id'], $courseInfo['code']);
if ($docData) {
$docContent .= '<li><a target="_blank" href="'.$docData['url'].'">'.$docData['title'].'</a></li>';
}
}
$docContent .= '</ul><br />';
echo $docContent;
}
$check_qualification = intval($my_folder_data['qualification']);
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {

@ -66,10 +66,18 @@ echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin.'&gradebook='.$gradebook.'">';
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'),'',ICON_SIZE_MEDIUM).'</a>';
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';
if (ADD_DOCUMENT_TO_WORK) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
echo Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
echo Display::return_icon('user.png', get_lang('AddUser'), '', 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;curdirpath='.$cur_dir_path.'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'),'',ICON_SIZE_MEDIUM)."</a>\n";
Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
$count = get_count_work($workId);
if ($count > 0) {
$display_output .= '<a href="downloadfolder.inc.php?id='.$workId.'">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_MEDIUM).'</a>';

@ -38,8 +38,9 @@ if ($courseInfo['show_score'] == 1) {
api_not_allowed(true);
}
$htmlHeadXtra[] = api_get_jqgrid_js();
allowOnlySubscribedUser(api_get_user_id(), $workId, $courseInfo['real_id']);
$htmlHeadXtra[] = api_get_jqgrid_js();
if (!empty($group_id)) {
$group_properties = GroupManager :: get_group_properties($group_id);

Loading…
Cancel
Save