Skip to content

Commit 755aa93

Browse files
committed
Add setting "show_all_sessions_on_my_course_page" see BT#13590
Show all sessions (old, current and future) in the "my courses" page.
1 parent 5879c81 commit 755aa93

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

main/inc/lib/usermanager.lib.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,8 +2798,14 @@ public static function get_sessions_by_category(
27982798
LEFT JOIN ChamiloCoreBundle:SessionRelCourseRelUser AS scu WITH scu.session = s
27992799
INNER JOIN ChamiloCoreBundle:AccessUrlRelSession AS url WITH url.sessionId = s.id
28002800
LEFT JOIN ChamiloCoreBundle:SessionCategory AS sc WITH s.category = sc
2801-
WHERE (scu.user = :user OR s.generalCoach = :user) AND url.accessUrlId = :url
2802-
ORDER BY sc.name, s.name";
2801+
WHERE (scu.user = :user OR s.generalCoach = :user) AND url.accessUrlId = :url ";
2802+
2803+
$order = "ORDER BY sc.name, s.name";
2804+
$showAllSessions = api_get_configuration_value('show_all_sessions_on_my_course_page') === true;
2805+
if ($showAllSessions) {
2806+
$order = "ORDER BY s.accessStartDate";
2807+
}
2808+
$dql .= $order;
28032809

28042810
$dql = Database::getManager()
28052811
->createQuery($dql)

main/inc/lib/userportal.lib.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@ public function returnCoursesAndSessions(
11701170

11711171
$coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl';
11721172
$coursesWithCategoryTemplate = '/user_portal/classic_courses_with_category.tpl';
1173+
$showAllSessions = api_get_configuration_value('show_all_sessions_on_my_course_page') === true;
11731174

11741175
if ($loadHistory) {
11751176
// Load sessions in category in *history*
@@ -1187,6 +1188,7 @@ public function returnCoursesAndSessions(
11871188
$studentInfo = api_get_configuration_value('course_student_info');
11881189
$viewGrid = api_get_configuration_value('view_grid_courses');
11891190

1191+
11901192
$studentInfoProgress = !empty($studentInfo['progress']) && $studentInfo['progress'] === true;
11911193
$studentInfoScore = !empty($studentInfo['score']) && $studentInfo['score'] === true;
11921194
$studentInfoCertificate = !empty($studentInfo['certificate']) && $studentInfo['certificate'] === true;
@@ -1465,6 +1467,8 @@ public function returnCoursesAndSessions(
14651467
// Loop course content
14661468
$html_courses_session = [];
14671469
$atLeastOneCourseIsVisible = false;
1470+
$markAsOld = false;
1471+
$markAsFuture = false;
14681472

14691473
foreach ($session['courses'] as $course) {
14701474
$is_coach_course = api_is_coach($session_id, $course['real_id']);
@@ -1478,6 +1482,7 @@ public function returnCoursesAndSessions(
14781482
$allowed_time = api_strtotime($date_session_start);
14791483
}
14801484

1485+
$endSessionToTms = null;
14811486
if (!isset($_GET['history'])) {
14821487
if (!empty($date_session_end)) {
14831488
if ($is_coach_course) {
@@ -1503,6 +1508,17 @@ public function returnCoursesAndSessions(
15031508
}
15041509
}
15051510

1511+
if ($showAllSessions) {
1512+
if ($allowed_time < $session_now && $allowedEndTime == false) {
1513+
$markAsOld = true;
1514+
}
1515+
if ($allowed_time > $session_now && $endSessionToTms > $session_now) {
1516+
$markAsFuture = true;
1517+
}
1518+
$allowedEndTime = true;
1519+
$allowed_time = 0;
1520+
}
1521+
15061522
if ($session_now >= $allowed_time && $allowedEndTime) {
15071523
// Read only and accessible.
15081524
$atLeastOneCourseIsVisible = true;
@@ -1612,6 +1628,8 @@ public function returnCoursesAndSessions(
16121628
$html_courses_session
16131629
);
16141630
$params['courses'] = $html_courses_session;
1631+
$params['is_old'] = $markAsOld;
1632+
$params['is_future'] = $markAsFuture;
16151633

16161634
if ($showSimpleSessionInfo) {
16171635
$params['subtitle'] = self::getSimpleSessionDetails(
@@ -1728,10 +1746,16 @@ public function returnCoursesAndSessions(
17281746
}
17291747

17301748
$this->tpl->assign('session', $sessionParams);
1731-
$html_sessions .= $this->tpl->fetch(
1732-
$this->tpl->get_template('user_portal/classic_session.tpl')
1733-
);
17341749

1750+
if ($viewGridCourses) {
1751+
$html_sessions .= $this->tpl->fetch(
1752+
$this->tpl->get_template('/user_portal/grid_session.tpl')
1753+
);
1754+
} else {
1755+
$html_sessions .= $this->tpl->fetch(
1756+
$this->tpl->get_template('user_portal/classic_session.tpl')
1757+
);
1758+
}
17351759
$sessionCount++;
17361760
}
17371761
}

main/install/configuration.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,5 @@
671671
];*/
672672
// Disable jquery, jquery-ui libs added in the learning path view
673673
//$_configuration['disable_js_in_lp_view'] = true;
674+
// Show all sessions (old, current, future) in my course page
675+
//$_configuration['show_all_sessions_on_my_course_page'] = true;

0 commit comments

Comments
 (0)