コード例 #1
0
                $("#viewBySession").removeClass("btn-primary");
            }
        }
	</script>
';
}
$controller = new IndexManager(get_lang('MyCourses'));
// Main courses and session list
//$courseAndSessions = $controller->returnCoursesAndSessions($userId);
// Main courses and session list
if (isset($_COOKIE['defaultMyCourseView' . $userId]) && $_COOKIE['defaultMyCourseView' . $userId] == IndexManager::VIEW_BY_SESSION && $displayMyCourseViewBySessionLink) {
    $courseAndSessions = $controller->returnCoursesAndSessionsViewBySession($userId);
    IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_SESSION, $userId);
} else {
    $courseAndSessions = $controller->returnCoursesAndSessions($userId);
    IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_DEFAULT, $userId);
}
// if teacher, session coach or admin, display the button to change te course view
if ($displayMyCourseViewBySessionLink && (api_is_drh() || api_is_course_coach() || api_is_platform_admin() || api_is_session_admin() || api_is_teacher())) {
    $courseAndSessions['html'] = "<div class='view-by-session-link'>\n\t\t<div class='btn-group pull-right'>\n\t\t<a class='btn btn-default' id='viewByDefault' href='user_portal.php' onclick='changeMyCoursesView(\"" . IndexManager::VIEW_BY_DEFAULT . "\")'>\n\t\t" . get_lang('MyCoursesDefaultView') . "\n\t\t</a>\n\t\t<a class='btn btn-default' id='viewBySession' href='user_portal.php' onclick='changeMyCoursesView(\"" . IndexManager::VIEW_BY_SESSION . "\")'>\n\t\t" . get_lang('MyCoursesSessionView') . "\n\t\t</a>\n\t\t</div>\n\t</div><br /><br />\n\t" . $courseAndSessions['html'];
}
// Check if a user is enrolled only in one course for going directly to the course after the login.
if (api_get_setting('go_to_course_after_login') == 'true') {
    $count_of_sessions = $courseAndSessions['session_count'];
    $count_of_courses_no_sessions = $courseAndSessions['course_count'];
    // User is subscribe in 1 session and 0 courses.
    if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) {
        $sessions = SessionManager::get_sessions_by_user($userId);
        if (isset($sessions[0])) {
            $sessionInfo = $sessions[0];
            // Session only has 1 course.