From c6c5f8ab9e6c914057f794b9f75620be8fa938c5 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 19 Sep 2017 10:05:46 +0200 Subject: [PATCH] Add param history fixes BT#13396 --- main/inc/lib/userportal.lib.php | 7 ++++--- user_portal.php | 19 ++++++------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index ea54cdc5f8..8401291ab0 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1142,25 +1142,26 @@ class IndexManager * @param bool $showSessions * @param string $categoryCodeFilter * @param bool $useUserLanguageFilterIfAvailable + * @param bool $loadHistory * @return array */ public function returnCoursesAndSessions( $user_id, $showSessions = true, $categoryCodeFilter = '', - $useUserLanguageFilterIfAvailable = true + $useUserLanguageFilterIfAvailable = true, + $loadHistory = false ) { $gameModeIsActive = api_get_setting('gamification_mode'); $listCourse = ''; $specialCourseList = ''; - $load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false; $viewGridCourses = api_get_configuration_value('view_grid_courses') === 'true'; $showSimpleSessionInfo = api_get_configuration_value('show_simple_session_info'); $coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl'; $coursesWithCategoryTemplate = '/user_portal/classic_courses_with_category.tpl'; - if ($load_history) { + if ($loadHistory) { // Load sessions in category in *history* $session_categories = UserManager::get_sessions_by_category($user_id, true); } else { diff --git a/user_portal.php b/user_portal.php index 2e1b44b81b..6d16d1fd42 100755 --- a/user_portal.php +++ b/user_portal.php @@ -39,6 +39,7 @@ $userId = api_get_user_id(); $load_dirs = api_get_setting('show_documents_preview'); $displayMyCourseViewBySessionLink = api_get_setting('my_courses_view_by_session') === 'true'; $nameTools = get_lang('MyCourses'); +$loadHistory = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false; // Load course notification by ajax $loadNotificationsByAjax = api_get_configuration_value('user_portal_load_notification_by_ajax'); @@ -139,7 +140,7 @@ if (!$myCourseListAsCategory) { $courseAndSessions = $controller->returnCoursesAndSessionsViewBySession($userId); IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_SESSION, $userId); } else { - $courseAndSessions = $controller->returnCoursesAndSessions($userId); + $courseAndSessions = $controller->returnCoursesAndSessions($userId, true, null, true, $loadHistory); IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_DEFAULT, $userId); } @@ -179,7 +180,9 @@ if (!$myCourseListAsCategory) { $courseAndSessions = $controller->returnCoursesAndSessions( $userId, false, - $categoryCode + $categoryCode, + true, + $loadHistory ); $getCategory = CourseCategory::getCategory($categoryCode); $controller->tpl->assign('category', $getCategory); @@ -301,6 +304,7 @@ if ($allow) { $userId, false, '', + false, false ); @@ -387,11 +391,6 @@ if ($allow) { } } - /*$userFinished = - $countDependenciesPassed == count($dependencies) && - $countCoursesPassedNoDependency >= $minToValidate - ;*/ - $userFinished = $countDependenciesPassed >= $gradeBooksToValidateInDependence && $countCoursesPassedNoDependency >= $minToValidate @@ -421,12 +420,6 @@ if ($allow) { $finalResult ); $controller->tpl->assign('grade_book_badge_list', $badgeList); - /*if ($finalScore > 0) { - $finalScore = (int) $finalScore / count($total); - if ($finalScore == 100) { - $completed = true; - } - }*/ } $controller->tpl->display_two_col_template();