Fix file upload using extra field type "work" see BT#13533

- Show "work" extra fields in the teacher and student view.
pull/2487/head
jmontoyaa 7 years ago
parent 2c6e8f8c97
commit d8bfcdf073
  1. 16
      main/inc/lib/extra_field_value.lib.php
  2. 24
      main/work/work.lib.php
  3. 5
      main/work/work.php
  4. 2
      main/work/work_list.php
  5. 9
      main/work/work_list_all.php

@ -132,6 +132,7 @@ class ExtraFieldValue extends Model
$commentVariable = 'extra_'.$field_variable.'_comment';
$comment = isset($params[$commentVariable]) ? $params[$commentVariable] : null;
$dirPermissions = api_get_permissions_for_new_directories();
switch ($extraFieldInfo['field_type']) {
case ExtraField::FIELD_TYPE_TAG:
@ -214,7 +215,6 @@ class ExtraFieldValue extends Model
$em->flush();
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
$dirPermissions = api_get_permissions_for_new_directories();
switch ($this->type) {
case 'course':
$fileDir = api_get_path(SYS_UPLOAD_PATH)."courses/";
@ -228,6 +228,10 @@ class ExtraFieldValue extends Model
$fileDir = UserManager::getUserPathById($params['item_id'], 'system');
$fileDirStored = UserManager::getUserPathById($params['item_id'], 'last');
break;
case 'work':
$fileDir = api_get_path(SYS_UPLOAD_PATH).'work/';
$fileDirStored = 'work/';
break;
}
$fileName = ExtraField::FIELD_TYPE_FILE_IMAGE."_{$params['item_id']}.png";
@ -254,21 +258,23 @@ class ExtraFieldValue extends Model
}
break;
case ExtraField::FIELD_TYPE_FILE:
$dirPermissions = api_get_permissions_for_new_directories();
switch ($this->type) {
case 'course':
$fileDir = api_get_path(SYS_UPLOAD_PATH)."courses/";
$fileDir = api_get_path(SYS_UPLOAD_PATH).'courses/';
$fileDirStored = "courses/";
break;
case 'session':
$fileDir = api_get_path(SYS_UPLOAD_PATH)."sessions/";
$fileDir = api_get_path(SYS_UPLOAD_PATH).'sessions/';
$fileDirStored = "sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($params['item_id'], 'system');
$fileDirStored = UserManager::getUserPathById($params['item_id'], 'last');
break;
case 'work':
$fileDir = api_get_path(SYS_UPLOAD_PATH).'work/';
$fileDirStored = "work/";
break;
}
$cleanedName = api_replace_dangerous_char($value['name']);

@ -4732,8 +4732,8 @@ function getFormWork($form, $defaults = [], $workId = 0)
$form->addElement('select', 'allow_text_assignment', get_lang('DocumentType'), getUploadDocumentType());
// Extra fields
$extra_field = new ExtraField('work');
$extra = $extra_field->addElements($form, $workId);
$extraField = new ExtraField('work');
$extra = $extraField->addElements($form, $workId);
$htmlHeadXtra[] = '
<script>
@ -5629,3 +5629,23 @@ function deleteCorrection($courseInfo, $work)
}
}
}
/**
* @param int $workId
* @return string
*/
function workGetExtraFieldData($workId)
{
$sessionField = new ExtraField('work');
$extraFieldData = $sessionField->getDataAndFormattedValues($workId);
$result = '';
if (!empty($extraFieldData)) {
$result .= '<div class="well">';
foreach ($extraFieldData as $data) {
$result .= $data['text'].': '.$data['value'];
}
$result .= '</div>';
}
return $result;
}

@ -180,8 +180,9 @@ switch ($action) {
$form->addButtonCreate(get_lang('CreateDirectory'));
if ($form->validate()) {
$values = $form->getSubmitValues();
$result = addDir(
$_POST,
$values,
$user_id,
$courseInfo,
$groupId,
@ -357,7 +358,7 @@ switch ($action) {
break;
}
Display :: display_header(null);
Display::display_header(null);
Display::display_introduction_section(TOOL_STUDENTPUBLICATION);
if ($origin === 'learnpath') {

@ -92,6 +92,8 @@ if (!empty($my_folder_data['description'])) {
$content .= Display::panel($contentWork, get_lang('Description'));
}
$content .= workGetExtraFieldData($workId);
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;

@ -42,7 +42,7 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
$user_id = api_get_user_id();
if (!empty($group_id)) {
$group_properties = GroupManager :: get_group_properties($group_id);
$group_properties = GroupManager::get_group_properties($group_id);
$show_work = false;
if (api_is_allowed_to_edit(false, true)) {
@ -213,7 +213,6 @@ if (!empty($my_folder_data['description'])) {
$check_qualification = intval($my_folder_data['qualification']);
$orderName = api_is_western_name_order() ? 'firstname' : 'lastname';
if (!empty($work_data['enable_qualification']) &&
!empty($check_qualification)
) {
@ -365,9 +364,15 @@ $(function() {
</script>
<?php
echo $documentsAddedInWork;
$tableWork = Display::grid_html('results');
echo workGetExtraFieldData($workId);
echo Display::panel($tableWork);
echo '<div class="list-work-results">';
echo '<div class="panel panel-default">';
echo '<div class="panel-body">';

Loading…
Cancel
Save