From 9b7a8cfe58ecc0da9962b81ec14ce22dc3f9ecbc Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 23 Sep 2019 10:26:19 +0200 Subject: [PATCH] Add config 'force_download_doc_before_upload_work' BT#15549 Student publication: force to download document before upload an assignment. --- main/install/configuration.dist.php | 3 ++ main/work/work.lib.php | 2 +- main/work/work_list.php | 51 +++++++++++++++++++++-------- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 45bc20ccaa..1e484678a5 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -1320,6 +1320,9 @@ requires extension "php-soap" sudo apt-get install php-soap // ALTER TABLE c_survey_question ADD parent_option_id INT(11) DEFAULT 0 NOT NULL; //$_configuration['survey_question_dependency'] = true; +// Student publication: force to download document before upload an assignment. +// $_configuration['force_download_doc_before_upload_work' ] = true; + // KEEP THIS AT THE END // -------- Custom DB changes // Add user activation by confirmation email diff --git a/main/work/work.lib.php b/main/work/work.lib.php index b54be1e61b..f9697a972c 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -2969,7 +2969,7 @@ function getAllDocumentsFromWorkToString($workId, $courseInfo) foreach ($documents as $doc) { $docData = DocumentManager::get_document_data_by_id($doc['document_id'], $courseInfo['code']); if ($docData) { - $content .= '
  • '.$docData['title'].'
  • '; + $content .= '
  • '.$docData['title'].'
  • '; } } $content .= '
    '; diff --git a/main/work/work_list.php b/main/work/work_list.php index c40b36de9e..4b0c770dfc 100755 --- a/main/work/work_list.php +++ b/main/work/work_list.php @@ -11,7 +11,7 @@ api_protect_course_script(true); require_once 'work.lib.php'; $this_section = SECTION_COURSES; -$workId = isset($_GET['id']) ? intval($_GET['id']) : null; +$workId = isset($_GET['id']) ? (int) $_GET['id'] : null; $courseInfo = api_get_course_info(); if (empty($workId) || empty($courseInfo)) { @@ -20,7 +20,7 @@ if (empty($workId) || empty($courseInfo)) { // Student publications are saved with the iid in a LP $origin = api_get_origin(); -if ($origin == 'learnpath') { +if ($origin === 'learnpath') { $em = Database::getManager(); /** @var CStudentPublication $work */ $work = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->findOneBy( @@ -73,14 +73,12 @@ $onlyOnePublication = api_get_configuration_value('allow_only_one_student_public if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) { $url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId; $actionsRight = Display::url( - Display::return_icon( - 'upload_file.png', - get_lang('UploadMyAssignment'), - null, - ICON_SIZE_MEDIUM - ).get_lang('UploadMyAssignment'), + Display::returnFontAwesomeIcon( + ' fa-upload' + ). + get_lang('UploadMyAssignment'), $url, - ['class' => 'btn-toolbar'] + ['class' => 'btn btn-primary', 'id' => 'upload_button'] ); } @@ -108,9 +106,8 @@ if (!empty($my_folder_data['description'])) { } $content .= workGetExtraFieldData($workId); - $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; -$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null; +$item_id = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null; switch ($action) { case 'delete': @@ -126,7 +123,7 @@ switch ($action) { $result = getWorkDateValidationStatus($work_data); $content .= $result['message']; -$check_qualification = intval($my_folder_data['qualification']); +$check_qualification = (int) $my_folder_data['qualification']; if (!api_is_invitee()) { if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) { @@ -215,7 +212,7 @@ if (!api_is_invitee()) { 'width' => '60', 'align' => 'left', 'search' => 'false', - 'wrap_cell' => "true", + 'wrap_cell' => 'true', ], [ 'name' => 'qualification', @@ -260,7 +257,33 @@ if (!api_is_invitee()) { '; - $content .= getAllDocumentsFromWorkToString($workId, $courseInfo); + $documents = getAllDocumentsFromWorkToString($workId, $courseInfo); + + if (!empty($documents)) { + $forceDownload = api_get_configuration_value('force_download_doc_before_upload_work'); + if ($forceDownload) { + // Force to download documents first. + $downloadDocumentsFirst = addslashes(get_lang('DownloadDocumentsFirst')); + $content .= ""; + } + } + + $content .= $documents; + $tableWork = Display::grid_html('results'); $content .= Display::panel($tableWork); }