From 1d6bd0b198d18421f5876620bbefb0b271515603 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Sun, 2 May 2021 11:13:47 +0200 Subject: [PATCH] Fix PHP errors --- public/main/exercise/tests_category.php | 3 +-- public/main/inc/lib/groupmanager.lib.php | 3 ++- public/main/inc/lib/sortable_table.class.php | 8 +++--- public/main/inc/lib/tracking.lib.php | 23 +++++++--------- public/main/mySpace/myStudents.php | 28 ++++++++++---------- public/main/session/resume_session.php | 2 +- public/main/tracking/courseLog.php | 4 +-- public/main/tracking/course_log_groups.php | 9 ++----- public/main/tracking/course_log_tools.php | 14 ++++------ public/main/tracking/lp_report.php | 5 ++-- 10 files changed, 43 insertions(+), 56 deletions(-) diff --git a/public/main/exercise/tests_category.php b/public/main/exercise/tests_category.php index ed9358fda5..477d69dc37 100644 --- a/public/main/exercise/tests_category.php +++ b/public/main/exercise/tests_category.php @@ -270,6 +270,5 @@ function displayActionBar() ); echo Display::toolbarAction('toolbar', [$actions]); - - echo '
'.get_lang('Questions category').'
'; + echo Display::page_header(get_lang('Questions category')); } diff --git a/public/main/inc/lib/groupmanager.lib.php b/public/main/inc/lib/groupmanager.lib.php index 7c4ce96f3d..24fe0bf68d 100644 --- a/public/main/inc/lib/groupmanager.lib.php +++ b/public/main/inc/lib/groupmanager.lib.php @@ -102,8 +102,9 @@ class GroupManager * @param int $sessionId * @param bool $getCount * @param bool $notInGroup Get groups not in a category + * @param bool $returnEntityList * - * @return array an array with all information about the groups + * @return array|CGroup[] an array with all information about the groups */ public static function get_group_list( $categoryId = null, diff --git a/public/main/inc/lib/sortable_table.class.php b/public/main/inc/lib/sortable_table.class.php index 8e57d3c4d6..ae05eccdcd 100644 --- a/public/main/inc/lib/sortable_table.class.php +++ b/public/main/inc/lib/sortable_table.class.php @@ -144,8 +144,8 @@ class SortableTable extends HTML_Table if (empty($attributes)) { $attributes = []; - //$attributes['class'] = 'table table-hover table-striped table-bordered data_table'; - $attributes['class'] = 'q-table'; + $attributes['class'] = 'table table-hover table-striped table-bordered data_table'; + //$attributes['class'] = 'q-table'; $attributes['id'] = $table_id; } @@ -425,8 +425,8 @@ class SortableTable extends HTML_Table } //$html .= '
'.$content.'
'; - $html .= '
'. - $content.'
'; + $html .= '
'; + $html .= $content.'
'; if (!empty($this->additional_parameters)) { foreach ($this->additional_parameters as $key => $value) { diff --git a/public/main/inc/lib/tracking.lib.php b/public/main/inc/lib/tracking.lib.php index 5853fe7dff..ace4d0cc13 100644 --- a/public/main/inc/lib/tracking.lib.php +++ b/public/main/inc/lib/tracking.lib.php @@ -56,18 +56,17 @@ class Tracking return null; } $course = api_get_course_entity($courseId); - $courseCode = $course->getCode(); $session = api_get_session_entity($sessionId); if ('count' === $type) { return GroupManager::get_group_list(null, $course, null, $sessionId, true); } - $groupList = GroupManager::get_group_list(null, $course, null, $sessionId); + $groupList = GroupManager::get_group_list(null, $course, null, $sessionId, false, null, true); $parsedResult = []; if (!empty($groupList)) { foreach ($groupList as $group) { - $users = GroupManager::get_users($group['iid'], true, null, null, false, $courseId); + $users = GroupManager::get_users($group->getIid(), true, null, null, false, $courseId); $time = 0; $avg_student_score = 0; $avg_student_progress = 0; @@ -108,8 +107,8 @@ class Tracking $averageScore = empty($countUsers) ? 0 : round($avg_student_score / $countUsers, 2); $groupItem = [ - 'id' => $group['id'], - 'name' => $group['name'], + 'id' => $group->getIid(), + 'name' => $group->getName(), 'time' => api_time_to_hms($time), 'progress' => $averageProgress, 'score' => $averageScore, @@ -3179,7 +3178,7 @@ class Tracking if (!empty($course_code)) { $course = api_get_course_info($course_code); $courseId = $course['real_id']; - $conditions[] = " lp.c_id = $courseId"; + //$conditions[] = " lp.c_id = $courseId"; } // Get course tables names @@ -3213,13 +3212,12 @@ class Tracking SUM(lp_i.max_score) sum_max_score FROM $lp_table as lp INNER JOIN $lp_item_table as lp_i - ON lp.iid = lp_id AND lp.c_id = lp_i.c_id + ON lp.iid = lp_i.lp_id INNER JOIN $lp_view_table as lp_view - ON lp_view.lp_id = lp_i.lp_id AND lp_view.c_id = lp_i.c_id + ON lp_view.lp_id = lp_i.lp_id INNER JOIN $lp_item_view_table as lp_iv ON lp_i.iid = lp_iv.lp_item_id AND - lp_view.c_id = lp_iv.c_id AND lp_iv.lp_view_id = lp_view.iid WHERE (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."') AND $conditionsToString @@ -3495,7 +3493,7 @@ class Tracking // Check the real number of LPs corresponding to the filter in the // database (and if no list was given, get them all) $sql = "SELECT iid FROM $lp_table - WHERE c_id = $courseId AND iid = $lp_id "; + WHERE iid = $lp_id "; $row = Database::query($sql); $count = Database::num_rows($row); @@ -3504,10 +3502,9 @@ class Tracking $sql = 'SELECT MIN(start_time) FROM '.$t_lpiv.' AS item_view INNER JOIN '.$t_lpv.' AS view - ON (item_view.lp_view_id = view.iid AND item_view.c_id = view.c_id) + ON (item_view.lp_view_id = view.iid) WHERE status != "not attempted" AND - item_view.c_id = '.$courseId.' AND view.c_id = '.$courseId.' AND view.lp_id = '.$lp_id.' AND view.user_id = '.$student_id.' AND @@ -8911,6 +8908,6 @@ class TrackingCourseLog $attendanceLink, ]; - return implode('', $items).' '; + return Display::toolbarAction('tracking', $items); } } diff --git a/public/main/mySpace/myStudents.php b/public/main/mySpace/myStudents.php index 7e6e6549ff..356da27834 100644 --- a/public/main/mySpace/myStudents.php +++ b/public/main/mySpace/myStudents.php @@ -678,20 +678,19 @@ Display::display_header($nameTools); $token = Security::get_token(); // Actions bar -echo '
'; -echo '' +$actions = '' .Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).''; -echo '' +$actions .= '' .Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).''; -echo '' +$actions .= '' .Display::return_icon('export_csv.png', get_lang('CSV export'), '', ICON_SIZE_MEDIUM).' '; -echo '' +$actions .= '' .Display::return_icon('export_excel.png', get_lang('Excel export'), '', ICON_SIZE_MEDIUM).' '; -echo Display::url( +$actions .= Display::url( Display::return_icon('attendance.png', get_lang('Access details'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'mySpace/access_details_session.php?user_id='.$studentId ); @@ -702,10 +701,10 @@ if (!empty($email)) { } else { $send_mail = Display::return_icon('mail_send_na.png', get_lang('Send message mail'), '', ICON_SIZE_MEDIUM); } -echo $send_mail; +$actions .= $send_mail; if (!empty($studentId) && !empty($courseCode)) { // Only show link to connection details if course and student were defined in the URL - echo '' .Display::return_icon('statistics.png', get_lang('Access details'), '', ICON_SIZE_MEDIUM) .''; @@ -715,19 +714,19 @@ $notebookTeacherEnable = 'true' === api_get_plugin_setting('notebookteacher', 'e if ($notebookTeacherEnable && !empty($studentId) && !empty($courseCode)) { // link notebookteacher $optionsLink = 'student_id='.$studentId.'&origin='.$origin.'&cid='.$courseId.'&id_session='.$sessionId; - echo '' + $actions .= '' .Display::return_icon('notebookteacher.png', get_lang('Notebook'), '', ICON_SIZE_MEDIUM) .''; } if (api_can_login_as($studentId)) { - echo '' .Display::return_icon('login_as.png', get_lang('Login as'), null, ICON_SIZE_MEDIUM).'  '; } if (Skill::isAllowed($studentId, false)) { - echo Display::url( + $actions .= Display::url( Display::return_icon( 'skill-badges.png', get_lang('Assign skill'), @@ -739,7 +738,7 @@ if (Skill::isAllowed($studentId, false)) { } if (Skill::isAllowed($studentId, false)) { - echo Display::url( + $actions .= Display::url( Display::return_icon( 'attendance.png', get_lang('CountDoneAttendance'), @@ -757,7 +756,7 @@ $permissions = StudentFollowUpPlugin::getPermissions( $isAllow = $permissions['is_allow']; if ($isAllow) { - echo Display::url( + $actions .= Display::url( Display::return_icon( 'blog.png', get_lang('Blog'), @@ -767,7 +766,8 @@ if ($isAllow) { api_get_path(WEB_PLUGIN_PATH).'studentfollowup/posts.php?student_id='.$studentId ); } -echo '
'; + +echo Display::toolbarAction('my_students', [$actions]); // is the user online ? $online = get_lang('No'); diff --git a/public/main/session/resume_session.php b/public/main/session/resume_session.php index cc178089f4..6cdddde313 100644 --- a/public/main/session/resume_session.php +++ b/public/main/session/resume_session.php @@ -193,7 +193,7 @@ if (0 === $session->getNbrCourses()) { ); } - $courseUrl = api_get_course_url($courseCode, $sessionId); + $courseUrl = api_get_course_url($courseId, $sessionId); // hide_course_breadcrumb the parameter has been added to hide the name // of the course, that appeared in the default $interbreadcrumb diff --git a/public/main/tracking/courseLog.php b/public/main/tracking/courseLog.php index 094f898e6b..0be16f7c5f 100644 --- a/public/main/tracking/courseLog.php +++ b/public/main/tracking/courseLog.php @@ -198,8 +198,7 @@ Display::display_header($nameTools, 'Tracking'); $actionsLeft = TrackingCourseLog::actionsLeft('users', $sessionId); -$actionsRight = '
'; -$actionsRight .= ''. +$actionsRight = ''. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).''; $additionalParams = ''; @@ -217,7 +216,6 @@ if (isset($_GET['users_tracking_per_page'])) { $actionsRight .= ' '.Display::return_icon('export_csv.png', get_lang('CSV export'), '', ICON_SIZE_MEDIUM).''; -$actionsRight .= '
'; // Create a search-box. $form_search = new FormValidator( 'search_simple', diff --git a/public/main/tracking/course_log_groups.php b/public/main/tracking/course_log_groups.php index c81943a325..26eefa7653 100644 --- a/public/main/tracking/course_log_groups.php +++ b/public/main/tracking/course_log_groups.php @@ -1,4 +1,5 @@ '; Display::display_header(); - -echo '
'; echo TrackingCourseLog::actionsLeft('groups', $sessionId); -echo '
'; - echo Display::grid_html('group_users'); Display::display_footer(); diff --git a/public/main/tracking/course_log_tools.php b/public/main/tracking/course_log_tools.php index 726dcbf05f..bd0e72d3a3 100644 --- a/public/main/tracking/course_log_tools.php +++ b/public/main/tracking/course_log_tools.php @@ -100,19 +100,15 @@ $nbStudents = count($a_students); $student_ids = array_keys($a_students); $studentCount = count($student_ids); -/* MAIN CODE */ - -echo '
'; echo TrackingCourseLog::actionsLeft('courses', api_get_session_id()); + echo ''; echo ''. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).''; echo ' '.Display::return_icon('export_csv.png', get_lang('CSV export'), '', ICON_SIZE_MEDIUM).''; - echo ''; -echo '
'; $course_code = api_get_course_id(); $course_id = api_get_course_int_id(); @@ -132,7 +128,7 @@ if ($lpReporting) { ); echo ''; if ($export_csv) { - $temp = [get_lang('Progress in courses', ''), '']; + $temp = [get_lang('Progress in courses'), '']; $csv_content[] = ['', '']; $csv_content[] = $temp; } @@ -143,9 +139,9 @@ if ($lpReporting) { // get the progress in learning pathes $lp_avg_progress += Tracking::get_avg_student_progress( $student_id, - $course_code, + $course, [$lp_id], - $session_id + $session ); } @@ -169,7 +165,7 @@ if ($lpReporting) { echo '
'; } else { if ($export_csv) { - $temp = [get_lang('NoLearningPath', ''), '']; + $temp = [get_lang('NoLearningPath'), '']; $csv_content[] = $temp; } } diff --git a/public/main/tracking/lp_report.php b/public/main/tracking/lp_report.php index afcfa02829..d35f22f827 100644 --- a/public/main/tracking/lp_report.php +++ b/public/main/tracking/lp_report.php @@ -273,6 +273,7 @@ function getData($from, $numberOfItems, $column, $direction, $params) $courseCode = api_get_course_id(); $courseId = api_get_course_int_id(); $course = api_get_course_entity(); + $session = api_get_session_entity(); /** @var CLp[] $lps */ $lps = $params['lps']; @@ -327,7 +328,7 @@ function getData($from, $numberOfItems, $column, $direction, $params) $userId, $course, [$lpId], - $sessionId + $session ); if ($useNewTable) { @@ -444,7 +445,7 @@ $table->setDataFunctionParams(['lps' => $lps]); $table->set_additional_parameters($parameters); $column = 0; foreach ($headers as $header) { - $lpName = $lp['name']; + $lpName = $lp->getName(); $table->set_header($column++, $header, false); }