Minor - fix format code

pull/3064/head
Julio 5 years ago
parent ecd82509bc
commit 1071d4c64b
  1. 18
      public/main/inc/lib/link.lib.php
  2. 1
      public/main/link/link.php
  3. 2
      public/main/work/add_document.php
  4. 3
      public/main/work/add_user.php
  5. 5
      public/main/work/download.php
  6. 11
      public/main/work/download_comment_file.php
  7. 13
      public/main/work/downloadfolder.inc.php
  8. 27
      public/main/work/edit.php
  9. 5
      public/main/work/edit_work.php
  10. 7
      public/main/work/show_file.php
  11. 22
      public/main/work/student_work.php
  12. 11
      public/main/work/upload.php
  13. 5
      public/main/work/upload_corrections.php
  14. 13
      public/main/work/upload_from_template.php
  15. 20
      public/main/work/view.php
  16. 170
      public/main/work/work.lib.php
  17. 33
      public/main/work/work.php
  18. 4
      public/main/work/work_list.php
  19. 18
      public/main/work/work_list_all.php
  20. 8
      public/main/work/work_list_others.php
  21. 14
      public/main/work/work_missing.php

@ -140,7 +140,7 @@ class Link extends Model
}
$sessionId = intval($sessionId);
if ($linkUrl != '') {
$sql = "UPDATE $tblLink SET
$sql = "UPDATE $tblLink SET
url = '$linkUrl'
WHERE id = $linkId AND c_id = $courseId AND session_id = $sessionId";
$resLink = Database::query($sql);
@ -561,7 +561,7 @@ class Link extends Model
if ($category_id != $values['category_id']) {
$sql = "SELECT MAX(display_order)
FROM $tbl_link
FROM $tbl_link
WHERE
c_id = $course_id AND
category_id='".intval($values['category_id'])."'";
@ -915,10 +915,10 @@ class Link extends Model
$withBaseContent,
'ip.session_id'
);
$condition = " AND
$condition = " AND
(
(ip.visibility = '1' $conditionBaseSession) OR
(
(ip.visibility = '0' OR ip.visibility = '1')
$condition_session
@ -935,7 +935,7 @@ class Link extends Model
$condition .= " AND (ip.visibility = '0' OR ip.visibility = '1') $condition ";
}
$sql = "SELECT
$sql = "SELECT
link.id,
ip.session_id,
link.session_id link_session_id,
@ -1085,7 +1085,7 @@ class Link extends Model
$toolbar .= Display::toolbarButton(
get_lang('Move up'),
api_get_self().'?'.api_get_cidreq().'&'.http_build_query($moveLinksParams),
api_get_self().'?'.api_get_cidreq().'&'.http_build_query($moveLinkParams),
'level-up-alt',
'secondary',
['class' => 'btn-sm '.($i === 1 ? 'disabled' : '')],
@ -1095,7 +1095,7 @@ class Link extends Model
$moveLinkParams['action'] = 'move_link_down';
$toolbar .= Display::toolbarButton(
get_lang('Move down'),
api_get_self().'?'.api_get_cidreq().'&'.http_build_query($moveLinksParams),
api_get_self().'?'.api_get_cidreq().'&'.http_build_query($moveLinkParams),
'level-down-alt',
'secondary',
['class' => 'btn-sm '.($i === $numberOfLinks ? 'disabled' : '')],
@ -1596,7 +1596,7 @@ Do you really want to delete this category and its links ?')."')) return false;\
'&sec_token='.$token
);
if ($action == 'addlink') {
if ($action === 'addlink') {
$form->addHeader(get_lang('LinksAdd'));
} else {
$form->addHeader(get_lang('LinksMod'));
@ -1746,7 +1746,7 @@ Do you really want to delete this category and its links ?')."')) return false;\
if (empty($id) || empty($courseId)) {
return [];
}
$sql = "SELECT * FROM $table
$sql = "SELECT * FROM $table
WHERE id = $id AND c_id = $courseId";
$result = Database::query($sql);
$category = Database::fetch_array($result, 'ASSOC');

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -51,6 +52,7 @@ switch ($action) {
header('Location: '.$url);
exit;
}
break;
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -48,6 +49,7 @@ switch ($action) {
Display::addFlash(Display::return_message(get_lang('Added')));
header('Location: '.$url);
exit;
break;
case 'delete':
if (!empty($workId) && !empty($userId)) {
@ -58,6 +60,7 @@ switch ($action) {
header('Location: '.$url);
exit;
}
break;
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -6,8 +7,6 @@
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package chamilo.work
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
@ -27,7 +26,7 @@ if (empty($courseInfo) || empty($id)) {
$correction = isset($_REQUEST['correction']) ? true : false;
$result = downloadFile($id, $courseInfo, $correction);
if ($result === false) {
if (false === $result) {
api_not_allowed(true);
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -6,8 +7,6 @@
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package chamilo.work
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
@ -15,7 +14,7 @@ require_once 'work.lib.php';
// Course protection
api_protect_course_script(true);
$commentId = isset($_GET['comment_id']) ? intval($_GET['comment_id']) : null;
$commentId = isset($_GET['comment_id']) ? (int) ($_GET['comment_id']) : null;
if (empty($commentId)) {
api_not_allowed(true);
}
@ -34,9 +33,9 @@ if (!empty($workData)) {
protectWork($courseInfo, $work['parent_id']);
if (user_is_author($workData['work_id']) ||
$courseInfo['show_score'] == 0 &&
$work['active'] == 1 &&
$work['accepted'] == 1
0 == $courseInfo['show_score'] &&
1 == $work['active'] &&
1 == $work['accepted']
) {
if (Security::check_abs_path(
$workData['file_path'],

@ -1,12 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Functions and main code for the download folder feature.
*
* @todo use ids instead of the path like the document tool
*
* @package chamilo.work
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -62,7 +61,7 @@ $sessionCondition = api_get_session_condition($sessionId, true, false, 'props.se
$filenameCondition = null;
if (array_key_exists('filename', $work_data)) {
$filenameCondition = ", filename";
$filenameCondition = ', filename';
}
$groupIid = 0;
@ -105,11 +104,11 @@ if (api_is_allowed_to_edit() || api_is_coach()) {
$userCondition = '';
// All users
if ($courseInfo['show_score'] == 0) {
if (0 == $courseInfo['show_score']) {
// Do another filter
} else {
// Only teachers
$userCondition = " AND props.insert_user_id = ".api_get_user_id();
$userCondition = ' AND props.insert_user_id = '.api_get_user_id();
}
//for other users, we need to create a zipfile with only visible files and folders
@ -170,7 +169,7 @@ while ($not_deleted_file = Database::fetch_assoc($query)) {
);
} else {
// Convert texts in html files
$filename = trim($filename).".html";
$filename = trim($filename).'.html';
$work_temp = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().'_'.$filename;
file_put_contents($work_temp, $not_deleted_file['description']);
$files[basename($work_temp)] = $filename;
@ -231,7 +230,7 @@ function diff($arr1, $arr2)
foreach ($arr1 as $av) {
if (!in_array($av, $arr2)) {
$res[$r] = $av;
$r++;
++$r;
}
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -17,8 +18,8 @@ require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$work_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
$work_id = isset($_REQUEST['id']) ? (int) ($_REQUEST['id']) : null;
$item_id = isset($_REQUEST['item_id']) ? (int) ($_REQUEST['item_id']) : null;
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$is_allowed_to_edit = api_is_allowed_to_edit();
@ -46,7 +47,7 @@ $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false) {
if (false == $is_course_member) {
api_not_allowed(true);
}
@ -67,7 +68,7 @@ if (!$is_author) {
// Student's can't edit work only if he can delete his docs.
if (!api_is_allowed_to_edit()) {
if (api_get_course_setting('student_delete_own_publication') != 1) {
if (1 != api_get_course_setting('student_delete_own_publication')) {
api_not_allowed(true);
}
}
@ -130,9 +131,9 @@ $interbreadcrumb[] = ['url' => '#', 'name' => $form_title];
$form = new FormValidator(
'form',
'POST',
api_get_self()."?".api_get_cidreq()."&id=".$work_id,
api_get_self().'?'.api_get_cidreq().'&id='.$work_id,
'',
['enctype' => "multipart/form-data"]
['enctype' => 'multipart/form-data']
);
$form->addElement('header', $form_title);
$show_progress_bar = false;
@ -144,7 +145,7 @@ if ($is_allowed_to_edit && !empty($item_id)) {
FROM $work_table
WHERE c_id = $course_id AND id ='$item_id' ";
$result = Database::query($sql);
if ($result !== false && Database::num_rows($result) > 0) {
if (false !== $result && Database::num_rows($result) > 0) {
$row = Database::fetch_array($result);
if ($row['contains_file'] || !empty($row['url'])) {
$form->addLabel(
@ -165,7 +166,7 @@ $form->addHtmlEditor(
);
$defaults['title'] = $work_item['title'];
$defaults["description"] = $work_item['description'];
$defaults['description'] = $work_item['description'];
$defaults['qualification'] = $work_item['qualification'];
if ($is_allowed_to_edit && !empty($item_id)) {
@ -219,7 +220,7 @@ if ($form->validate()) {
* SPECIAL CASE ! For a work edited
*/
//Get the author ID for that document from the item_property table
$item_to_edit_id = intval($_POST['item_to_edit']);
$item_to_edit_id = (int) ($_POST['item_to_edit']);
$is_author = user_is_author($item_to_edit_id);
if ($is_author) {
@ -231,7 +232,7 @@ if ($form->validate()) {
$description = isset($_POST['description']) ? $_POST['description'] : $work_data['description'];
$add_to_update = null;
if ($is_allowed_to_edit && ($_POST['qualification'] != '')) {
if ($is_allowed_to_edit && ('' != $_POST['qualification'])) {
/*$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()."'";*/
@ -257,7 +258,7 @@ if ($form->validate()) {
'error'
));
} else {
$sql = "UPDATE ".$work_table."
$sql = 'UPDATE '.$work_table."
SET title = '".Database::escape_string($title)."',
description = '".Database::escape_string($description)."'
".$add_to_update."
@ -302,12 +303,12 @@ if (!empty($work_id)) {
$content .= $form->returnForm();
}
} elseif ($is_author) {
if (empty($work_item['qualificator_id']) || $work_item['qualificator_id'] == 0) {
if (empty($work_item['qualificator_id']) || 0 == $work_item['qualificator_id']) {
$content .= $form->returnForm();
} else {
$content .= Display::return_message(get_lang('Action not allowed'), 'error');
}
} elseif ($student_can_edit_in_session && $has_ended == false) {
} elseif ($student_can_edit_in_session && false == $has_ended) {
$content .= $form->returnForm();
} else {
$content .= Display::return_message(get_lang('Action not allowed'), 'error');

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -26,12 +27,12 @@ if ($blockEdition && !api_is_platform_admin()) {
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$workId = isset($_GET['id']) ? intval($_GET['id']) : null;
$workId = isset($_GET['id']) ? (int) ($_GET['id']) : null;
$workData = get_work_data_by_id($workId);
$homework = get_work_assignment_by_id($workId);
$locked = api_resource_is_locked_by_gradebook($workId, LINK_STUDENTPUBLICATION);
if (api_is_platform_admin() == false && $locked == true) {
if (false == api_is_platform_admin() && true == $locked) {
api_not_allowed(true);
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -6,8 +7,6 @@
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package chamilo.work
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once 'work.lib.php';
@ -17,7 +16,7 @@ $this_section = SECTION_COURSES;
// Course protection
api_protect_course_script(true);
$id = intval($_GET['id']);
$id = (int) ($_GET['id']);
$course_info = api_get_course_info();
if (empty($course_info)) {
@ -26,6 +25,6 @@ if (empty($course_info)) {
$result = getFile($id, $course_info, false);
if ($result == false) {
if (false == $result) {
api_not_allowed();
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -10,7 +11,7 @@ api_protect_course_group(GroupManager::GROUP_TOOL_WORK);
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$studentId = isset($_GET['studentId']) ? intval($_GET['studentId']) : null;
$studentId = isset($_GET['studentId']) ? (int) ($_GET['studentId']) : null;
if (empty($studentId)) {
api_not_allowed(true);
@ -49,11 +50,13 @@ switch ($action) {
case 'export_to_pdf':
exportAllWork($studentId, $courseInfo, 'pdf');
exit;
break;
case 'download':
if (api_is_allowed_to_edit()) {
downloadAllFilesPerUser($studentId, $courseInfo);
}
break;
case 'delete_all':
if (api_is_allowed_to_edit()) {
@ -69,6 +72,7 @@ switch ($action) {
header('Location: '.api_get_self().'?studentId='.$studentId.'&'.api_get_cidreq());
exit;
}
break;
}
@ -116,15 +120,15 @@ $headers = [
];
foreach ($headers as $header) {
$table->setHeaderContents($row, $column, $header);
$column++;
++$column;
}
$row++;
++$row;
$column = 0;
$url = api_get_path(WEB_CODE_PATH).'work/';
foreach ($workPerUser as $work) {
$work = $work['work'];
$scoreWeight = intval($work->qualification) == 0 ? null : $work->qualification;
$scoreWeight = 0 == (int) ($work->qualification) ? null : $work->qualification;
$workId = $work->id;
$workExtraData = get_work_assignment_by_id($workId);
@ -132,17 +136,17 @@ foreach ($workPerUser as $work) {
$itemId = $userResult['id'];
$table->setCellContents($row, $column, $work->title.' ['.trim(strip_tags($userResult['title'])).']');
$table->setCellAttributes($row, $column, ['width' => '300px']);
$column++;
++$column;
$table->setCellContents($row, $column, $userResult['sent_date']);
$column++;
++$column;
$dateQualification = !empty($workExtraData['expires_on']) ? api_get_local_time($workExtraData['expires_on']) : '-';
$table->setCellContents($row, $column, $dateQualification);
$column++;
++$column;
$score = null;
$score = $userResult['qualification'];
$table->setCellContents($row, $column, $score);
$column++;
++$column;
// Detail
$links = null;
@ -166,7 +170,7 @@ foreach ($workPerUser as $work) {
$table->setCellContents($row, $column, $links);
$row++;
++$row;
$column = 0;
}
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -35,7 +36,7 @@ $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
);
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false || api_is_invitee()) {
if (false == $is_course_member || api_is_invitee()) {
api_not_allowed(true);
}
@ -69,9 +70,9 @@ $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Upload a document')];
$form = new FormValidator(
'form-work',
'POST',
api_get_self()."?".api_get_cidreq()."&id=".$work_id,
api_get_self().'?'.api_get_cidreq().'&id='.$work_id,
'',
['enctype' => "multipart/form-data"]
['enctype' => 'multipart/form-data']
);
setWorkUploadForm($form, $workInfo['allow_text_assignment']);
@ -127,7 +128,7 @@ $htmlHeadXtra[] = to_javascript_work();
Display::display_header(null);
// Only text
if ($workInfo['allow_text_assignment'] == 1) {
if (1 == $workInfo['allow_text_assignment']) {
$tabs = $form->returnForm();
} else {
$headers = [
@ -153,7 +154,7 @@ if (!empty($work_id)) {
} else {
echo $tabs;
}
} elseif ($student_can_edit_in_session && $validationStatus['has_ended'] == false) {
} elseif ($student_can_edit_in_session && false == $validationStatus['has_ended']) {
echo $tabs;
} else {
Display::addFlash(Display::return_message(get_lang('Action not allowed'), 'error'));

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Symfony\Component\Finder\Finder;
@ -55,9 +56,9 @@ $downloadLink = api_get_path(WEB_CODE_PATH).'work/downloadfolder.inc.php?id='.$w
$form = new FormValidator(
'form',
'POST',
api_get_self()."?".api_get_cidreq()."&id=".$workId,
api_get_self().'?'.api_get_cidreq().'&id='.$workId,
'',
['enctype' => "multipart/form-data"]
['enctype' => 'multipart/form-data']
);
$form->addElement('header', get_lang('Upload corrections'));

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -11,8 +12,8 @@ require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$work_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
$documentId = isset($_REQUEST['document_id']) ? intval($_REQUEST['document_id']) : null;
$work_id = isset($_REQUEST['id']) ? (int) ($_REQUEST['id']) : null;
$documentId = isset($_REQUEST['document_id']) ? (int) ($_REQUEST['document_id']) : null;
$is_allowed_to_edit = api_is_allowed_to_edit();
$course_id = api_get_course_int_id();
@ -40,7 +41,7 @@ $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false) {
if (false == $is_course_member) {
api_not_allowed(true);
}
@ -65,9 +66,9 @@ $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Upload from template')];
$form = new FormValidator(
'form',
'POST',
api_get_self()."?".api_get_cidreq()."&id=".$work_id,
api_get_self().'?'.api_get_cidreq().'&id='.$work_id,
'',
['enctype' => "multipart/form-data"]
['enctype' => 'multipart/form-data']
);
setWorkUploadForm($form, $workInfo['allow_text_assignment']);
$form->addElement('hidden', 'document_id', $documentId);
@ -124,7 +125,7 @@ if (!empty($work_id)) {
} else {
$form->display();
}
} elseif ($student_can_edit_in_session && $validationStatus['has_ended'] == false) {
} elseif ($student_can_edit_in_session && false == $validationStatus['has_ended']) {
$form->display();
} else {
api_not_allowed();

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -13,7 +14,7 @@ if (empty($id) || empty($work)) {
api_not_allowed(true);
}
if ($work['active'] != 1) {
if (1 != $work['active']) {
api_not_allowed(true);
}
$work['title'] = isset($work['title']) ? Security::remove_XSS($work['title']) : '';
@ -43,9 +44,9 @@ $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_is_coach())) ||
(
$courseInfo['show_score'] == 0 &&
$work['active'] == 1 &&
$work['accepted'] == 1
0 == $courseInfo['show_score'] &&
1 == $work['active'] &&
1 == $work['accepted']
)
) {
if ((api_is_allowed_to_edit() || api_is_coach()) || api_is_drh()) {
@ -60,16 +61,16 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
$interbreadcrumb[] = ['url' => '#', 'name' => $work['title']];
if ((
$courseInfo['show_score'] == 0 &&
$work['active'] == 1 &&
$work['accepted'] == 1
0 == $courseInfo['show_score'] &&
1 == $work['active'] &&
1 == $work['accepted']
) ||
(api_is_allowed_to_edit() || api_is_coach()) || user_is_author($id) || $isDrhOfCourse
) {
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : null;
if ($page == 'edit') {
if ('edit' == $page) {
$url = api_get_path(WEB_CODE_PATH).'work/edit.php?id='.$my_folder_data['id'].'&item_id='.$work['id'].'&'.api_get_cidreq();
} else {
$url = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
@ -141,6 +142,7 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
}
header('Location: '.$url);
exit;
break;
case 'delete_attachment':
deleteCommentFile(
@ -151,6 +153,7 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
Display::addFlash(Display::return_message(get_lang('Document deleted')));
header('Location: '.$url);
exit;
break;
case 'delete_correction':
if (isset($work['url_correction']) && !empty($work['url_correction'])) {
@ -164,6 +167,7 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
header('Location: '.$url);
exit;
break;
}

@ -22,13 +22,13 @@ use ChamiloSession as Session;
/**
* Displays action links (for admins, authorized groups members and authorized students).
*
* @param int Whether to show tool options
* @param int Whether to show upload form option
* @param int $id Whether to show tool options
* @param int $action Whether to show upload form option
* @param bool $isTutor
*/
function displayWorkActionLinks($id, $action, $isTutor)
{
$id = $my_back_id = intval($id);
$id = $my_back_id = (int) $id;
if ('list' == $action) {
$my_back_id = 0;
}
@ -85,7 +85,7 @@ function displayWorkActionLinks($id, $action, $isTutor)
function get_work_data_by_path($path, $courseId = 0)
{
$path = Database::escape_string($path);
$courseId = intval($courseId);
$courseId = (int) $courseId;
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
@ -112,7 +112,7 @@ function get_work_data_by_path($path, $courseId = 0)
function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
{
$id = (int) $id;
$courseId = ((int) $courseId) ?: api_get_course_int_id();
$courseId = (int) $courseId ?: api_get_course_int_id();
$course = api_get_course_entity($courseId);
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
@ -166,8 +166,8 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
*/
function get_work_count_by_student($user_id, $work_id)
{
$user_id = intval($user_id);
$work_id = intval($work_id);
$user_id = (int) $user_id;
$work_id = (int) $work_id;
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$sessionCondition = api_get_session_condition($session_id);
@ -185,7 +185,7 @@ function get_work_count_by_student($user_id, $work_id)
$return = 0;
if (Database::num_rows($result)) {
$return = Database::fetch_row($result, 'ASSOC');
$return = intval($return[0]);
$return = (int) ($return[0]);
}
return $return;
@ -199,11 +199,11 @@ function get_work_count_by_student($user_id, $work_id)
*/
function get_work_assignment_by_id($id, $courseId = 0)
{
$courseId = intval($courseId);
$courseId = (int) $courseId;
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
$id = intval($id);
$id = (int) $id;
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$sql = "SELECT * FROM $table
WHERE c_id = $courseId AND publication_id = $id";
@ -229,8 +229,8 @@ function getWorkList($id, $my_folder_data, $add_in_where_query = null, $course_i
{
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$course_id = $course_id ? $course_id : api_get_course_int_id();
$session_id = $session_id ? $session_id : api_get_session_id();
$course_id = $course_id ?: api_get_course_int_id();
$session_id = $session_id ?: api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$group_id = api_get_group_id();
@ -254,7 +254,7 @@ function getWorkList($id, $my_folder_data, $add_in_where_query = null, $course_i
$workInGradeBookLinkId = $linkInfo['id'];
if ($workInGradeBookLinkId) {
if ($is_allowed_to_edit) {
if (0 == intval($my_folder_data['qualification'])) {
if (0 == (int) ($my_folder_data['qualification'])) {
echo Display::return_message(
get_lang('Max weight need to be provided'),
'warning'
@ -350,17 +350,15 @@ function getWorkPerUser($userId, $courseId = 0, $sessionId = 0)
* @param int $groupId
* @param int $course_id
* @param int $sessionId
*
* @return mixed
*/
function getUniqueStudentAttemptsTotal($workId, $groupId, $course_id, $sessionId)
{
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$course_id = intval($course_id);
$workId = intval($workId);
$sessionId = intval($sessionId);
$groupId = intval($groupId);
$course_id = (int) $course_id;
$workId = (int) $workId;
$sessionId = (int) $sessionId;
$groupId = (int) $groupId;
$sessionCondition = api_get_session_condition(
$sessionId,
true,
@ -393,14 +391,11 @@ function getUniqueStudentAttemptsTotal($workId, $groupId, $course_id, $sessionId
}
/**
* @param mixed $workId
* @param int $groupId
* @param int $course_id
* @param int $sessionId
* @param int $userId user id to filter
* @param array $onlyUserList only parse this user list
*
* @return mixed
*/
function getUniqueStudentAttempts(
$workId,
@ -413,19 +408,19 @@ function getUniqueStudentAttempts(
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$course_id = intval($course_id);
$course_id = (int) $course_id;
$workCondition = null;
if (is_array($workId)) {
$workId = array_map('intval', $workId);
$workId = implode("','", $workId);
$workCondition = " w.parent_id IN ('".$workId."') AND";
} else {
$workId = intval($workId);
$workId = (int) $workId;
$workCondition = ' w.parent_id = '.$workId.' AND';
}
$sessionId = intval($sessionId);
$groupId = intval($groupId);
$sessionId = (int) $sessionId;
$groupId = (int) $groupId;
$studentCondition = null;
if (!empty($onlyUserList)) {
@ -464,7 +459,7 @@ function getUniqueStudentAttempts(
w.active IN (0, 1) $studentCondition
";
if (!empty($userId)) {
$userId = intval($userId);
$userId = (int) $userId;
$sql .= ' AND u.user_id = '.$userId;
}
$sql .= ' GROUP BY u.user_id, w.parent_id) as t';
@ -625,15 +620,15 @@ function build_work_directory_selector($folders, $curdirpath, $group_dir = '')
$form .= '<option value="/">/ ('.get_lang('root').')</option>';
if (is_array($folders)) {
foreach ($folders as $folder) {
$selected = ($curdirpath == $folder) ? ' selected="selected"' : '';
$selected = $curdirpath == $folder ? ' selected="selected"' : '';
$form .= '<option'.$selected.' value="'.$folder.'">'.$folder.'</option>'."\n";
}
}
} else {
foreach ($folders as $folder) {
$selected = ($curdirpath == $folder) ? ' selected="selected"' : '';
$selected = $curdirpath == $folder ? ' selected="selected"' : '';
$display_folder = substr($folder, strlen($group_dir));
$display_folder = ('' == $display_folder) ? '/ ('.get_lang('root').')' : $display_folder;
$display_folder = '' == $display_folder ? '/ ('.get_lang('root').')' : $display_folder;
$form .= '<option'.$selected.' value="'.$folder.'">'.$display_folder.'</option>'."\n";
}
}
@ -660,7 +655,7 @@ function build_work_directory_selector($folders, $curdirpath, $group_dir = '')
function build_work_move_to_selector($folders, $curdirpath, $move_file, $group_dir = '')
{
$course_id = api_get_course_int_id();
$move_file = intval($move_file);
$move_file = (int) $move_file;
$tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "SELECT title, url FROM $tbl_work
WHERE c_id = $course_id AND id ='".$move_file."'";
@ -704,7 +699,7 @@ function build_work_move_to_selector($folders, $curdirpath, $move_file, $group_d
) {
//cannot copy dir into his own subdir
$display_folder = substr($folder, strlen($group_dir));
$display_folder = ('' == $display_folder) ? '/ ('.get_lang('root').')' : $display_folder;
$display_folder = '' == $display_folder ? '/ ('.get_lang('root').')' : $display_folder;
//$form .= '<option value="'.$fid.'">'.$display_folder.'</option>'."\n";
$options[$fid] = $display_folder;
}
@ -904,7 +899,7 @@ function get_work_path($id)
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$course_id = api_get_course_int_id();
$sql = 'SELECT url FROM '.$table.'
WHERE c_id = '.$course_id.' AND id='.intval($id);
WHERE c_id = '.$course_id.' AND id='.(int) $id;
$res = Database::query($sql);
if (Database::num_rows($res)) {
$row = Database::fetch_array($res);
@ -931,8 +926,8 @@ function updateWorkUrl($id, $new_path, $parent_id)
}
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$course_id = api_get_course_int_id();
$id = intval($id);
$parent_id = intval($parent_id);
$id = (int) $id;
$parent_id = (int) $parent_id;
$sql = "SELECT * FROM $table
WHERE c_id = $course_id AND id = $id";
@ -949,9 +944,8 @@ function updateWorkUrl($id, $new_path, $parent_id)
url = '$new_url',
parent_id = '$parent_id'
WHERE c_id = $course_id AND id = $id";
$res = Database::query($sql);
return $res;
return Database::query($sql);
}
}
@ -966,7 +960,7 @@ function updateWorkUrl($id, $new_path, $parent_id)
function updateDirName($work_data, $newPath)
{
$course_id = $work_data['c_id'];
$work_id = intval($work_data['iid']);
$work_id = (int) ($work_data['iid']);
$oldPath = $work_data['url'];
$originalNewPath = Database::escape_string($newPath);
$newPath = Database::escape_string($newPath);
@ -995,7 +989,7 @@ function updateDirName($work_data, $newPath)
*/
function to_javascript_work()
{
$js = '<script>
return '<script>
function updateDocumentTitle(value) {
var temp = value.indexOf("/");
//linux path
@ -1053,8 +1047,6 @@ function to_javascript_work()
});
});
</script>';
return $js;
}
/**
@ -1162,11 +1154,11 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null)
$extra_conditions .= ' AND work.parent_id = '.$work_id.' ';
$where_condition = null;
if (!empty($notMeUserId)) {
$where_condition .= ' AND u.user_id <> '.intval($notMeUserId);
$where_condition .= ' AND u.user_id <> '.(int) $notMeUserId;
}
if (!empty($onlyMeUserId)) {
$where_condition .= ' AND u.user_id = '.intval($onlyMeUserId);
$where_condition .= ' AND u.user_id = '.(int) $onlyMeUserId;
}
$repo = Container::getStudentPublicationRepository();
@ -1329,7 +1321,7 @@ function getWorkListStudent(
$count = getTotalWorkComment($workList, $courseInfo);
$lastWork = getLastWorkStudentFromParentByUser($userId, $work, $courseInfo);
if (!is_null($count) && !empty($count)) {
if (null !== $count && !empty($count)) {
$urlView = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$lastWork['id'].'&'.api_get_cidreq();
$feedback = '&nbsp;'.Display::url(
@ -1342,7 +1334,7 @@ function getWorkListStudent(
}
if (!empty($lastWork)) {
$work['last_upload'] = (!empty($lastWork['qualification'])) ? $lastWork['qualification_rounded'].' - ' : '';
$work['last_upload'] = !empty($lastWork['qualification']) ? $lastWork['qualification_rounded'].' - ' : '';
$work['last_upload'] .= api_get_local_time($lastWork['sent_date']);
}
@ -1399,8 +1391,8 @@ function getWorkListTeacher(
}
$column = !empty($column) ? Database::escape_string($column) : 'sent_date';
$start = intval($start);
$limit = intval($limit);
$start = (int) $start;
$limit = (int) $limit;
$works = [];
// Get list from database
@ -1663,7 +1655,7 @@ function get_work_user_list_from_documents(
$work_data = get_work_data_by_id($workId);
$qualificationExists = false;
if (!empty($work_data['qualification']) && intval($work_data['qualification']) > 0) {
if (!empty($work_data['qualification']) && (int) ($work_data['qualification']) > 0) {
$qualificationExists = true;
}
@ -1797,7 +1789,7 @@ function get_work_user_list(
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$session_id = $sessionId ? $sessionId : api_get_session_id();
$session_id = $sessionId ?: api_get_session_id();
$group_id = api_get_group_id();
$course_info = api_get_course_info();
$course_info = empty($course_info) ? api_get_course_info_by_id($courseId) : $course_info;
@ -1988,7 +1980,7 @@ function get_work_user_list(
$qualification_exists = false;
if (!empty($work_data['qualification']) &&
intval($work_data['qualification']) > 0
(int) ($work_data['qualification']) > 0
) {
$qualification_exists = true;
}
@ -2048,7 +2040,7 @@ function get_work_user_list(
$feedback = '';
$count = getWorkCommentCount($item_id, $course_info);
if (!is_null($count) && !empty($count)) {
if (null !== $count && !empty($count)) {
if ($qualification_exists) {
$feedback .= ' ';
}
@ -2282,7 +2274,7 @@ function get_work_user_list(
/**
* Send reminder to users who have not given the task.
*
* @param int
* @param int $task_data
*
* @return array
*
@ -2502,8 +2494,8 @@ function user_is_author($itemId, $userId = null, $courseId = 0, $sessionId = 0)
/**
* Get list of users who have not given the task.
*
* @param int
* @param int
* @param int $task_id
* @param int $studentId
*
* @return array
*
@ -2523,7 +2515,7 @@ function get_list_users_without_publication($task_id, $studentId = 0)
// Condition for the session
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$task_id = intval($task_id);
$task_id = (int) $task_id;
$sessionCondition = api_get_session_condition($session_id);
if (0 == $session_id) {
@ -2561,7 +2553,7 @@ function get_list_users_without_publication($task_id, $studentId = 0)
}
if (!empty($studentId)) {
$sql_users .= ' AND u.user_id = '.intval($studentId);
$sql_users .= ' AND u.user_id = '.(int) $studentId;
}
$group_id = api_get_group_id();
@ -2609,7 +2601,7 @@ function get_list_users_without_publication($task_id, $studentId = 0)
/**
* Display list of users who have not given the task.
*
* @param int task id
* @param int $task_id task id
* @param int $studentId
*
* @author cvargas carlos.vargas@beeznest.com cfasanando, christian.fasanado@beeznest.com
@ -2636,7 +2628,7 @@ function display_list_users_without_publication($task_id, $studentId = null)
$my_params['list'] = Security::remove_XSS($_GET['list']);
}
$my_params['origin'] = $origin;
$my_params['id'] = intval($_GET['id']);
$my_params['id'] = (int) ($_GET['id']);
//$column_show
$column_show[] = 1;
@ -2701,12 +2693,12 @@ function getDocumentToWorkPerUser($documentId, $workId, $courseId, $sessionId, $
$workRel = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_DOCUMENT);
$work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$documentId = intval($documentId);
$workId = intval($workId);
$courseId = intval($courseId);
$userId = intval($userId);
$sessionId = intval($sessionId);
$active = intval($active);
$documentId = (int) $documentId;
$workId = (int) $workId;
$courseId = (int) $courseId;
$userId = (int) $userId;
$sessionId = (int) $sessionId;
$active = (int) $active;
$sessionCondition = api_get_session_condition($sessionId);
$sql = "SELECT w.* FROM $work w
@ -2815,7 +2807,7 @@ function getAllUserToWork($workId, $courseId, $getCount = false)
'simple'
);
if (!empty($result)) {
$count = intval($result['count']);
$count = (int) ($result['count']);
}
return $count;
@ -3109,7 +3101,7 @@ function getWorkCommentCount($id, $courseInfo = [])
}
$commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
$id = intval($id);
$id = (int) $id;
$sql = "SELECT count(*) as count
FROM $commentTable
@ -3146,12 +3138,12 @@ function getWorkCommentCountFromParent(
if (empty($sessionId)) {
$sessionId = api_get_session_id();
} else {
$sessionId = intval($sessionId);
$sessionId = (int) $sessionId;
}
$work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
$parentId = intval($parentId);
$parentId = (int) $parentId;
$sessionCondition = api_get_session_condition($sessionId, false, false, 'w.session_id');
$sql = "SELECT count(*) as count
@ -3193,13 +3185,13 @@ function getLastWorkStudentFromParent(
if (empty($sessionId)) {
$sessionId = api_get_session_id();
} else {
$sessionId = intval($sessionId);
$sessionId = (int) $sessionId;
}
$work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sessionCondition = api_get_session_condition($sessionId, false);
$commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);
$parentId = intval($parentId);
$parentId = (int) $parentId;
$sql = "SELECT w.*
FROM $commentTable c INNER JOIN $work w
@ -3214,9 +3206,7 @@ function getLastWorkStudentFromParent(
$result = Database::query($sql);
if (Database::num_rows($result)) {
$comment = Database::fetch_array($result, 'ASSOC');
return $comment;
return Database::fetch_array($result, 'ASSOC');
}
return [];
@ -3245,10 +3235,10 @@ function getLastWorkStudentFromParentByUser(
if (empty($sessionId)) {
$sessionId = api_get_session_id();
} else {
$sessionId = intval($sessionId);
$sessionId = (int) $sessionId;
}
$userId = intval($userId);
$userId = (int) $userId;
$work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (empty($parentInfo)) {
return false;
@ -3308,9 +3298,7 @@ function formatWorkScore($score, $weight)
$label
);
} else {
$finalScore = $scoreBasedInModel;
return $finalScore;
return $scoreBasedInModel;
}
}
@ -3558,7 +3546,7 @@ function getWorkCommentForm($work, $workParent)
$qualification = $workParent['qualification'];
if (api_is_allowed_to_edit()) {
if (!empty($qualification) && intval($qualification) > 0) {
if (!empty($qualification) && (int) $qualification > 0) {
$model = ExerciseLib::getCourseScoreModel();
if (empty($model)) {
$form->addFloat(
@ -3688,11 +3676,13 @@ function setWorkUploadForm($form, $uploadFormType = 0)
);
$form->addProgress();
$form->addHtmlEditor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
break;
case 1:
// Only text.
$form->addHtmlEditor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
$form->addRule('description', get_lang('Required field'), 'required');
break;
case 2:
// Only file.
@ -3704,6 +3694,7 @@ function setWorkUploadForm($form, $uploadFormType = 0)
);
$form->addProgress();
$form->addRule('file', get_lang('Required field'), 'required');
break;
}
@ -3779,7 +3770,7 @@ function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo
if (!empty($workInfo['url'])) {
$new_file_name = basename($workInfo['url']).'_correction';
} else {
$new_file_name = $new_file_name.'_correction';
$new_file_name .= '_correction';
}
}
@ -4136,7 +4127,7 @@ function processWorkForm(
if ($showFlashMessage) {
Display::addFlash(
Display::return_message(
$message ? $message : get_lang('Impossible to save the document'),
$message ?: get_lang('Impossible to save the document'),
'error'
)
);
@ -4277,6 +4268,7 @@ function addDir($formValues, $user_id, $courseInfo, $groupId, $sessionId = 0)
$course_id,
$sessionId
);
break;
}
@ -4293,7 +4285,7 @@ function agendaExistsForWork($workId, $courseInfo)
{
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$courseId = $courseInfo['real_id'];
$workId = intval($workId);
$workId = (int) $workId;
$sql = "SELECT add_to_calendar FROM $workTable
WHERE c_id = $courseId AND publication_id = ".$workId;
@ -4351,7 +4343,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$workId = intval($workId);
$workId = (int) $workId;
$now = api_get_utc_datetime();
$course_id = $courseInfo['real_id'];
@ -4542,8 +4534,8 @@ function deleteAllWorkPerUser($userId, $courseInfo)
}
/**
* @param int $item_id
* @param array course info
* @param int $item_id
* @param array $courseInfo course info
*
* @return bool
*/
@ -4736,7 +4728,7 @@ function getFormWork($form, $defaults = [], $workId = 0)
// ScoreOfAssignment
$form->addElement('text', 'qualification', get_lang('ScoreNumeric'));
if ((0 != $sessionId && Gradebook::is_active()) || 0 == $sessionId) {
if (0 != $sessionId && Gradebook::is_active() || 0 == $sessionId) {
$form->addElement(
'checkbox',
'make_calification',
@ -5013,8 +5005,8 @@ function getWorkUserList($courseCode, $sessionId, $groupId, $start, $limit, $sid
} else {
$limitString = null;
if (!empty($start) && !empty($limit)) {
$start = intval($start);
$limit = intval($limit);
$start = (int) $start;
$limit = (int) $limit;
$limitString = " LIMIT $start, $limit";
}
@ -5351,6 +5343,7 @@ function exportAllWork($userId, $courseInfo, $format = 'pdf')
);
}
}
break;
}
}
@ -5485,6 +5478,7 @@ function exportAllStudentWorkFromPublication(
}
exit;
}
break;
}
}

@ -1,9 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.work
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
@ -31,12 +29,12 @@ $origin = api_get_origin();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
// Download folder
if ($action === 'downloadfolder') {
if ('downloadfolder' === $action) {
require 'downloadfolder.inc.php';
}
$display_upload_form = false;
if ($action === 'upload_form') {
if ('upload_form' === $action) {
$display_upload_form = true;
}
@ -69,23 +67,23 @@ if (!empty($groupId)) {
$interbreadcrumb[] = ['url' => $url_dir, 'name' => $my_folder_data['title']];
}
if ($action == 'upload_form') {
if ('upload_form' == $action) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('Upload a document'),
];
}
if ($action == 'create_dir') {
if ('create_dir' == $action) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('Create assignment'),
];
}
} else {
if ($origin != 'learnpath') {
if ('learnpath' != $origin) {
if (isset($_GET['id']) &&
!empty($_GET['id']) || $display_upload_form || $action == 'create_dir'
!empty($_GET['id']) || $display_upload_form || 'create_dir' == $action
) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
@ -102,11 +100,11 @@ if (!empty($groupId)) {
];
}
if ($action === 'upload_form') {
if ('upload_form' === $action) {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Upload a document')];
}
if ($action === 'create_dir') {
if ('create_dir' === $action) {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Create assignment')];
}
}
@ -189,6 +187,7 @@ switch ($action) {
} else {
$content = $form->returnForm();
}
break;
case 'delete_dir':
if ($is_allowed_to_edit) {
@ -204,6 +203,7 @@ switch ($action) {
header('Location: '.$currentUrl);
exit;
}
break;
case 'move':
// Move file form request
@ -218,16 +218,17 @@ switch ($action) {
);
}
}
break;
case 'move_to':
/* Move file command */
if ($is_allowed_to_edit) {
$move_to_path = get_work_path($_REQUEST['move_to_id']);
if ($move_to_path == -1) {
if (-1 == $move_to_path) {
$move_to_path = '/';
} elseif (substr($move_to_path, -1, 1) != '/') {
$move_to_path = $move_to_path.'/';
} elseif ('/' != substr($move_to_path, -1, 1)) {
$move_to_path .= '/';
}
// Security fix: make sure they can't move files that are not in the document table
@ -259,6 +260,7 @@ switch ($action) {
header('Location: '.$currentUrl);
exit;
}
break;
case 'visible':
if (!$is_allowed_to_edit) {
@ -342,13 +344,14 @@ switch ($action) {
} else {
$content .= Display::panel(showStudentWorkGrid());
}
break;
}
Display::display_header(null);
Display::display_introduction_section(TOOL_STUDENTPUBLICATION);
if ($origin === 'learnpath') {
if ('learnpath' === $origin) {
echo '<div style="height:15px">&nbsp;</div>';
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CStudentPublication;
@ -20,7 +21,7 @@ if (empty($workId) || empty($courseInfo)) {
// Student publications are saved with the iid in a LP
$origin = api_get_origin();
if ($origin === 'learnpath') {
if ('learnpath' === $origin) {
$em = Database::getManager();
/** @var CStudentPublication $work */
$work = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->findOneBy(
@ -144,6 +145,7 @@ switch ($action) {
} else {
Display::addFlash(Display::return_message(get_lang('The document has been deleted.')));
}
break;
}

@ -89,6 +89,7 @@ switch ($action) {
}
}
}
break;
case 'delete':
/* Delete document */
@ -104,6 +105,7 @@ switch ($action) {
);
}
}
break;
case 'delete_correction':
$result = get_work_user_list(null, null, null, null, $workId);
@ -118,12 +120,13 @@ switch ($action) {
}
header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
exit;
break;
case 'make_visible':
/* Visible */
if ($is_allowed_to_edit) {
if (!empty($itemId)) {
if (isset($itemId) && $itemId == 'all') {
if (isset($itemId) && 'all' == $itemId) {
} else {
makeVisible($itemId, $courseInfo);
Display::addFlash(
@ -132,11 +135,12 @@ switch ($action) {
}
}
}
break;
case 'make_invisible':
/* Invisible */
if (!empty($itemId)) {
if (isset($itemId) && $itemId == 'all') {
if (isset($itemId) && 'all' == $itemId) {
} else {
makeInvisible($itemId, $courseInfo);
Display::addFlash(
@ -144,6 +148,7 @@ switch ($action) {
);
}
}
break;
case 'export_pdf':
exportAllStudentWorkFromPublication(
@ -152,6 +157,7 @@ switch ($action) {
$sessionId,
'pdf'
);
break;
}
@ -179,7 +185,7 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
$actionsLeft .= Display::return_icon('pdf.png', get_lang('Export'), '', 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;list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('View missing assignments'), '', ICON_SIZE_MEDIUM)."</a>";
Display::return_icon('exercice_uncheck.png', get_lang('View missing assignments'), '', ICON_SIZE_MEDIUM).'</a>';
$editLink = '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
$editLink .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
@ -488,13 +494,13 @@ if ($allowAntiPlagiarism) {
$html .= '<div class="btn-toolbar">';
$html .= '<div class="btn-group">';
$html .= '<a class="btn btn-default" href="?'
.'&amp;'."gbox_results".'&amp;'.'selectall=1" onclick="javascript: setCheckbox(true, \''
."gbox_results".'\'); return false;">'
.'&amp;'.'gbox_results'.'&amp;'.'selectall=1" onclick="javascript: setCheckbox(true, \''
.'gbox_results'.'\'); return false;">'
.get_lang('Select all')
.'</a>';
$html .= '<a class="btn btn-default" href="?'
.'" onclick="javascript: setCheckbox(false, \''
."gbox_results"
.'gbox_results'
.'\'); return false;">'
.get_lang('UnSelect all')
.'</a> ';

@ -10,7 +10,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;
if (empty($workId)) {
api_not_allowed(true);
@ -28,7 +28,7 @@ $group_id = api_get_group_id();
$courseInfo = api_get_course_info();
// not all users
if ($courseInfo['show_score'] == 1) {
if (1 == $courseInfo['show_score']) {
api_not_allowed(true);
}
@ -86,7 +86,7 @@ if (!empty($my_folder_data['description'])) {
Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
}
$check_qualification = intval($my_folder_data['qualification']);
$check_qualification = (int) ($my_folder_data['qualification']);
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
$type = 'simple';
@ -177,7 +177,7 @@ if (!empty($work_data['enable_qualification']) && !empty($check_qualification))
'width' => '40',
'align' => 'left',
'search' => 'false',
'wrap_cell' => "true",
'wrap_cell' => 'true',
],
[
'name' => 'sent_date',

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -10,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;
$group_id = api_get_group_id();
$user_id = api_get_user_id();
@ -48,6 +49,7 @@ switch ($action) {
}
Security::clear_token();
}
break;
}
@ -91,7 +93,7 @@ $interbreadcrumb[] = [
'name' => $my_folder_data['title'],
];
if (isset($_GET['list']) && $_GET['list'] == 'with') {
if (isset($_GET['list']) && 'with' == $_GET['list']) {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Learners who sent their work')];
} else {
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Learners who didn\'t send their work')];
@ -104,15 +106,15 @@ echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?id='.$workI
Display::return_icon('back.png', get_lang('Back to Assignments list'), '', ICON_SIZE_MEDIUM).'</a>';
$output = '';
if (!empty($workId)) {
if (empty($_GET['list']) or Security::remove_XSS($_GET['list']) == 'with') {
if (empty($_GET['list']) or 'with' == Security::remove_XSS($_GET['list'])) {
$output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$workId.'&list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('ViewLearners who didn\'t send their work'), '', ICON_SIZE_MEDIUM).
"</a>";
'</a>';
} else {
if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'send_mail')) {
if (!isset($_GET['action']) || (isset($_GET['action']) && 'send_mail' != $_GET['action'])) {
$output .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&id='.$workId.'&list=without&action=send_mail&sec_token='.$token.'">'.
Display::return_icon('mail_send.png', get_lang('Send a reminder'), '', ICON_SIZE_MEDIUM).
"</a>";
'</a>';
} else {
$output .= Display::return_icon('mail_send_na.png', get_lang('Send a reminder'), '', ICON_SIZE_MEDIUM);
}

Loading…
Cancel
Save