From 1914b93948262dfa17b5a8b5c6c9a8188b88965d Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Fri, 29 Dec 2017 13:08:20 +0100 Subject: [PATCH] Minor - format code --- main/admin/user_import.php | 4 +- main/dashboard/dashboard_controller.php | 4 - main/inc/lib/api.lib.php | 72 ++++----- main/inc/lib/document.lib.php | 2 +- main/lp/aiccObjective.class.php | 2 - main/lp/learnpath.class.php | 79 +++++----- main/work/work.lib.php | 144 +++++++++--------- plugin/vchamilo/views/editinstance_form.php | 13 +- .../Component/Editor/CkEditor/CkEditor.php | 1 - .../Editor/CkEditor/Toolbar/AgendaStudent.php | 2 +- .../Editor/CkEditor/Toolbar/Basic.php | 13 +- .../Editor/CkEditor/Toolbar/Careers.php | 2 - .../CkEditor/Toolbar/DocumentsStudent.php | 1 - .../Component/Editor/CkEditor/Toolbar/FAQ.php | 2 - .../Editor/CkEditor/Toolbar/Forum.php | 2 - .../Editor/CkEditor/Toolbar/ForumStudent.php | 2 - .../Editor/CkEditor/Toolbar/Glossary.php | 2 - .../CkEditor/Toolbar/LearningPathAuthor.php | 4 +- .../Editor/CkEditor/Toolbar/Messages.php | 2 - .../Editor/CkEditor/Toolbar/Minimal.php | 2 - .../CkEditor/Toolbar/NotebookStudent.php | 2 - .../Editor/CkEditor/Toolbar/PortalNews.php | 2 - .../Editor/CkEditor/Toolbar/Profile.php | 2 - .../Editor/CkEditor/Toolbar/Project.php | 2 - .../CkEditor/Toolbar/ProjectComment.php | 2 - .../Toolbar/ProjectCommentStudent.php | 2 - .../CkEditor/Toolbar/ProjectStudent.php | 2 - .../Editor/CkEditor/Toolbar/Register.php | 4 +- .../Editor/CkEditor/Toolbar/Survey.php | 2 - .../CkEditor/Toolbar/TermsAndConditions.php | 1 - .../CkEditor/Toolbar/TestFreeAnswerStrict.php | 1 - .../Toolbar/TestQuestionDescription.php | 1 - .../CkEditor/Toolbar/ToolbarStartExpanded.php | 2 - .../CkEditor/Toolbar/UniqueAnswerImage.php | 2 +- .../Editor/CkEditor/Toolbar/Wiki.php | 1 - .../Editor/CkEditor/Toolbar/WikiStudent.php | 1 - .../Editor/CkEditor/Toolbar/WikiTask.php | 2 - .../Editor/CkEditor/Toolbar/Work.php | 5 +- .../CoreBundle/Component/Editor/Connector.php | 1 - .../Editor/Driver/CourseUserDriver.php | 1 - .../CoreBundle/Component/Editor/Toolbar.php | 8 +- .../CoreBundle/Component/Utils/ChamiloApi.php | 2 + .../EventListener/LegacyLoginListener.php | 14 +- src/Chamilo/CoreBundle/Menu/NavBuilder.php | 1 - .../Twig/Extension/ChamiloExtension.php | 3 +- .../Component/CourseCopy/Resources/Asset.php | 1 - 46 files changed, 176 insertions(+), 246 deletions(-) diff --git a/main/admin/user_import.php b/main/admin/user_import.php index 18e6557cd6..a6dba248ac 100644 --- a/main/admin/user_import.php +++ b/main/admin/user_import.php @@ -365,9 +365,7 @@ $extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true); $user_id_error = array(); $error_message = ''; -if (isset($_POST['formSent']) && $_POST['formSent'] AND - $_FILES['import_file']['size'] !== 0 -) { +if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['size'] !== 0) { $file_type = $_POST['file_type']; Security::clear_token(); $tok = Security::get_token(); diff --git a/main/dashboard/dashboard_controller.php b/main/dashboard/dashboard_controller.php index cc820e2f93..3e5f1ef03d 100755 --- a/main/dashboard/dashboard_controller.php +++ b/main/dashboard/dashboard_controller.php @@ -132,10 +132,6 @@ class DashboardController $content .= '
'.get_lang('YouHaveNotEnabledBlocks').'
'; } } else { - // block dashboard list - if (isset($success)) { - Display::addFlash(Display::return_message(get_lang('BlocksHaveBeenUpdatedSuccessfully'), 'confirm')); - } $user_id = api_get_user_id(); $content .= DashboardManager::display_user_dashboard_list($user_id); } diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 44367be5bd..42d6aa1519 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1290,7 +1290,7 @@ function api_get_user_courses($userid, $fetch_session = true) { // Get out if not integer if ($userid != strval(intval($userid))) { - return array(); + return []; } $t_course = Database::get_main_table(TABLE_MAIN_COURSE); @@ -1305,10 +1305,10 @@ function api_get_user_courses($userid, $fetch_session = true) cu.relation_type<>".COURSE_RELATION_TYPE_RRHH." "; $result = Database::query($sql); if ($result === false) { - return array(); + return []; } - $courses = array(); + $courses = []; while ($row = Database::fetch_array($result)) { // we only need the database name of the course $courses[] = $row; @@ -1329,7 +1329,7 @@ function api_get_user_courses($userid, $fetch_session = true) */ function _api_format_user($user, $add_password = false, $loadAvatars = true) { - $result = array(); + $result = []; $result['firstname'] = null; $result['lastname'] = null; @@ -1898,7 +1898,7 @@ function api_get_course_info($course_code = null, $strict = false) $courseId = api_get_course_int_id($course_code); if (empty($courseId)) { - return array(); + return []; } $course_table = Database::get_main_table(TABLE_MAIN_COURSE); @@ -1912,7 +1912,7 @@ function api_get_course_info($course_code = null, $strict = false) ON course.category_code = course_category.code WHERE course.id = $courseId"; $result = Database::query($sql); - $courseInfo = array(); + $courseInfo = []; if (Database::num_rows($result) > 0) { $data = Database::fetch_array($result); $courseInfo = api_format_course_array($data); @@ -1923,7 +1923,7 @@ function api_get_course_info($course_code = null, $strict = false) global $_course; if ($_course == '-1') { - $_course = array(); + $_course = []; } return $_course; @@ -1952,7 +1952,7 @@ function api_get_course_info_by_id($id = null) ON course.category_code = course_category.code WHERE course.id = $id"; $result = Database::query($sql); - $_course = array(); + $_course = []; if (Database::num_rows($result) > 0) { $row = Database::fetch_array($result); $_course = api_format_course_array($row); @@ -1962,7 +1962,7 @@ function api_get_course_info_by_id($id = null) global $_course; if ($_course == '-1') { - $_course = array(); + $_course = []; } return $_course; } @@ -1979,10 +1979,10 @@ function api_get_course_info_by_id($id = null) function api_format_course_array($course_data) { if (empty($course_data)) { - return array(); + return []; } - $_course = array(); + $_course = []; $_course['id'] = $course_data['code']; $_course['real_id'] = $course_data['id']; @@ -4075,7 +4075,7 @@ function api_get_item_property_by_tool($tool, $course_code, $session_id = null) tool = '$tool' $session_condition "; $rs = Database::query($sql); - $list = array(); + $list = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs, 'ASSOC')) { $list[] = $row; @@ -4117,7 +4117,7 @@ function api_get_item_property_list_by_tool_by_user( $session_condition "; $rs = Database::query($sql); - $list = array(); + $list = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs, 'ASSOC')) { $list[] = $row; @@ -4214,7 +4214,7 @@ function api_get_track_item_property_history($tool, $ref) ORDER BY lastedit_date DESC"; $result = Database::query($sql); if ($result === false or $result === null) { - $result = array(); + $result = []; } else { $result = Database::store_result($result, 'ASSOC'); } @@ -4266,7 +4266,7 @@ function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0, $g } $rs = Database::query($sql); - $row = array(); + $row = []; if (Database::num_rows($rs) > 0) { $row = Database::fetch_array($rs, 'ASSOC'); } @@ -4460,7 +4460,7 @@ function api_get_languages() $sql = "SELECT * FROM $tbl_language WHERE available='1' ORDER BY original_name ASC"; $result = Database::query($sql); - $language_list = array(); + $language_list = []; while ($row = Database::fetch_array($result)) { $language_list['name'][] = $row['original_name']; $language_list['folder'][] = $row['dokeos_folder']; @@ -4478,7 +4478,7 @@ function api_get_languages_to_array() $tbl_language = Database::get_main_table(TABLE_MAIN_LANGUAGE); $sql = "SELECT * FROM $tbl_language WHERE available='1' ORDER BY original_name ASC"; $result = Database::query($sql); - $languages = array(); + $languages = []; while ($row = Database::fetch_array($result)) { $languages[$row['dokeos_folder']] = $row['original_name']; } @@ -4899,7 +4899,7 @@ function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = fals * @param string $source * @param string $dest */ -function copyr($source, $dest, $exclude = array(), $copied_files = array()) +function copyr($source, $dest, $exclude = [], $copied_files = []) { if (empty($dest)) { return false; } // Simple copy for a file @@ -5117,7 +5117,7 @@ function api_chmod_R($path, $filemode) * The info array. */ function api_parse_info_file($filename) { - $info = array(); + $info = []; if (!file_exists($filename)) { return $info; @@ -5157,7 +5157,7 @@ function api_parse_info_file($filename) { $key = count($parent); } if (!isset($parent[$key]) || !is_array($parent[$key])) { - $parent[$key] = array(); + $parent[$key] = []; } $parent = &$parent[$key]; } @@ -5254,7 +5254,7 @@ function api_get_settings_options($var) WHERE variable = '$var' ORDER BY id"; $result = Database::query($sql); - $settings_options_array = array(); + $settings_options_array = []; while ($row = Database::fetch_array($result, 'ASSOC')) { $settings_options_array[] = $row; } @@ -5414,7 +5414,7 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url * @param string $value * @return bool */ -function api_set_settings_category($category, $value = null, $access_url = 1, $fieldtype = array()) +function api_set_settings_category($category, $value = null, $access_url = 1, $fieldtype = []) { if (empty($category)) { return false; @@ -5932,7 +5932,7 @@ function api_get_access_url_from_user($user_id) ON (url_rel_user.access_url_id = u.id) WHERE user_id = ".intval($user_id); $result = Database::query($sql); - $list = array(); + $list = []; while ($row = Database::fetch_array($result, 'ASSOC')) { $list[] = $row['access_url_id']; } @@ -6658,7 +6658,7 @@ function api_get_jquery_ui_css_web_path() */ function api_get_jquery_ui_js($include_jqgrid = false) { - $libraries = array(); + $libraries = []; if ($include_jqgrid) { $libraries[] = 'jqgrid'; } @@ -7076,7 +7076,7 @@ function api_set_default_visibility( $item_id, $tool_id, $group_id = 0, - $courseInfo = array(), + $courseInfo = [], $sessionId = 0, $userId = 0 ) { @@ -7177,7 +7177,7 @@ function api_get_security_key() */ function api_detect_user_roles($user_id, $courseId, $session_id = 0) { - $user_roles = array(); + $user_roles = []; $courseInfo = api_get_course_info_by_id($courseId); $course_code = $courseInfo['code']; @@ -7274,11 +7274,11 @@ function api_get_js_simple($file) function api_set_settings_and_plugins() { global $_configuration; - $_setting = array(); - $_plugins = array(); + $_setting = []; + $_plugins = []; // access_url == 1 is the default chamilo location - $settings_by_access_list = array(); + $settings_by_access_list = []; $access_url_id = api_get_current_access_url_id(); if ($access_url_id != 1) { $url_info = api_get_access_url($_configuration['access_url']); @@ -7341,11 +7341,11 @@ function api_set_settings_and_plugins() } $result = api_get_settings('Plugins', 'list', $access_url_id); - $_plugins = array(); + $_plugins = []; foreach ($result as & $row) { $key = & $row['variable']; if (is_string($_setting[$key])) { - $_setting[$key] = array(); + $_setting[$key] = []; } $_setting[$key][] = $row['selected_value']; $_plugins[$key][] = $row['selected_value']; @@ -7675,7 +7675,7 @@ function api_can_login_as($loginAsUserId, $userId = null) 'drh_all', api_get_user_id() ); - $userList = array(); + $userList = []; if (is_array($users)) { foreach ($users as $user) { $userList[] = $user['user_id']; @@ -8083,10 +8083,10 @@ function api_mail_html( $message, $senderName = '', $senderEmail = '', - $extra_headers = array(), - $data_file = array(), + $extra_headers = [], + $data_file = [], $embedded_image = false, - $additionalParameters = array() + $additionalParameters = [] ) { global $platform_email; @@ -8165,7 +8165,7 @@ function api_mail_html( // Get all images html inside content. preg_match_all("/]*)[\"\']?[^>]*>/i", $message, $m); // Prepare new tag images. - $new_images_html = array(); + $new_images_html = []; $i = 1; if (!empty($m[1])) { foreach ($m[1] as $image_path) { diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index b981635b8e..852231c8ac 100644 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2494,7 +2494,7 @@ class DocumentManager $value = trim($regs[16][$i]); } if (!empty($name)) { - if (!$reduced OR in_array(strtolower($name), $wanted)) { + if (!$reduced || in_array(strtolower($name), $wanted)) { if ($name == $check) { $attributes[strtolower($name)][] = strtolower($name); } else { diff --git a/main/lp/aiccObjective.class.php b/main/lp/aiccObjective.class.php index e3e93efe82..516080a5b7 100755 --- a/main/lp/aiccObjective.class.php +++ b/main/lp/aiccObjective.class.php @@ -1,8 +1,6 @@ db_id. Used only for prerequisites match. + public $refs_list = []; //list of items by ref => db_id. Used only for prerequisites match. // !!!This array (refs_list) is built differently depending on the nature of the LP. // If SCORM, uses ref, if Chamilo, uses id to keep a unique value. public $type; //type of learnpath. Could be 'chamilo', 'scorm', 'scorm2004', 'aicc', ... // TODO: Check if this type variable is useful here (instead of just in the controller script). public $user_id; //ID of the user that is viewing/using the course - public $update_queue = array(); + public $update_queue = []; public $scorm_debug = 0; - public $arrMenu = array(); // Array for the menu items. + public $arrMenu = []; // Array for the menu items. public $debug = 0; // Logging level. public $lp_session_id = 0; public $lp_view_session_id = 0; // The specific view might be bound to a session. @@ -87,7 +87,7 @@ class learnpath public $expired_on = ''; public $ref = null; public $course_int_id; - public $course_info = array(); + public $course_info = []; public $categoryId; /** @@ -246,7 +246,7 @@ class learnpath error_log('-- Start while--'); } - $lp_item_id_list = array(); + $lp_item_id_list = []; while ($row = Database::fetch_array($res)) { $lp_item_id_list[] = $row['iid']; switch ($this->type) { @@ -355,7 +355,7 @@ class learnpath ); } - $status_list = array(); + $status_list = []; $res = Database::query($sql); while ($row = Database:: fetch_array($res)) { $status_list[$row['lp_item_id']] = $row['status']; @@ -1035,7 +1035,7 @@ class learnpath return false; } $this->current_time_stop = time(); - $this->ordered_items = array(); + $this->ordered_items = []; $this->index = 0; unset($this->lp_id); //unset other stuff @@ -1295,7 +1295,7 @@ class learnpath $title, $description, $prerequisites = '0', - $audio = array(), + $audio = [], $max_time_allowed = 0, $url = '' ) { @@ -1599,7 +1599,7 @@ class learnpath } if (empty($id) || $id != strval(intval($id))) { - return array(); + return []; } $lp_item = Database::get_course_table(TABLE_LP_ITEM); @@ -1617,7 +1617,7 @@ class learnpath ORDER BY display_order"; $res_bros = Database::query($sql); - $list = array(); + $list = []; while ($row_bro = Database::fetch_array($res_bros)) { $list[] = $row_bro; } @@ -1625,7 +1625,7 @@ class learnpath return $list; } - return array(); + return []; } /** @@ -1642,7 +1642,7 @@ class learnpath } if (empty($id) || $id != strval(intval($id))) { - return array(); + return []; } $lp_item = Database::get_course_table(TABLE_LP_ITEM); @@ -1679,7 +1679,7 @@ class learnpath TOOL_LEARNPATH, $this->lp_id ); - $prefix_terms = array(); + $prefix_terms = []; if (!empty($terms)) { foreach ($terms as $term) { $prefix_terms[] = $term['value']; @@ -2840,7 +2840,7 @@ class learnpath if ($this->debug > 0) { error_log('New LP - In learnpath::get_items_status_list()', 0); } - $list = array(); + $list = []; foreach ($this->ordered_items as $item_id) { $list[] = array( $item_id => $this->items[$item_id]->get_status() @@ -4988,7 +4988,7 @@ class learnpath /** * Set index specified prefix terms for all items in this path * @param string Comma-separated list of terms - * @param char Xapian term prefix + * @param string Xapian term prefix * @return boolean False on error, true otherwise */ public function set_terms_by_prefix($terms_string, $prefix) @@ -5004,7 +5004,6 @@ class learnpath $terms_string = trim($terms_string); $terms = explode(',', $terms_string); array_walk($terms, 'trim_value'); - $stored_terms = $this->get_common_index_terms_by_prefix($prefix); // Don't do anything if no change, verify only at DB, not the search engine. @@ -9377,7 +9376,7 @@ class learnpath * @param array $data * @return string */ - public function display_item_small_form($item_type, $title = '', $data = array()) + public function display_item_small_form($item_type, $title = '', $data = []) { $url = api_get_self().'?'.api_get_cidreq().'&action=edit_item&lp_id='.$this->lp_id; $form = new FormValidator('small_form', 'post', $url); @@ -9436,10 +9435,10 @@ class learnpath $sql = "SELECT * FROM $tbl_lp_item WHERE c_id = $course_id AND lp_id = ".$this->lp_id; $result = Database::query($sql); - $arrLP = array(); + $arrLP = []; - $selectedMinScore = array(); - $selectedMaxScore = array(); + $selectedMinScore = []; + $selectedMaxScore = []; while ($row = Database::fetch_array($result)) { if ($row['id'] == $item_id) { $selectedMinScore[$row['prerequisite']] = $row['prerequisite_min_score']; @@ -9622,7 +9621,7 @@ class learnpath DocumentManager::build_directory_selector( $folders, '', - array(), + [], true, $form, 'directory_parent_id' @@ -9732,7 +9731,7 @@ class learnpath $return .= Display::return_icon( 'move_everywhere.png', get_lang('Move'), - array(), + [], ICON_SIZE_TINY ); $return .= ' '; @@ -9758,14 +9757,14 @@ class learnpath $return .= Display::return_icon( 'move_everywhere.png', get_lang('Move'), - array(), + [], ICON_SIZE_TINY ); $return .= ' '; $return .= Display::return_icon( 'quizz_small.gif', '', - array(), + [], ICON_SIZE_TINY ); $sessionStar = api_get_session_image( @@ -9800,7 +9799,7 @@ class learnpath $moveEverywhereIcon = Display::return_icon( 'move_everywhere.png', get_lang('Move'), - array(), + [], ICON_SIZE_TINY ); @@ -9824,8 +9823,8 @@ class learnpath WHERE link.c_id = ".$course_id." $condition_session ORDER BY link_category.category_title ASC, link.title ASC"; $result = Database::query($sql); - $categorizedLinks = array(); - $categories = array(); + $categorizedLinks = []; + $categories = []; while ($link = Database::fetch_array($result)) { if (!$link['category_id']) { @@ -9928,7 +9927,7 @@ class learnpath $return .= Display::return_icon( 'move_everywhere.png', get_lang('Move'), - array(), + [], ICON_SIZE_TINY ); $return .= ' '; @@ -10027,9 +10026,9 @@ class learnpath $return .= '
  • '; $return .= ''; - $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); + $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), [], ICON_SIZE_TINY); $return .= ' '; - $return .= Display::return_icon('lp_forum.png', '', array(), ICON_SIZE_TINY); + $return .= Display::return_icon('lp_forum.png', '', [], ICON_SIZE_TINY); $return .= ' @@ -10050,9 +10049,9 @@ class learnpath $return .= '
  • '; $return .= ' '; - $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); + $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), [], ICON_SIZE_TINY); $return .= ' '; - $return .= Display::return_icon('forumthread.png', get_lang('Thread'), array(), ICON_SIZE_TINY); + $return .= Display::return_icon('forumthread.png', get_lang('Thread'), [], ICON_SIZE_TINY); $return .= ''. Security::remove_XSS($thread['thread_title']).' '.$link.''; $return .= '
  • '; @@ -10103,7 +10102,7 @@ class learnpath $zip_folder = new PclZip($temp_zip_file); $current_course_path = api_get_path(SYS_COURSE_PATH).api_get_course_path(); $root_path = $main_path = api_get_path(SYS_PATH); - $files_cleanup = array(); + $files_cleanup = []; // Place to temporarily stash the zip file. // create the temp dir if it doesn't exist @@ -10120,7 +10119,7 @@ class learnpath } closedir($handle); } - $zip_files = $zip_files_abs = $zip_files_dist = array(); + $zip_files = $zip_files_abs = $zip_files_dist = []; if (is_dir($current_course_path.'/scorm/'.$this->path) && is_file($current_course_path.'/scorm/'.$this->path.'/imsmanifest.xml') ) { @@ -10195,8 +10194,8 @@ class learnpath // For each element, add it to the imsmanifest structure, then add it to the zip. // Always call the learnpathItem->scorm_export() method to change it to the SCORM format. - $link_updates = array(); - $links_to_create = array(); + $link_updates = []; + $links_to_create = []; //foreach ($this->items as $index => $item) { foreach ($this->ordered_items as $index => $itemId) { $item = $this->items[$itemId]; @@ -11014,7 +11013,7 @@ EOD; public function scorm_export_to_pdf($lp_id) { $lp_id = intval($lp_id); - $files_to_export = array(); + $files_to_export = []; $course_data = api_get_course_info($this->cc); if (!empty($course_data)) { $scorm_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/scorm/'.$this->path; @@ -11545,7 +11544,7 @@ EOD; public static function getCategoryFromCourseIntoSelect($courseId, $addSelectOption = false) { $items = self::getCategoryByCourse($courseId); - $cats = array(); + $cats = []; if ($addSelectOption) { $cats = array(get_lang('SelectACategory')); } diff --git a/main/work/work.lib.php b/main/work/work.lib.php index f2002c8972..16480d3994 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -143,17 +143,16 @@ function settingsForm($defaults) function get_work_data_by_path($path, $courseId = 0) { $path = Database::escape_string($path); + $courseId = intval($courseId); if (empty($courseId)) { $courseId = api_get_course_int_id(); - } else { - $courseId = intval($courseId); } $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $sql = "SELECT * FROM ".$work_table." WHERE url = '$path' AND c_id = $courseId "; $result = Database::query($sql); - $return = array(); + $return = []; if (Database::num_rows($result)) { $return = Database::fetch_array($result, 'ASSOC'); } @@ -170,13 +169,10 @@ function get_work_data_by_path($path, $courseId = 0) function get_work_data_by_id($id, $courseId = 0, $sessionId = 0) { $id = intval($id); - - if (!empty($courseId)) { - $courseId = intval($courseId); - } else { + $courseId = intval($courseId); + if (empty($courseId)) { $courseId = api_get_course_int_id(); } - $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $sessionCondition = null; @@ -189,7 +185,7 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0) id = $id AND c_id = $courseId $sessionCondition"; $result = Database::query($sql); - $work = array(); + $work = []; if (Database::num_rows($result)) { $work = Database::fetch_array($result, 'ASSOC'); if (empty($work['title'])) { @@ -272,7 +268,7 @@ function get_work_assignment_by_id($id, $courseId = null) $sql = "SELECT * FROM $table WHERE c_id = $courseId AND publication_id = $id"; $result = Database::query($sql); - $return = array(); + $return = []; if (Database::num_rows($result)) { $return = Database::fetch_array($result, 'ASSOC'); } @@ -362,7 +358,7 @@ function getWorkList($id, $my_folder_data, $add_in_where_query = null, $course_i ORDER BY title"; } - $work_parents = array(); + $work_parents = []; $sql_result = Database::query($sql); if (Database::num_rows($sql_result)) { @@ -385,7 +381,7 @@ function getWorkList($id, $my_folder_data, $add_in_where_query = null, $course_i function getWorkPerUser($userId, $courseId = 0, $sessionId = 0) { $works = getWorkList(null, null, null, $courseId, $sessionId); - $result = array(); + $result = []; if (!empty($works)) { foreach ($works as $workData) { $workId = $workData->id; @@ -468,7 +464,7 @@ function getUniqueStudentAttempts( $course_id, $sessionId, $userId = null, - $onlyUserList = array() + $onlyUserList = [] ) { $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $user_table = Database::get_main_table(TABLE_MAIN_USER); @@ -577,7 +573,7 @@ function showStudentWorkGrid() $html = ''; @@ -622,7 +618,7 @@ function showTeacherWorkGrid() $html = '