subscribe_user($course_code); if (!empty($msg)) { $show_message .= Display::return_message(get_lang($msg)); } } } /* Is the user allowed here? */ api_protect_course_script(true); /* STATISTICS */ if (!isset($coursesAlreadyVisited[$course_code])) { event_access_course(); $coursesAlreadyVisited[$course_code] = 1; Session::write('coursesAlreadyVisited', $coursesAlreadyVisited); } $show_autolaunch_exercise_warning = false; // Exercise auto-launch $auto_launch = api_get_course_setting('enable_exercise_auto_launch'); if (!empty($auto_launch)) { $session_id = api_get_session_id(); //Exercise list if ($auto_launch == 2) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $show_autolaunch_exercise_warning = true; } else { $session_key = 'exercise_autolunch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the Exercise $url = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&id_session='.$session_id; Session::write($session_key, true); //$_SESSION[$session_key] = true; header("Location: $url"); exit; } } } else { $table = Database::get_course_table(TABLE_QUIZ_TEST); $course_id = api_get_course_int_id(); $condition = ''; if (!empty($session_id)) { $condition = api_get_session_condition($session_id); $sql = "SELECT iid FROM $table WHERE c_id = $course_id AND autolaunch = 1 $condition LIMIT 1"; $result = Database::query($sql); //If we found nothing in the session we just called the session_id = 0 autolaunch if (Database::num_rows($result) == 0) { $condition = ''; } else { //great, there is an specific auto lunch for this session we leave the $condition } } $sql = "SELECT iid FROM $table WHERE c_id = $course_id AND autolaunch = 1 $condition LIMIT 1"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $data = Database::fetch_array($result,'ASSOC'); if (!empty($data['iid'])) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $show_autolaunch_exercise_warning = true; } else { $session_key = 'exercise_autolunch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH).'exercice/overview.php?'.api_get_cidreq().'&exerciseId='.$data['iid']; //$_SESSION[$session_key] = true; Session::write($session_key, true); header("Location: $url"); exit; } } } } } } /* Auto launch code */ $show_autolaunch_lp_warning = false; $auto_launch = api_get_course_setting('enable_lp_auto_launch'); if (!empty($auto_launch)) { $session_id = api_get_session_id(); //LP list if ($auto_launch == 2) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $show_autolaunch_lp_warning = true; } else { $session_key = 'lp_autolunch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&id_session='.$session_id; //$_SESSION[$session_key] = true; Session::write($session_key, true); header("Location: $url"); exit; } } } else { $lp_table = Database::get_course_table(TABLE_LP_MAIN); $course_id = api_get_course_int_id(); $condition = ''; if (!empty($session_id)) { $condition = api_get_session_condition($session_id); $sql = "SELECT id FROM $lp_table WHERE c_id = $course_id AND autolunch = 1 $condition LIMIT 1"; $result = Database::query($sql); //If we found nothing in the session we just called the session_id = 0 autolunch if (Database::num_rows($result) == 0) { $condition = ''; } else { //great, there is an specific auto lunch for this session we leave the $condition } } $sql = "SELECT id FROM $lp_table WHERE c_id = $course_id AND autolunch = 1 $condition LIMIT 1"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $lp_data = Database::fetch_array($result,'ASSOC'); if (!empty($lp_data['id'])) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $show_autolaunch_lp_warning = true; } else { $session_key = 'lp_autolunch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp_data['id']; //$_SESSION[$session_key] = true; Session::write($session_key, true); header("Location: $url"); exit; } } } } } } $tool_table = Database::get_course_table(TABLE_TOOL_LIST); $temps = time(); $reqdate = "&reqdate=$temps"; /* MAIN CODE */ /* Introduction section (editable by course admins) */ $content = Display::return_introduction_section(TOOL_COURSE_HOMEPAGE, array( 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/', 'CreateDocumentDir' => 'document/', 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/' )); /* SWITCH TO A DIFFERENT HOMEPAGE VIEW the setting homepage_view is adjustable through the platform administration section */ if ($show_autolaunch_lp_warning) { $show_message .= Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'),'warning'); } if ($show_autolaunch_exercise_warning) { $show_message .= Display::return_message(get_lang('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'),'warning'); } if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_view') == 'activity_big') { require 'activity.php'; } elseif (api_get_setting('homepage_view') == '2column') { require '2column.php'; } elseif (api_get_setting('homepage_view') == '3column') { require '3column.php'; } elseif (api_get_setting('homepage_view') == 'vertical_activity') { require 'vertical_activity.php'; } $content = '
'.$content.'
'; Session::erase('_gid'); return array('content' => $content, 'message' => $show_message);