diff --git a/main/admin/user_information.php b/main/admin/user_information.php index 495f9efbc8..0ba941d076 100755 --- a/main/admin/user_information.php +++ b/main/admin/user_information.php @@ -698,11 +698,9 @@ $content = $tpl->fetch($layoutTemplate); echo $content; if (api_get_configuration_value('allow_career_users')) { if (!empty($sessions)) { - foreach ($sessions as $session) { - echo SessionManager::getCareerDiagramPerSession($session['session_id'], $userId); - } + $sessions = array_column($sessions, 'session_id'); + echo SessionManager::getCareerDiagramPerSessionList($sessions, $userId); } - echo Display::page_subheader(get_lang('Careers'), null, 'h3', ['class' => 'section-title']); echo MyStudents::userCareersTable($userId); } diff --git a/main/auth/my_progress.php b/main/auth/my_progress.php index 0fad3fe3be..68551944fe 100755 --- a/main/auth/my_progress.php +++ b/main/auth/my_progress.php @@ -41,6 +41,8 @@ $sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0; $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null; $allowCareerUser = api_get_configuration_value('allow_career_users'); +$showGraph = false === api_get_configuration_value('hide_session_graph_in_my_progress'); + if (!empty($courseUserList)) { $items = MySpace::get_connections_from_course_list( $user_id, @@ -81,12 +83,19 @@ if (!empty($courseUserList)) { } } -$content = Tracking::showUserProgress($user_id, $sessionId); +$content = Tracking::showUserProgress( + $user_id, + $sessionId, + '', + true, + true, + false, + $showGraph +); $showAllSessionCourses = api_get_configuration_value('my_progress_session_show_all_courses'); if ($showAllSessionCourses && !empty($sessionId) && empty($courseCode)) { $userSessionCourses = UserManager::get_courses_list_by_session($user_id, $sessionId); - foreach ($userSessionCourses as $userSessionCourse) { $content .= Tracking::show_course_detail( $user_id, @@ -102,19 +111,19 @@ if ($showAllSessionCourses && !empty($sessionId) && empty($courseCode)) { if (!empty($dates)) { $content .= Display::page_subheader(get_lang('Timeline')); $content .= ' -
-
-
-
    '.$dates.'
-
    '.$issues.'
-
-
- - -
-
-
- '; +
+
+
+
    '.$dates.'
+
    '.$issues.'
+
+
+ + +
+
+
+ '; } if (api_get_configuration_value('private_messages_about_user_visible_to_user') === true) { diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index 2874ced04c..22f2c7d7b9 100755 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -624,6 +624,7 @@ foreach ($posts as $post) { $post['post_title'] .= Display::tag('div', $titlePost, ['class' => 'post-header']); // the post body + $post['post_text'] = Security::remove_XSS($post['post_text']); $post['post_data'] = Display::tag('div', $post['post_text'], ['class' => 'post-body']); // The check if there is an attachment diff --git a/main/inc/lib/MyStudents.php b/main/inc/lib/MyStudents.php index 06ec5c5be5..6f6b058538 100644 --- a/main/inc/lib/MyStudents.php +++ b/main/inc/lib/MyStudents.php @@ -16,7 +16,9 @@ class MyStudents return ''; } - return self::getCareersTable($careers); + $title = Display::page_subheader(get_lang('Careers'), null, 'h3', ['class' => 'section-title']); + + return $title.self::getCareersTable($careers); } public static function getCareersTable(array $careers): string @@ -52,13 +54,11 @@ class MyStudents return $table->toHtml(); } - public static function getBlockForSkills(int $studentId, int $courseId, int $sessionId): string { $allowAll = api_get_configuration_value('allow_teacher_access_student_skills'); if ($allowAll) { - // Show all skills return Tracking::displayUserSkills($studentId, 0, 0, true); } diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index cf91e07d2c..29b67cad75 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -9660,47 +9660,46 @@ class SessionManager return $careers; } - public static function getCareerDiagramPerSession($sessionId, $userId): string + public static function getCareerDiagramPerSessionList($sessionList, $userId) { - $sessionId = (int) $sessionId; - $userId = (int) $userId; - - $visibility = api_get_session_visibility($sessionId, null, false, $userId); - $content = ''; - if (SESSION_AVAILABLE === $visibility) { - $careerList = self::getCareersFromSession($sessionId); + if (empty($sessionList) || empty($userId)) { + return ''; + } - if (empty($careerList)) { - return ''; + $userId = (int) $userId; + $content = Display::page_subheader(get_lang('OngoingTraining')); + $content .= ' + + '; + $careersAdded = []; + foreach ($sessionList as $sessionId) { + $visibility = api_get_session_visibility($sessionId, null, false, $userId); + if (SESSION_AVAILABLE === $visibility) { + $careerList = self::getCareersFromSession($sessionId); + if (empty($careerList)) { + continue; } - - '; - } - - if (!empty($content)) { - $content = Display::page_subheader(get_lang('OngoingTraining')).$content; + foreach ($careerList as $career) { + $careerId = $career['id']; + if (!in_array($careerId, $careersAdded)) { + $careersAdded[] = $careerId; + $careerUrl = api_get_path(WEB_CODE_PATH).'user/career_diagram.php?iframe=1&career_id='.$career['id'].'&user_id='.$userId; + $content .= ' + '; + } + } + } } return $content; diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 29392964f2..0f35af1894 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -4703,7 +4703,8 @@ class Tracking $extra_params = '', $show_courses = true, $showAllSessions = true, - $returnArray = false + $returnArray = false, + $showGraph = true ) { $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); @@ -5004,6 +5005,7 @@ class Tracking $allowCareerUser = api_get_configuration_value('allow_career_users'); // Session list. + $visibleSessions = []; if (!empty($course_in_session)) { $main_session_graph = ''; // Load graphics only when calling to an specific session @@ -5011,7 +5013,6 @@ class Tracking $my_results = []; $all_exercise_graph_list = []; $all_exercise_start_time = []; - $allCareers = []; foreach ($course_in_session as $my_session_id => $session_data) { $course_list = $session_data['course_list']; $user_count = count(SessionManager::get_users_by_session($my_session_id)); @@ -5021,10 +5022,7 @@ class Tracking $visibility = api_get_session_visibility($my_session_id, null, false, $user_id); if (SESSION_AVAILABLE === $visibility) { - $careers = SessionManager::getCareersFromSession($my_session_id); - if (!empty($careers)) { - $allCareers = array_merge($allCareers, $careers); - } + $visibleSessions[] = $my_session_id; } foreach ($course_list as $course_data) { @@ -5103,13 +5101,15 @@ class Tracking $my_results_final[] = $my_results[$key]; $final_all_exercise_graph_list[] = $all_exercise_graph_list[$key]; } - $main_session_graph = '
' - .self::generate_session_exercise_graph( - $final_all_exercise_graph_name_list, - $my_results_final, - $final_all_exercise_graph_list - ) - .'
'; + if ($showGraph) { + $main_session_graph = '
' + .self::generate_session_exercise_graph( + $final_all_exercise_graph_name_list, + $my_results_final, + $final_all_exercise_graph_list + ) + .'
'; + } } $sessionIcon = Display::return_icon('session.png', get_lang('Sessions')); @@ -5209,24 +5209,25 @@ class Tracking ); } - if ($allowCareerUser && !empty($allCareers)) { - $careers = []; - foreach ($allCareers as $career) { - $careers[$career['id']] = $career; + if ($allowCareerUser) { + $diagrams = ''; + if (!empty($visibleSessions)) { + $diagrams .= SessionManager::getCareerDiagramPerSessionList($visibleSessions, $user_id); } - - $title = Display::page_subheader(get_lang('OngoingTraining')); - $html .= $title.MyStudents::getCareersTable($careers); + $html .= $diagrams.MyStudents::userCareersTable($user_id); } $html .= Display::div($sessionsTable->toHtml(), ['class' => 'table-responsive']); - $html .= Display::div( - $main_session_graph, - [ - 'id' => 'session_graph', - 'class' => 'chart-session', - ] - ); + + if ($showGraph) { + $html .= Display::div( + $main_session_graph, + [ + 'id' => 'session_graph', + 'class' => 'chart-session', + ] + ); + } // Checking selected session. if (isset($_GET['session_id'])) { diff --git a/main/inc/lib/webservices/Rest.php b/main/inc/lib/webservices/Rest.php index 761efd7933..e0d25ef578 100644 --- a/main/inc/lib/webservices/Rest.php +++ b/main/inc/lib/webservices/Rest.php @@ -1456,7 +1456,7 @@ class Rest extends WebService $course_code = CourseManager::get_course_code_from_course_id($course_id); } - if (CourseManager::subscribeUser($user_id, $course_code, $status)) { + if (CourseManager::subscribeUser($user_id, $course_code, $status, 0, 0, false)) { return [true]; } diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 8c9be300b4..15786e5ec8 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -1921,6 +1921,9 @@ ALTER TABLE gradebook_comment ADD CONSTRAINT FK_C3B70763AD3ED51C FOREIGN KEY (gr // Replace the Chamilo logo URL. //$_configuration['platform_logo_url'] = 'https://chamilo.org'; +// Hides the session graph in the main/auth/my_progress.php page. +//$_configuration['hide_session_graph_in_my_progress'] = true; + // KEEP THIS AT THE END // -------- Custom DB changes // Add user activation by confirmation email diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index fa06804f20..2001d53144 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -946,10 +946,9 @@ echo $content; // Careers. if (api_get_configuration_value('allow_career_users')) { - foreach ($courses_in_session as $sId => $courses) { - echo SessionManager::getCareerDiagramPerSession($sId, $student_id); + if (!empty($courses_in_session)) { + echo SessionManager::getCareerDiagramPerSessionList(array_keys($courses_in_session), $student_id); } - echo Display::page_subheader(get_lang('Careers'), null, 'h3', ['class' => 'section-title']); echo MyStudents::userCareersTable($student_id); } diff --git a/main/mySpace/student_follow_export.php b/main/mySpace/student_follow_export.php index 133b5011d6..ec9b8c9e42 100644 --- a/main/mySpace/student_follow_export.php +++ b/main/mySpace/student_follow_export.php @@ -503,10 +503,10 @@ if ($form->validate()) { $coursesInfo[] = generateHtmlForCourse($studentInfo['id'], $coursesInSessions, $courseId, $sessionId); } } - $title = Display::page_subheader(get_lang('Careers'), null, 'h3', ['class' => 'section-title']); + $view = new Template('', false, false, false, true, false, false); $view->assign('user_info', $studentInfo); - $view->assign('careers', $title.MyStudents::userCareersTable($studentInfo['id'])); + $view->assign('careers', MyStudents::userCareersTable($studentInfo['id'])); $view->assign('skills', Tracking::displayUserSkills($studentInfo['id'])); $view->assign('classes', MyStudents::getBlockForClasses($studentInfo['id'])); $view->assign('courses_info', $coursesInfo); diff --git a/main/template/default/career/diagram_full.tpl b/main/template/default/career/diagram_full.tpl index 5297220dbd..a8c415d4e9 100644 --- a/main/template/default/career/diagram_full.tpl +++ b/main/template/default/career/diagram_full.tpl @@ -2,5 +2,4 @@ {% block content %} {% include 'career/diagram.tpl' |get_template %} - {{ content }} {% endblock %} \ No newline at end of file diff --git a/main/template/default/career/diagram_iframe.tpl b/main/template/default/career/diagram_iframe.tpl index 55ff3d490e..a225a609e8 100644 --- a/main/template/default/career/diagram_iframe.tpl +++ b/main/template/default/career/diagram_iframe.tpl @@ -2,5 +2,4 @@ {% block body %} {% include 'career/diagram.tpl' |get_template %} - {{ content }} {% endblock %} \ No newline at end of file