$user_infos = UserManager::get_user_info_by_id($user_id);
$name = $user_infos['firstname'] . ' ' . $user_infos['lastname'];
if (!api_is_platform_admin(true) && !CourseManager::is_course_teacher($_user['user_id'], $cidReq) && !Tracking::is_allowed_to_coach_student($_user['user_id'], $_GET['student_id']) && $user_infos['hr_dept_id'] !== $_user['user_id']) {
    Display::display_header('');
    api_not_allowed();
    Display::display_footer();
}
$course_exits = CourseManager::course_exists($cidReq);
if (!empty($course_exits)) {
    $_course = CourseManager::get_course_information($cidReq);
} else {
    api_not_allowed();
}
$_course['dbNameGlu'] = $_configuration['table_prefix'] . $_course['db_name'] . $_configuration['db_glue'];
$lp_id = intval($_GET['lp_id']);
$lp_view_id = cloud_getLpViewId($cidReq, $lp_id, $user_id);
$regid = cloud_getRegId($cidReq, $lp_view_id);
$interbreadcrumb[] = array("url" => api_get_path(WEB_COURSE_PATH) . $_course['directory'], 'name' => $_course['title']);
$interbreadcrumb[] = array("url" => "../tracking/courseLog.php?cidReq=" . $cidReq . '&studentlist=true&id_session=' . $_SESSION['id_session'], "name" => get_lang("Tracking"));
$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=" . Security::remove_XSS($_GET['student_id']) . "&course=" . $cidReq . "&details=true&origin=" . Security::remove_XSS($_GET['origin']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array("url" => "cloudCourseDetails.php?regid=" . $regid . "&course=" . $cidReq . "&lp_id=" . $lp_id . "&student_id=" . $user_id, "name" => "Course Activity Report");
$nameTools = get_lang('launchHistoryReport');
$htmlHeadXtra[] = '
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){

    });
    </script>
<script type="text/javascript">
        var extConfigurationString = "";
	Copyright (c) 2009 Rustici Software
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	See the GNU General Public License for more details.

==============================================================================
*/
require_once '../newscorm/back_compat.inc.php';
require_once '../newscorm/learnpath.class.php';
require_once 'scorm_cloud.lib.php';
//get the courseid and userid
//Dokeos Course ID (a db, training, etc. - can contain many courses (or none))
$cid = $_GET['cidReq'];
//learningPath Id - learningpath is a course
$lp_id = $_GET['lp_id'];
$userInfo = api_get_user_info();
$userId = $userInfo['user_id'];
$need_to_create_reg = false;
$lp_view_id = cloud_getLpViewId($cid, $lp_id, $userId, true);
//echo $lp_view_id;
$regId = cloud_getRegId($cid, $lp_view_id);
$ScormService = cloud_getScormEngineService();
$regService = $ScormService->getRegistrationService();
$exitUrl = api_get_path(WEB_PATH) . 'main/scorm_cloud/RegistrationResults.php?regid=' . $regId . '&lp_id=' . $lp_id;
$launchUrl = $regService->GetLaunchUrl($regId, $exitUrl, null, null, $cid . ',TEST1', "TEST2,TEST3");
//echo $launchUrl;
header('location: ' . $launchUrl);
function cloud_getTotalCourseTime($cid, $lp_id, $user_id)
{
    $lp_view_id = cloud_getLpViewId($cid, $lp_id, $user_id, true);
    $regId = cloud_getRegId($cid, $lp_view_id);
    $ScormService = cloud_getScormEngineService();
    $regService = $ScormService->getRegistrationService();
    $resultXmlString = $regService->GetRegistrationResult($regId, 0, 0);
    $resXml = simplexml_load_string($resultXmlString);
    //echo $resultXmlString;
    $timeVal = $resXml->registrationreport->totaltime;
    return $timeVal;
}