Fixing redirect to course with new options

skala
Julio Montoya 14 years ago
parent 80de69d903
commit 789cd32f6a
  1. 48
      user_portal.php

@ -96,14 +96,47 @@ $personal_course_list = UserManager::get_personal_session_course_list($_user['us
// 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') {
if (!isset($_SESSION['coursesAlreadyVisited']) && is_array($personal_course_list) && count($personal_course_list) == 1) {
$key = array_keys($personal_course_list);
$course_info = $personal_course_list[$key[0]];
$my_session_list = array();
$count_of_courses_no_sessions = 0;
$count_of_courses_with_sessions = 0;
foreach($personal_course_list as $course) {
if (!empty($course['id_session'])) {
$my_session_list[$course['id_session']] = true;
$count_of_courses_with_sessions++;
} else {
$count_of_courses_no_sessions++;
}
}
$count_of_sessions = count($my_session_list);
//echo $count_of_sessions.' '.$count_of_courses_with_sessions.' '.$count_of_courses_no_sessions;
//!isset($_SESSION['coursesAlreadyVisited'])
if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) {
$key = array_keys($personal_course_list);
$course_info = $personal_course_list[$key[0]];
$course_directory = $course_info['d'];
$id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
header('location:'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session);
$id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
$url = api_get_path(WEB_CODE_PATH).'session/?session_id='.$id_session;
header('location:'.$url);
exit;
} else {
}
if (!isset($_SESSION['coursesAlreadyVisited']) && $count_of_sessions == 0 && $count_of_courses_no_sessions == 1) {
$key = array_keys($personal_course_list);
$course_info = $personal_course_list[$key[0]];
$course_directory = $course_info['d'];
$id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
$url = api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session;
header('location:'.$url);
exit;
}
/*
if (api_get_setting('hide_courses_in_sessions') == 'true') {
//Check sessions
$session_list = array();
@ -116,7 +149,8 @@ if (api_get_setting('go_to_course_after_login') == 'true') {
header('Location:'.api_get_path(WEB_CODE_PATH).'session/?session_id='.$session_list[$only_session_id]['id_session']);
}
}
}
*/
}
$nosession = false;

Loading…
Cancel
Save