From af2c73667465876d9e4e47448592738366dd8ed8 Mon Sep 17 00:00:00 2001 From: Julio Date: Wed, 22 Sep 2021 09:23:02 +0200 Subject: [PATCH] Tracking: Fix php errors --- public/main/inc/lib/myspace.lib.php | 32 +++++++++---------- public/main/mySpace/admin_view.php | 12 +++---- public/main/mySpace/course.php | 6 ++-- .../default/my_space/accessoverview.html.twig | 2 +- .../template/default/my_space/index.html.twig | 32 +++++++++---------- 5 files changed, 41 insertions(+), 43 deletions(-) diff --git a/public/main/inc/lib/myspace.lib.php b/public/main/inc/lib/myspace.lib.php index 46bab366b5..6e01c2a323 100644 --- a/public/main/inc/lib/myspace.lib.php +++ b/public/main/inc/lib/myspace.lib.php @@ -55,23 +55,23 @@ class MySpace ], [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/survey_report.php', - 'content' => get_lang('SurveysReport'), + 'content' => get_lang('Surveys report'), ], [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/tc_report.php', - 'content' => get_lang('TCReport'), + 'content' => get_lang("Student's superior follow up"), ], [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/ti_report.php', - 'content' => get_lang('TIReport'), + 'content' => get_lang('General Coaches planning'), ], [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/question_stats_global.php', - 'content' => get_lang('QuestionStats'), + 'content' => get_lang('Question stats'), ], [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/question_stats_global_detail.php', - 'content' => get_lang('QuestionStatsDetailedReport'), + 'content' => get_lang('Detailed questions stats'), ], ]; @@ -81,7 +81,7 @@ class MySpace $actions[] = [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=company', - 'content' => get_lang('UserByEntityReport'), + 'content' => get_lang('User by organization'), ]; } $field = new ExtraField('lp'); @@ -90,7 +90,7 @@ class MySpace $actions[] = [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=learningPath', - 'content' => get_lang('LpByAuthor'), + 'content' => get_lang('Learning path by author'), ]; } $field = new ExtraField('lp_item'); @@ -99,11 +99,11 @@ class MySpace $actions[] = [ 'url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=learningPathByItem', - 'content' => get_lang('LearningPathItemByAuthor'), + 'content' => get_lang('LP item by author'), ]; } - return Display::actions($actions, null); + return Display::actions($actions); } /** @@ -318,7 +318,7 @@ class MySpace $courseId = $course->getId(); $courseCode = $course->getCode(); - $avg_score = Tracking::get_avg_student_score($userId, $courseCode); + $avg_score = Tracking::get_avg_student_score($userId, $course); if (is_numeric($avg_score)) { $avg_score = round($avg_score, 2); } else { @@ -1761,7 +1761,7 @@ class MySpace $nb_progress_lp += $progress_tmp[1]; $score_tmp = Tracking::get_avg_student_score( $userId, - $courseCode, + $course, [], null, true @@ -1954,7 +1954,6 @@ class MySpace public static function session_tracking_filter($session_id, $url_params, $row) { $sessionId = $row[0]; - $url = api_get_url_entity(); $session = api_get_session_entity($sessionId); // the table header $return = 'user_id, $courseCode, [], $session_id, true); + $score_tmp = Tracking::get_avg_student_score($row_user->user_id, $course, [], $session_id, true); if (is_array($score_tmp)) { $score += $score_tmp[0]; $nb_score_lp += $score_tmp[1]; @@ -2135,7 +2134,7 @@ class MySpace $csv_content[] = $csv_row; // the other lines (the data) - foreach ($session_data as $key => $session) { + foreach ($session_data as $session) { $session_id = $session[0]; $session_title = $session[1]; @@ -2147,7 +2146,8 @@ class MySpace $result = Database::query($sql); while ($row = Database::fetch_object($result)) { $courseId = $row->c_id; - $courseInfo = api_get_course_info_by_id($courseId); + $courseInfo = ['real_id' => $courseId]; + $course = api_get_course_entity($courseId); $csv_row = []; $csv_row[] = $session_title; $csv_row[] = $row->title; @@ -2183,7 +2183,7 @@ class MySpace $nb_progress_lp += $progress_tmp[1]; $score_tmp = Tracking::get_avg_student_score( $row_user->user_id, - $row->code, + $course, [], $session_id, true diff --git a/public/main/mySpace/admin_view.php b/public/main/mySpace/admin_view.php index 4c9a1506a7..25dc146997 100644 --- a/public/main/mySpace/admin_view.php +++ b/public/main/mySpace/admin_view.php @@ -109,24 +109,24 @@ switch ($display) { break; case 'accessoverview': $courseId = isset($_GET['course_id']) ? (int) $_GET['course_id'] : 0; - if (0 == $courseId && $_POST['course_id']) { + if (0 == $courseId && isset($_POST['course_id']) && $_POST['course_id']) { $courseId = (int) $_POST['course_id']; $_GET['course_id'] = $courseId; } $sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0; - if (0 == $sessionId && $_POST['session_id']) { + if (0 == $sessionId && isset($_POST['session_id']) && $_POST['session_id']) { $sessionId = (int) $_POST['session_id']; $_GET['session_id'] = $sessionId; } $studentId = isset($_GET['student_id']) ? (int) $_GET['student_id'] : 0; - if (0 == $studentId && $_POST['student_id']) { + if (0 == $studentId && isset($_POST['student_id']) && $_POST['student_id']) { $studentId = (int) $_POST['student_id']; $_GET['student_id'] = $studentId; } - $perPage = isset($_GET['tracking_access_overview_per_page']) ? $_GET['tracking_access_overview_per_page'] : 20; + $perPage = $_GET['tracking_access_overview_per_page'] ?? 20; - $dates = isset($_GET['date']) ? $_GET['date'] : null; - if (null == $dates && $_POST['date']) { + $dates = $_GET['date'] ?? null; + if (null == $dates && isset($_POST['date']) && $_POST['date']) { $dates = $_POST['date']; $_GET['date'] = $dates; } diff --git a/public/main/mySpace/course.php b/public/main/mySpace/course.php index 0ab72c6900..ab7c007c53 100644 --- a/public/main/mySpace/course.php +++ b/public/main/mySpace/course.php @@ -105,17 +105,17 @@ if (api_is_platform_admin(true, true)) { api_get_path(WEB_CODE_PATH).'mySpace/session.php' ); $menu_items[] = Display::url( - get_lang('QuestionStats'), + get_lang('Question stats'), api_get_path(WEB_CODE_PATH).'mySpace/question_stats_global.php' ); $menu_items[] = Display::url( - get_lang('QuestionStatsDetailedReport'), + get_lang('Detailed questions stats'), api_get_path(WEB_CODE_PATH).'mySpace/question_stats_global_detail.php' ); if (api_can_login_as($user_id)) { $link = ''. + href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.Security::get_existing_token().'">'. Display::return_icon('login_as.png', get_lang('Login as'), null, ICON_SIZE_MEDIUM).'  '; $menu_items[] = $link; } diff --git a/public/main/template/default/my_space/accessoverview.html.twig b/public/main/template/default/my_space/accessoverview.html.twig index 1620982329..e34f223e93 100644 --- a/public/main/template/default/my_space/accessoverview.html.twig +++ b/public/main/template/default/my_space/accessoverview.html.twig @@ -1,5 +1,5 @@ {% autoescape false %} - + {{ form }} {{ table }} diff --git a/public/main/template/default/my_space/index.html.twig b/public/main/template/default/my_space/index.html.twig index 2800ec9ddf..6e491d8ab8 100644 --- a/public/main/template/default/my_space/index.html.twig +++ b/public/main/template/default/my_space/index.html.twig @@ -17,7 +17,7 @@
@@ -184,7 +183,7 @@ - {{ 'FollowedSessions' | trans }} + {{ 'Followed sessions' | trans }}
@@ -217,7 +216,7 @@ -

{{ 'AverageCoursePerStudent' | trans }}

+

{{ 'Average number of courses to which my learners are subscribed' | trans }}

@@ -229,7 +228,7 @@
-

{{ 'InactivesStudents' | trans }}

+

{{ 'Learners not connected for a week or more' | trans }}

@@ -241,7 +240,7 @@
-

{{ 'AverageTimeSpentOnThePlatform' | trans }}

+

{{ 'Time spent on portal' | trans }}

@@ -253,7 +252,7 @@
-

{{ 'AverageProgressInLearnpath' | trans }}

+

{{ 'Progress in courses' | trans }}

@@ -266,7 +265,7 @@
-

{{ 'AvgCourseScore' | trans }}

+

{{ 'Average score in learning paths' | trans }}

@@ -279,7 +278,7 @@
-

{{ 'AveragePostsInForum' | trans }}

+

{{ 'Posts in forum' | trans }}

@@ -289,10 +288,9 @@
{{ report.AverageAssignments }}
-
-

{{ 'AverageAssignments' | trans }}

+

{{ 'Average assignments per learner' | trans }}