Student publication UI improvements see BT#12100

pull/2487/head
jmontoyaa 9 years ago
parent 39b001c5c3
commit a004e1c9e2
  1. 2
      main/inc/ajax/work.ajax.php
  2. 2
      main/template/default/work/view.tpl
  3. 19
      main/work/edit.php
  4. 2
      main/work/edit_work.php
  5. 2
      main/work/student_work.php
  6. 91
      main/work/view.php
  7. 36
      main/work/work.lib.php
  8. 1
      main/work/work_list_all.php

@ -138,8 +138,8 @@ switch ($action) {
$json['type'] = api_htmlentities($file['type']);
$json['size'] = format_file_size($file['size']);
}
if (isset($result['url'])) {
$json['result'] = Display::return_icon(
'accept.png',

@ -13,6 +13,8 @@
</p>
{% endif %}
{{ score_form }}
{% if work.contains_file and work.show_content %}
<h3>
{{ 'Content' | get_lang }}

@ -177,7 +177,7 @@ $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
/*$sql = "SELECT qualification FROM $work_table
WHERE c_id = $course_id AND id ='$work_id' ";
$result = Database::query($sql);
$row = Database::fetch_array($result);
@ -185,7 +185,7 @@ if ($is_allowed_to_edit && !empty($item_id)) {
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',
@ -239,9 +239,9 @@ if ($form->validate()) {
$add_to_update = null;
if ($is_allowed_to_edit && ($_POST['qualification'] !='' )) {
$add_to_update = ', qualificator_id ='."'".api_get_user_id()."', ";
/*$add_to_update = ', qualificator_id ='."'".api_get_user_id()."', ";
$add_to_update .= ' qualification = '."'".api_float_val($_POST['qualification'])."',";
$add_to_update .= ' date_of_qualification = '."'".api_get_utc_datetime()."'";
$add_to_update .= ' date_of_qualification = '."'".api_get_utc_datetime()."'";*/
if (isset($_POST['send_email'])) {
$url = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$item_to_edit_id;
@ -306,19 +306,20 @@ if (!empty($work_id)) {
if (api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION)) {
echo Display::display_warning_message(get_lang('ResourceLockedByGradebook'));
} else {
$comments = getWorkComments($work_item);
/*$comments = getWorkComments($work_item);
$template = $tpl->get_template('work/comments.tpl');
$tpl->assign('comments', $comments);
$commentForm = getWorkCommentForm($work_item, 'edit');
*/
if (api_is_allowed_to_session_edit()) {
$tpl->assign('form', $commentForm);
//$tpl->assign('form', $commentForm);
}
$content .= $form->returnForm();
$content .= $tpl->fetch($template);
/*$content .= $form->returnForm();
$content .= $tpl->fetch($template);*/
}
} elseif ($is_author) {
if (empty($work_item['qualificator_id']) || $work_item['qualificator_id'] == 0) {

@ -104,7 +104,7 @@ if ($form->validate()) {
updateDirName($workData, $params['new_dir']);
$currentUrl = api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('FolderEdited'), 'success'));
Display::addFlash(Display::return_message(get_lang('Updated'), 'success'));
header('Location: '.$currentUrl);
exit;

@ -177,7 +177,7 @@ foreach ($workPerUser as $work) {
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('rate_work.png', get_lang('Comment')),
Display::return_icon('edit.png', get_lang('Comment')),
$url
);
}

@ -72,11 +72,66 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
}
switch ($action) {
case 'update_score':
if (api_is_allowed_to_edit()) {
$work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "UPDATE $work_table
SET
qualificator_id = '".api_get_user_id()."',
qualification = '".api_float_val($_POST['qualification'])."',
date_of_qualification = '".api_get_utc_datetime()."'
WHERE c_id = ".$courseInfo['real_id']." AND id = $id";
Database::query($sql);
$resultUpload = uploadWork($my_folder_data, $courseInfo, true, $work);
if ($resultUpload) {
$work_table = Database:: get_course_table(
TABLE_STUDENT_PUBLICATION
);
if (isset($resultUpload['url']) && !empty($resultUpload['url'])) {
$title = isset($resultUpload['filename']) && !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'))
);
}
}
if (isset($_POST['send_email'])) {
$urlToSave = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$id;
$subject = sprintf(get_lang('ThereIsANewWorkFeedback'), $work['title']);
$message = sprintf(get_lang('ThereIsANewWorkFeedbackInWorkXHere'), $work['title'], $urlToSave);
MessageManager::send_message_simple(
$work['user_id'],
$subject,
$message,
api_get_user_id(),
isset($_POST['send_to_drh_users'])
);
Display::addFlash(
Display::return_message(get_lang('MessageSent'))
);
}
Display::addFlash(
Display::return_message(get_lang('Updated'))
);
}
header('Location: '.$url);
exit;
break;
case 'send_comment':
if (isset($_FILES["file"])) {
$_POST['file'] = $_FILES["file"];
}
addWorkComment(
api_get_course_info(),
api_get_user_id(),
@ -161,6 +216,40 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
}
}
$qualification = $my_folder_data['qualification'];
if (api_is_allowed_to_edit() && !empty($qualification) && intval($qualification) > 0) {
$form = new FormValidator(
'form',
'POST',
api_get_self()."?action=update_score&".api_get_cidreq()."&id=".$id,
'',
array('enctype' => "multipart/form-data")
);
$form->addElement('hidden', 'id', $id);
$form->addFloat(
'qualification',
array(get_lang('Qualification'), " / ".$qualification),
false,
[],
false,
0,
$qualification
);
$form->addFile('file', get_lang('Correction'));
$form->addCheckBox(
'send_email',
null,
get_lang('SendMailToStudent')
);
$form->setDefaults(['qualification' => $work['qualification']]);
$form->addButtonUpdate(get_lang('Update'));
$tpl->assign('score_form', $form->returnForm());
} else {
$tpl->assign('score_form', $actions);
}
$tpl->assign('actions', $actions);
if (api_is_allowed_to_session_edit()) {
$tpl->assign('form', $commentForm);

@ -1745,7 +1745,7 @@ function get_work_user_list_from_documents(
$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('default.png', get_lang('View'));
$viewIcon = Display::return_icon('rate_work.png', get_lang('CorrectAndRate'));
$allowEdition = api_get_course_setting('student_delete_own_publication');
$workList = array();
@ -1957,6 +1957,11 @@ function get_work_user_list(
$url = api_get_path(WEB_CODE_PATH).'work/';
$unoconv = api_get_configuration_value('unoconv.binaries');
$loadingText = addslashes(get_lang('Loading'));
$uploadedText = addslashes(get_lang('Uploaded'));
$failsUploadText = addslashes(get_lang('UplNoFileUploaded'));
$failsUploadIcon = Display::return_icon('closed-circle.png', '', [], ICON_SIZE_TINY);
while ($work = Database::fetch_array($result, 'ASSOC')) {
$item_id = $work['id'];
@ -2009,7 +2014,6 @@ function get_work_user_list(
}
$work['qualification_score'] = $work['qualification'];
$add_string = '';
$time_expires = '';
if (!empty($work_assignment['expires_on'])) {
@ -2021,7 +2025,7 @@ function get_work_user_list(
if (!empty($work_assignment['expires_on']) &&
!empty($time_expires) && ($time_expires < api_strtotime($work['sent_date'], 'UTC'))) {
$add_string = Display::label(get_lang('Expired'), 'important');
$add_string = Display::label(get_lang('Expired'), 'important').' - ';
}
if (($can_read && $work['accepted'] == '1') ||
@ -2044,7 +2048,6 @@ function get_work_user_list(
// File name.
$link_to_download = null;
// If URL is present then there's a file to download keep BC.
if ($work['contains_file'] || !empty($work['url'])) {
$link_to_download = '<a href="'.$url.'download.php?id='.$item_id.'&'.api_get_cidreq().'">'.
@ -2069,14 +2072,13 @@ function get_work_user_list(
// Date.
$work_date = api_convert_and_format_date($work['sent_date']);
$date = date_to_str_ago($work['sent_date']). ' ' . $work_date;
$work['formatted_date'] = $work_date . ' - ' . $add_string;
$work['formatted_date'] = $work_date . ' ' . $add_string;
$work['sent_date_from_db'] = $work['sent_date'];
$work['sent_date'] = '<div class="work-date" title="'.$date.'">' . $add_string . ' - ' . $work['sent_date'] . '</div>';
$work['sent_date'] = '<div class="work-date" title="'.$date.'">' . $add_string . ' ' . $work['sent_date'] . '</div>';
// Actions.
$correction = '';
$action = '';
if (api_is_allowed_to_edit()) {
if (!empty($work['url_correction'])) {
@ -2087,16 +2089,13 @@ function get_work_user_list(
}
$action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL).'</a> ';
Display::return_icon('rate_work.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL).'</a> ';
if ($unoconv && empty($work['contains_file'])) {
$action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=export_to_doc&item_id='.$item_id.'" title="'.get_lang('ExportToDoc').'" >'.
Display::return_icon('export_doc.png', get_lang('ExportToDoc'),array(), ICON_SIZE_SMALL).'</a> ';
}
$loadingText = addslashes(get_lang('Loading'));
$uploadedText = addslashes(get_lang('Uploaded'));
$failsUploadText = addslashes(get_lang('UplNoFileUploaded'));
$failsUploadIcon = Display::return_icon('closed-circle.png', '', [], ICON_SIZE_TINY);
$correction = '
<form
id="file_upload_'.$item_id.'"
@ -2138,14 +2137,14 @@ function get_work_user_list(
if ($locked) {
if ($qualification_exists) {
$action .= Display::return_icon('rate_work_na.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL);
$action .= Display::return_icon('edit_na.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL);
} else {
$action .= Display::return_icon('edit_na.png', get_lang('Comment'), array(), ICON_SIZE_SMALL);
}
} else {
if ($qualification_exists) {
$action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Edit').'" >'.
Display::return_icon('rate_work.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
} else {
$action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
@ -2154,7 +2153,12 @@ function get_work_user_list(
if ($work['contains_file']) {
if ($locked) {
$action .= Display::return_icon('move_na.png', get_lang('Move'),array(), ICON_SIZE_SMALL);
$action .= Display::return_icon(
'move_na.png',
get_lang('Move'),
array(),
ICON_SIZE_SMALL
);
} else {
$action .= '<a href="'.$url.'work.php?'.api_get_cidreq().'&action=move&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Move').'">'.
Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).'</a>';
@ -3458,12 +3462,14 @@ function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo
}
$curdirpath = basename($my_folder_data['url']);
// 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(
$file['tmp_name'],
$updir.$curdirpath.'/'.$new_file_name
);
} else {
return array(
'error' => Display :: return_message(

@ -169,7 +169,6 @@ $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
$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>';

Loading…
Cancel
Save