<?PHP
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Free Web Based Training System                           |
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Plate-forme de téléformation gratuite et en open source  |
// +----------------------------------------------------------------------------|
// | Copyright (C) 2001-2003  Anéma Formation  <http://www.anema.fr/>           |
// +----------------------------------------------------------------------------+
// |           Developer : Eric FIGUEIRAS <gcaldeira@anemalab.org>            	|
// |           Developer : Georges CALDEIRA <gcaldeira@anemalab.org>            |
// +----------------------------------------------------------------------------+
// |              Infos on project <http://anemalab.org/>                       |
// +----------------------------------------------------------------------------+
// | 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.                                        |
// |                                                                            |
// | This program is distributed in the hope that it will be useful,            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
// | GNU General Public License for more details.                               |
// |                                                                            |
// | You should have received a copy of the GNU General Public License          |
// | along with this program; if not, write to the Free Software                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   |
// +----------------------------------------------------------------------------+
/**
* Page pour la gestion SCORM en JavaScript
*
* @author	Georges Caldeira <gcaldeira@anemalab.org>
* @package	GaneshaCommun
*/
	/**
	* include des fichiers + verification de la cnx
	*/
	include_once("anema.inc.php");

	if ( !isset($HTTP_GET_VARS['groupe']) || !isset($HTTP_GET_VARS['module'])){
		PageErreur();
	    exit()      ;
	}

	$groupe	= $HTTP_GET_VARS['groupe'] ;
	$module = $HTTP_GET_VARS['module'] ;
	$chapitre = $HTTP_GET_VARS['chapitre'] ;

	if (! $ClsFormation->ModuleIsValid($module,$guserid,$groupe) ) {
		PageErreur();
		exit ()		;
	}	

	$ret = $ClsChapitre->info($module,$chapitre) ;
	$file_scorm = HTTP_FORMATION.$ret['lien'];
	$gparam = SCORM_GFILE.'?connexion='.$gconnexionid.'&groupe='.$groupe ;
	$gparam.= '&module='.$module.'&chapitre='.$chapitre ;
	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="javascript" >
<!-- 
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Free Web Based Training System                           |
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Plate-forme de téléformation gratuite et en open source  |
// +----------------------------------------------------------------------------|
// | Copyright (C) 2001-2003  Anéma Formation  <http://www.anema.fr/>           |
// +----------------------------------------------------------------------------+
// |           Eric FIGUEIRAS <figueiras@anema-formation.fr>        			|
// |           Georges CALDEIRA <gcaldeira@anemalab.org>            			|
// +----------------------------------------------------------------------------+
// |              Infos on project <http://anemalab.org/>                       |
// +----------------------------------------------------------------------------+
// | 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.                                        |
// |                                                                            |
// | This program is distributed in the hope that it will be useful,            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
// | GNU General Public License for more details.                               |
// |                                                                            |
// | You should have received a copy of the GNU General Public License          |
// | along with this program; if not, write to the Free Software                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   |
// +----------------------------------------------------------------------------+

var G_NoError = 0;
var G_GeneralException = 101;
var G_ServerBusy = 102;
var G_InvalidArgumentError = 201;
var G_ElementCannotHaveChildren = 202;
var G_ElementIsNotAnArray = 203;
var G_NotInitialized = 301;
var G_NotImplementedError = 401;
var G_InvalidSetValue = 402;
var G_ElementIsReadOnly = 403;
var G_ElementIsWriteOnly = 404;
var G_IncorrectDataType = 405;

var G_LastError = G_NoError ;

var commit = false ;

var score=0;
var max=0;
var min=0;
var lesson_status='';
var session_time=0;

function API() {
}

// Initalisation
 API.LMSInitialize = function (val){
	//alert('initialise'+val);
	commit = false ;
	return('true');
}

// Configuration du module
 API.LMSGetValue = function (param){
	//alert('get value'+param);
	switch(param) {
	//tous les elements du core que supporte la plateforme
	case 'cmi.core._children'		://LMS SABA ! 
	case 'cmi.core_children'		: 							
return('entry,exit,lesson_status,student_id,student_name,lesson_location,total_time,credit,lesson_mode,score,session_time');		break;
	//indique si eleve a deja commecer le module
	case 'cmi.core.entry'			: return('');		break;
	//indique comment eleve a quitter le module
	case 'cmi.core.exit'			: return('');		break;
	//etat actuel de eleve
	case 'cmi.core.lesson_status'	: return('not attempted');		break;
	//identifiant de l'utilisateur
	case 'cmi.core.student_id'	    : return('<?PHP echo $guserid ?>');	break;
	//nom de l'utilisateur
	case 'cmi.core.student_name'	: return("<?PHP echo $guser ?>");	break;
	//point de sortie du module lors de la derniere visite
	case 'cmi.core.lesson_location'	: return('');		break;
	//duree cumulative de toutes les seances de eleve sur le module 
	case 'cmi.core.total_time'		: return('0000:00:00.00');		break;
	//info relative au score
	//toutes les elements du score supporter par la plateforme
	case 'cmi.core.score._children'	: return('raw,min,max');		break;
	//score de eleve lors de derniere visite sur le module
	case 'cmi.core.score.raw'		: return('ancien score en dynamique');			break;
	//score max que eleve peut obtenir
	case 'cmi.core.score.max'		: return('100');			break;
	//score min que eleve peut obtenir
	case 'cmi.core.score.min'		: return('0');			break;
	//indique si eleve credite
	case 'cmi.core.credit'			: return('no-credit');	break;
	//indique comportement du module apres lancemant
	case 'cmi.core.lesson_mode'		: return('normal');		break;
	//info generer par le module, il peut les redemander lors du retour sur le module
	case 'cmi.suspend_data'			: return('');		break;
	//info de lancement: contenu dans le manifeste XML qui accompagne le module
	case 'cmi.launch_data'			: return('');		break;
	default : return('');		break;
	}
	return('');
}

// Positionne les valeurs de retour
 API.LMSSetValue = function (param, val){
	//alert('set value'+param);
	switch(param) {
	case 'cmi.core.score.raw'		: score= val ;			break;
	case 'cmi.core.score.max'		: max = val;			break;
	case 'cmi.core.score.min'		: min = val;			break;
	case 'cmi.core.lesson_status'	: lesson_status = val;	break;
	case 'cmi.core.session_time'	: session_time = val;	break;
	}
	return(true);
}

// valide les donnees avant la terminaison
 API.LMSCommit = function (val){
	//alert('trouve commit'+val);
	commit = true ;
	return('true');
}

// terminaison
 API.LMSFinish = function (val){
	if ( commit == true ) {
		param = '&score='+score+'&max='+max+'&min='+min+'&status='+lesson_status+'&time='+session_time ;
		//alert('trouve commit'+param);
		window.location.href = '<?PHP echo $gparam?>' + param ;
	}
	return('true');
}

// Gestion des erreurs au format integer
 API.LMSGetLastError = function (){
	return(G_LastError);
}

// Gestion des erreurs au format string
 API.LMSGetErrorString = function (errCode){
	return('No error !');
}

// Diagnostic : Retourne la derniere erreur.
 API.LMSGetDiagnostic = function (errCode){
	return(API.LMSGetLastError());
}

// -->
</script>
</head>

<frameset rows="*" frameborder="NO" border="0" framespacing="0">
  <frame src="<?PHP echo $file_scorm ?>" name="mainFrame">
</frameset>
<noframes><body>

</body></noframes>
</html>